From 3d47652d080c63da259d23f04b27b9f9ef36eed9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 31 Dec 2019 22:53:03 +0100 Subject: [PATCH] - had a look at Exhumed's shade tables and implemented the necessary adjustments for the 3 with abnormal gradients. --- source/exhumed/src/light.cpp | 25 ++++++------------------- source/glbackend/glbackend.cpp | 2 ++ source/glbackend/glbackend.h | 3 +-- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/source/exhumed/src/light.cpp b/source/exhumed/src/light.cpp index 4d82b7d03..aa0508c3b 100644 --- a/source/exhumed/src/light.cpp +++ b/source/exhumed/src/light.cpp @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "view.h" #include "cd.h" #include "lighting.h" +#include "../glbackend/glbackend.h" #include #include #include @@ -101,25 +102,11 @@ int LoadPaletteLookups() bGreenPal = 0; #ifdef USE_OPENGL - /* - // Very rough approximation... - palookupfogfactor[kPalNormal] = 1.f; - palookupfogfactor[kPalNoDim] = 0.f; - palookupfogfactor[kPalTorch] = 0.36f; - palookupfogfactor[kPalNoTorch] = 0.15f; - palookupfogfactor[kPalBrite] = 2.f; - palookupfogfactor[kPalRedBrite] = 0.36f; - palookupfog[kPalRedBrite] = { 248, 32, 0, 0 }; - hicsetpalettetint(kPalRedBrite, 255, 255, 255, 248, 32, 0, 0); - palookupfog[kPalGreenBrite] = { 248, 32, 0, 0 }; - palookupfogfactor[kPalGreenBrite] = 0.f; - hicsetpalettetint(kPalGreenBrite, 100, 200, 100, 0, 0, 0, 0); - palookupfogfactor[kPalNormal2] = 1.f; - palookupfogfactor[kPalNoDim2] = 0.f; - palookupfogfactor[kPalTorch2] = 0.36f; - palookupfogfactor[kPalNoTorch2] = 0.15f; - palookupfogfactor[kPalBrite2] = 2.f; - */ + // These 3 tables do not have normal gradients. The others work without adjustment. + // Other changes than altering the fog gradient are not necessary. + shadediv[kPalTorch] = shadediv[kPalTorch2] = 1 / 20.f; + shadediv[kPalNoTorch] = shadediv[kPalNoTorch2] = 0.25f; + shadediv[kPalBrite] = shadediv[kPalBrite] = 1 / 128.f; #endif } diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 84143e76f..b346eb7dc 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -50,6 +50,7 @@ #include "gl_renderer.h" extern int xdim, ydim; +float shadediv[MAXPALOOKUPS]; FileReader GetResource(const char* fn) { @@ -511,6 +512,7 @@ void GLInstance::SetPalette(int index) void GLInstance::SetPalswap(int index) { palmanager.BindPalswap(index); + renderState.ShadeDiv = shadediv[index] == 0 ? 1.f / (renderState.NumShades) : shadediv[index]; } void GLInstance::DrawImGui(ImDrawData* data) diff --git a/source/glbackend/glbackend.h b/source/glbackend/glbackend.h index f4c62fa7f..cd6ec21f6 100644 --- a/source/glbackend/glbackend.h +++ b/source/glbackend/glbackend.h @@ -174,6 +174,7 @@ enum ETexType struct ImDrawData; struct palette_t; +extern float shadediv[256]; class GLInstance { @@ -334,8 +335,6 @@ public: { renderState.Shade = shade; renderState.NumShades = numshades; - renderState.ShadeDiv = 1.f / (numshades-2); - } void SetVisibility(float visibility, float fviewingrange)