From fd3128a1645bbe3990d822d5183ad7830b906ceb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Oct 2014 09:40:36 +0200 Subject: [PATCH] - fixed: When changing enhanced nightvision mode the shaders need to have their fixed colormap state reset to ensure that the new settings get used. - fixed: The shader code for handling special fixed colormaps did not use the color vertex attribute which was most evident with the 'shadow' render style on the spectre. --- src/gl/renderer/gl_lightdata.cpp | 7 ++++++- src/gl/shaders/gl_shader.h | 12 ++++++++++++ wadsrc/static/shaders/glsl/main.fp | 3 +-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_lightdata.cpp b/src/gl/renderer/gl_lightdata.cpp index a02762eb80..771c4c65ca 100644 --- a/src/gl/renderer/gl_lightdata.cpp +++ b/src/gl/renderer/gl_lightdata.cpp @@ -67,7 +67,12 @@ CUSTOM_CVAR (Int, gl_light_ambient, 20, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) } CVAR(Int, gl_weaponlight, 8, CVAR_ARCHIVE); -CVAR(Bool,gl_enhanced_nightvision,true,CVAR_ARCHIVE) +CUSTOM_CVAR(Bool, gl_enhanced_nightvision, true, CVAR_ARCHIVE|CVAR_NOINITCALL) +{ + // The fixed colormap state needs to be reset because if this happens when + // a shader is set to CM_LITE or CM_TORCH it won't register the change in behavior caused by this CVAR. + GLRenderer->mShaderManager->ResetFixedColormap(); +} CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index 92ef221af2..8b6f7b4a6e 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -269,6 +269,18 @@ public: return mActiveShader; } + void ResetFixedColormap() + { + for (unsigned i = 0; i < mTextureEffects.Size(); i++) + { + mTextureEffects[i]->currentfixedcolormap = -1; + } + for (unsigned i = 0; i < mTextureEffectsNAT.Size(); i++) + { + mTextureEffectsNAT[i]->currentfixedcolormap = -1; + } + } + FShader *Get(unsigned int eff, bool alphateston) { // indices 0-2 match the warping modes, 3 is brightmap, 4 no texture, the following are custom diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index e7421106b5..1bf583b061 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -313,8 +313,7 @@ void main() case 2: { - frag = frag * uFixedColormapStart; - frag.a *= vColor.a; + frag = vColor * frag * uFixedColormapStart; break; }