- Implemented radial fog support in software light mode

This commit is contained in:
Magnus Norddahl 2017-06-25 15:02:34 +02:00
parent f34ededdef
commit b6e035e796
2 changed files with 11 additions and 3 deletions

View File

@ -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<int>(gl_bandedswlight) | (static_cast<int>(gl_fogmode) << 8));
activeShader->muTextureMode.Set(mTextureMode);
activeShader->muCameraPos.Set(mCameraPos.vec);
activeShader->muLightParms.Set(mLightParms);

View File

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