diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index 88f220703..1360c37c0 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -139,8 +139,9 @@ void HWDrawInfo::StartScene(FRenderViewpoint& parentvp, HWViewpointUniforms* uni VPUniforms.mViewMatrix.loadIdentity(); VPUniforms.mNormalViewMatrix.loadIdentity(); //VPUniforms.mViewHeight = viewheight; - VPUniforms.mGlobVis = (2 / 65536.f) * (isBuildSoftwareLighting()? g_visibility + g_relvisibility : g_visibility) / r_ambientlight; - VPUniforms.mPalLightLevels = numshades | (static_cast(gl_fogmode) << 8) | (5 << 16); + VPUniforms.mGlobVis = (2 / 65536.f) * (g_visibility + g_relvisibility) / r_ambientlight; + VPUniforms.mPalLightLevels = numshades | (static_cast(gl_fogmode) << 8); + if (isBuildSoftwareLighting()) VPUniforms.mPalLightLevels |= (5 << 16); VPUniforms.mClipLine.X = -10000000.0f; VPUniforms.mShadowmapFilter = gl_shadowmap_filter; diff --git a/source/core/rendering/scene/hw_lighting.cpp b/source/core/rendering/scene/hw_lighting.cpp index 78ef240ec..805df15f4 100644 --- a/source/core/rendering/scene/hw_lighting.cpp +++ b/source/core/rendering/scene/hw_lighting.cpp @@ -156,8 +156,7 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog else if ((fogcolor.d & 0xffffff) == 0) { // case 2: black fog - density = distfogtable[0][hw_ClampLight(lightlevel)]; - //density = distfogtable[lightmode != ELightMode::LinearStandard][hw_ClampLight(lightlevel)]; + density = distfogtable[hw_lightmode != 1][hw_ClampLight(lightlevel)]; } #if 0 else if (Level->outsidefogdensity != 0 && APART(Level->info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (Level->info->outsidefog & 0xffffff)) diff --git a/source/core/rendering/scene/hw_setcolor.cpp b/source/core/rendering/scene/hw_setcolor.cpp index 9ab1c7295..1de7ebb96 100644 --- a/source/core/rendering/scene/hw_setcolor.cpp +++ b/source/core/rendering/scene/hw_setcolor.cpp @@ -154,16 +154,26 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int palette, int shade, float visibility, float alpha) { - if (!di->isBuildSoftwareLighting()) - { - - return; - } - // Fog must be done before the texture so that the texture selector can override it. bool foggy = (GlobalMapFog || (fade & 0xffffff)); auto ShadeDiv = lookups.tables[palette].ShadeFactor; if (shade == 127) state.SetObjectColor(0xff000000); // 127 is generally used for shadow objects that must be black, even in foggy areas. + if (!di->isBuildSoftwareLighting() && !foggy) + { + bool fullbright = ShadeDiv < 1 / 1000.f; + float inverselight = shade * 255.f / numshades; + if (fullbright) inverselight /= ShadeDiv; + int vislight = 10 - sizeToBits(int(visibility)); + int gvis = -sizeToBits(g_visibility) * 2; + int rellight = 10 - sizeToBits(g_visibility + g_relvisibility) - gvis; + int lightlevel = !fullbright ? clamp(int(255 - inverselight), 0, 255) : 255; + FColormap cm = { 0xffffffff }; + di->SetColor(state, lightlevel, rellight, fullbright, cm, alpha); + di->SetFog(state, lightlevel/2 + gvis + vislight, rellight, fullbright, &cm, false); + return; + } + // Fog must be done before the texture so that the texture selector can override it. + // Disable brightmaps if non-black fog is used. if (ShadeDiv >= 1 / 1000.f && foggy) {