- fine tuning of the new light modes.

This commit is contained in:
Christoph Oelckers 2022-01-10 19:11:41 +01:00
parent 26223ffca2
commit aa7af0711a
3 changed files with 18 additions and 28 deletions

View file

@ -138,7 +138,7 @@ private:
int CalcLightLevel(int lightlevel, int rellight, bool weapon, int blendfactor);
PalEntry CalcLightColor(int light, PalEntry pe, int blendfactor);
void SetShaderLight(FRenderState& state, float level, float olight);
void SetFog(FRenderState& state, int lightlevel, int rellight, bool fullbright, const FColormap* cmap, bool isadditive);
void SetFog(FRenderState& state, int lightlevel, float visibility, bool fullbright, const FColormap* cmap, bool isadditive);
float GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity, int blendfactor);

View file

@ -43,26 +43,12 @@ CUSTOM_CVAR(Int, gl_distfog, 70, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
for (int i = 0; i < 256; i++)
{
int l = i >> 1;
if (i < 64) l = -32 + i;
if (i < 164)
{
distfogtable[0][i] = (float)((gl_distfog >> 1) + (gl_distfog)*(164 - i) / 164);
}
else if (i < 230)
{
distfogtable[0][i] = (float)((gl_distfog >> 1) - (gl_distfog >> 1)*(i - 164) / (230 - 164));
}
else distfogtable[0][i] = 0;
distfogtable[0][i] = (float)((gl_distfog >> 1) + (gl_distfog)*(164 - l) / 164);
if (i < 128)
{
distfogtable[1][i] = 6.f + (float)((gl_distfog >> 1) + (gl_distfog)*(128 - i) / 48);
}
else if (i < 216)
{
distfogtable[1][i] = (216.f - i) / ((216.f - 128.f)) * gl_distfog / 10;
}
else distfogtable[1][i] = 0;
distfogtable[1][i] = 5.f + (float)((gl_distfog >> 1) + (float)((gl_distfog)*(128 - (i >> 1)) / 70));
}
}

View file

@ -93,7 +93,7 @@ void HWDrawInfo::SetShaderLight(FRenderState &state, float level, float olight)
//
//==========================================================================
void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool fullbright, const FColormap *cmap, bool isadditive)
void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, float visibility, bool fullbright, const FColormap *cmap, bool isadditive)
{
PalEntry fogcolor;
float fogdensity;
@ -101,7 +101,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
if (cmap != nullptr && !fullbright)
{
fogcolor = cmap->FadeColor;
fogdensity = GetFogDensity(lightlevel, fogcolor, cmap->FogDensity, cmap->BlendFactor);
fogdensity = GetFogDensity(lightlevel, fogcolor, cmap->FogDensity, cmap->BlendFactor) * visibility;
fogcolor.a = 0;
}
else
@ -160,16 +160,20 @@ void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int pale
if (!di->isBuildSoftwareLighting() && !foggy)
{
bool fullbright = ShadeDiv < 1 / 1000.f;
bool fullbright = ShadeDiv < 1 / 1000.f || g_visibility == 0;
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;
if (inverselight < 0) fullbright = true;
if (!fullbright) inverselight /= ShadeDiv;
int lightlevel = !fullbright ? clamp(int(255 - inverselight), 0, 255) : 255;
int rellight = 0;
if (g_relvisibility)
{
rellight = sizeToBits(g_visibility) - sizeToBits(g_visibility + g_relvisibility);
}
FColormap cm = { 0xffffffff };
di->SetColor(state, lightlevel, rellight, fullbright, cm, alpha);
di->SetFog(state, lightlevel/2 + gvis + vislight, rellight, fullbright, &cm, false);
di->SetColor(state, lightlevel, 32*rellight, fullbright, cm, alpha);
di->SetFog(state, lightlevel, visibility * g_visibility * (1.f/512.f), fullbright, &cm, false);
return;
}
// Fog must be done before the texture so that the texture selector can override it.