diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index fa8237cca1..22330905fc 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -43,6 +43,7 @@ void gl_SetTextureMode(int type); FRenderState gl_RenderState; CVAR(Bool, gl_direct_state_change, true, 0) +CVAR(Bool, gl_bandedswlight, true, CVAR_ARCHIVE) static VSMatrix identityMatrix(1); @@ -146,6 +147,7 @@ bool FRenderState::ApplyShader() activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); + activeShader->muPalLightLevels.Set(gl_bandedswlight); activeShader->muTextureMode.Set(mTextureMode); activeShader->muCameraPos.Set(mCameraPos.vec); activeShader->muLightParms.Set(mLightParms); diff --git a/src/gl/shaders/gl_shader.cpp b/src/gl/shaders/gl_shader.cpp index 327ac5fd4d..ef512faea9 100644 --- a/src/gl/shaders/gl_shader.cpp +++ b/src/gl/shaders/gl_shader.cpp @@ -214,6 +214,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * muDesaturation.Init(hShader, "uDesaturationFactor"); muFogEnabled.Init(hShader, "uFogEnabled"); + muPalLightLevels.Init(hShader, "uPalLightLevels"); muTextureMode.Init(hShader, "uTextureMode"); muCameraPos.Init(hShader, "uCameraPos"); muLightParms.Init(hShader, "uLightAttr"); diff --git a/src/gl/shaders/gl_shader.h b/src/gl/shaders/gl_shader.h index acdd530aae..f9eb5c2920 100644 --- a/src/gl/shaders/gl_shader.h +++ b/src/gl/shaders/gl_shader.h @@ -259,6 +259,7 @@ class FShader FBufferedUniform1f muDesaturation; FBufferedUniform1i muFogEnabled; + FBufferedUniform1i muPalLightLevels; FBufferedUniform1i muTextureMode; FBufferedUniform4f muCameraPos; FBufferedUniform4f muLightParms; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index ddf23edb9c..bdc1ce3ae5 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2647,6 +2647,7 @@ GLPREFMNU_SSAO_PORTALS = "Portals with AO"; GLPREFMNU_FXAA = "FXAA Quality"; GLPREFMNU_PALTONEMAPORDER = "Tonemap Palette Order"; GLPREFMNU_PALTONEMAPPOWER = "Tonemap Palette Exponent"; +GLPREFMNU_SWLMBANDED = "Banded SW Lightmode"; // Option Values OPTVAL_SMART = "Smart"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index f683f2e0d3..606d21ab62 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -232,6 +232,7 @@ OptionMenu "GLPrefOptions" { Title "$GLPREFMNU_TITLE" Option "$GLPREFMNU_SECLIGHTMODE", gl_lightmode, "LightingModes" + Option "$GLPREFMNU_SWLMBANDED", gl_bandedswlight, "OnOff" Option "$GLPREFMNU_FOGMODE", gl_fogmode, "FogMode" Option "$GLPREFMNU_FOGFORCEFULLBRIGHT", gl_brightfog, "YesNo" Slider "$GLPREFMNU_WPNLIGHTSTR", gl_weaponlight, 0,32, 2 diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 5834dcf5d8..0c55adb507 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -121,7 +121,11 @@ float R_DoomLightingEquation(float light) /* The zdoom light equation */ float vis = globVis / z; float shade = 64.0 - (L + 12.0) * 32.0/128.0; - float lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0); + float lightscale; + if (uPalLightLevels != 0) + lightscale = clamp(int(shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0); + else + lightscale = clamp((shade - min(24.0, vis)) / 32.0, 0.0, 31.0/32.0); // Result is the normalized colormap index (0 bright .. 1 dark) return lightscale; diff --git a/wadsrc/static/shaders/glsl/shaderdefs.i b/wadsrc/static/shaders/glsl/shaderdefs.i index 8c5697a661..2099427d53 100644 --- a/wadsrc/static/shaders/glsl/shaderdefs.i +++ b/wadsrc/static/shaders/glsl/shaderdefs.i @@ -41,6 +41,7 @@ uniform vec4 uLightAttr; #define uLightFactor uLightAttr.g #define uLightDist uLightAttr.r uniform int uFogEnabled; +uniform int uPalLightLevels; // dynamic lights uniform int uLightIndex;