- made the new Build light mode operational

This commit is contained in:
Christoph Oelckers 2020-06-10 22:41:36 +02:00
parent 45210efb91
commit b20de184a0
5 changed files with 17 additions and 4 deletions

View file

@ -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<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
if (gl_lightmode == 5)
{
VPUniforms.mGlobVis = 1 / 64.f;
VPUniforms.mPalLightLevels = 32 | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
}
else
{
VPUniforms.mGlobVis = (float)R_GetGlobVis(r_viewwindow, r_visibility) / 32.f;
VPUniforms.mPalLightLevels = static_cast<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8) | ((int)lightmode << 16);
}
VPUniforms.mClipLine.X = -10000000.0f;
VPUniforms.mShadowmapFilter = gl_shadowmap_filter;
}

View file

@ -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)];
}

View file

@ -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);

View file

@ -2401,6 +2401,7 @@ OptionValue "LightingModes"
2, "$OPTVAL_DOOM"
3, "$OPTVAL_DARK"
4, "$OPTVAL_LEGACY"
5, "$OPTVAL_BUILD"
8, "$OPTVAL_SOFTWARE"
16, "$OPTVAL_VANILLA"
}

View file

@ -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);