From b6e035e79641892730fd12e13cc178e984c72b52 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sun, 25 Jun 2017 15:02:34 +0200 Subject: [PATCH] - Implemented radial fog support in software light mode --- src/gl/renderer/gl_renderstate.cpp | 2 +- wadsrc/static/shaders/glsl/main.fp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gl/renderer/gl_renderstate.cpp b/src/gl/renderer/gl_renderstate.cpp index 33c072ea9..939140640 100644 --- a/src/gl/renderer/gl_renderstate.cpp +++ b/src/gl/renderer/gl_renderstate.cpp @@ -150,7 +150,7 @@ bool FRenderState::ApplyShader() activeShader->muDesaturation.Set(mDesaturation / 255.f); activeShader->muFogEnabled.Set(fogset); - activeShader->muPalLightLevels.Set(gl_bandedswlight); + activeShader->muPalLightLevels.Set(static_cast(gl_bandedswlight) | (static_cast(gl_fogmode) << 8)); activeShader->muTextureMode.Set(mTextureMode); activeShader->muCameraPos.Set(mCameraPos.vec); activeShader->muLightParms.Set(mLightParms); diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index ee113676b..d778aa240 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -113,13 +113,21 @@ float R_DoomLightingEquation(float light) float L = light * 255.0; // z is the depth in view/eye space, positive going into the screen - float z = pixelpos.w; + float z; + if ((uPalLightLevels >> 8) == 1) + { + z = pixelpos.w; + } + else + { + z = distance(pixelpos.xyz, uCameraPos.xyz); + } // The zdoom light equation float vis = min(globVis / z, 24.0 / 32.0); float shade = 2.0 - (L + 12.0) / 128.0; float lightscale; - if (uPalLightLevels != 0) + if ((uPalLightLevels & 0xff) != 0) lightscale = float(-int(-(shade - vis) * 32.0)) / 32.0; else lightscale = shade - vis;