From b20de184a0e11e26a4d69bb400262f40ccf4a858 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 10 Jun 2020 22:41:36 +0200 Subject: [PATCH] - made the new Build light mode operational --- src/rendering/hwrenderer/scene/hw_drawinfo.cpp | 12 ++++++++++-- src/rendering/hwrenderer/scene/hw_lighting.cpp | 2 +- src/rendering/hwrenderer/scene/hw_setcolor.cpp | 4 ++++ wadsrc/static/menudef.txt | 1 + wadsrc/static/shaders/glsl/main.fp | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp index 421024947f..3bb41ff422 100644 --- a/src/rendering/hwrenderer/scene/hw_drawinfo.cpp +++ b/src/rendering/hwrenderer/scene/hw_drawinfo.cpp @@ -146,8 +146,16 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni VPUniforms.mViewMatrix.loadIdentity(); VPUniforms.mNormalViewMatrix.loadIdentity(); VPUniforms.mViewHeight = viewheight; - VPUniforms.mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f; - VPUniforms.mPalLightLevels = static_cast(gl_bandedswlight) | (static_cast(gl_fogmode) << 8) | ((int)lightmode << 16); + if (gl_lightmode == 5) + { + VPUniforms.mGlobVis = 1 / 64.f; + VPUniforms.mPalLightLevels = 32 | (static_cast(gl_fogmode) << 8) | ((int)lightmode << 16); + } + else + { + VPUniforms.mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f; + VPUniforms.mPalLightLevels = static_cast(gl_bandedswlight) | (static_cast(gl_fogmode) << 8) | ((int)lightmode << 16); + } VPUniforms.mClipLine.X = -10000000.0f; VPUniforms.mShadowmapFilter = gl_shadowmap_filter; } diff --git a/src/rendering/hwrenderer/scene/hw_lighting.cpp b/src/rendering/hwrenderer/scene/hw_lighting.cpp index bb45f08561..ca8fa546dd 100644 --- a/src/rendering/hwrenderer/scene/hw_lighting.cpp +++ b/src/rendering/hwrenderer/scene/hw_lighting.cpp @@ -185,7 +185,7 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog else if ((fogcolor.d & 0xffffff) == 0) { // case 2: black fog - if ((!isSoftwareLighting() || blendfactor > 0) && !(Level->flags3 & LEVEL3_NOLIGHTFADE)) + if ((!isDoomSoftwareLighting() || blendfactor > 0) && !(Level->flags3 & LEVEL3_NOLIGHTFADE)) { density = distfogtable[lightmode != ELightMode::LinearStandard][hw_ClampLight(lightlevel)]; } diff --git a/src/rendering/hwrenderer/scene/hw_setcolor.cpp b/src/rendering/hwrenderer/scene/hw_setcolor.cpp index a81db3a1c6..053a43b971 100644 --- a/src/rendering/hwrenderer/scene/hw_setcolor.cpp +++ b/src/rendering/hwrenderer/scene/hw_setcolor.cpp @@ -135,6 +135,10 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool float light = (float)CalcLightLevel(lightlevel, rellight, false, cmap->BlendFactor); SetShaderLight(state, light, lightlevel); } + else if (lightmode == ELightMode::Build) + { + state.SetLightParms(0.2f * fogdensity, 1.f / 31.f); + } else { state.SetLightParms(1.f, 0.f); diff --git a/wadsrc/static/menudef.txt b/wadsrc/static/menudef.txt index 1e06d6cd84..14935cb4fe 100644 --- a/wadsrc/static/menudef.txt +++ b/wadsrc/static/menudef.txt @@ -2401,6 +2401,7 @@ OptionValue "LightingModes" 2, "$OPTVAL_DOOM" 3, "$OPTVAL_DARK" 4, "$OPTVAL_LEGACY" + 5, "$OPTVAL_BUILD" 8, "$OPTVAL_SOFTWARE" 16, "$OPTVAL_VANILLA" } diff --git a/wadsrc/static/shaders/glsl/main.fp b/wadsrc/static/shaders/glsl/main.fp index 611dbe0b21..009427dd2e 100644 --- a/wadsrc/static/shaders/glsl/main.fp +++ b/wadsrc/static/shaders/glsl/main.fp @@ -313,7 +313,7 @@ float R_DoomLightingEquation(float light) { // This is a lot more primitive than Doom's lighting... float numShades = float(uPalLightLevels & 255); - float curshade = (1.0 - light) / (numShades - 1.0); + float curshade = (1.0 - light) * (numShades - 1.0); float visibility = max(uGlobVis * uLightFactor * z, 0.0); float shade = clamp((curshade + visibility), 0.0, numShades - 1.0); return clamp(shade * uLightDist, 0.0, 1.0);