mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 17:01:51 +00:00
- fine tuning of the new light modes.
This commit is contained in:
parent
26223ffca2
commit
aa7af0711a
3 changed files with 18 additions and 28 deletions
|
@ -138,7 +138,7 @@ private:
|
||||||
int CalcLightLevel(int lightlevel, int rellight, bool weapon, int blendfactor);
|
int CalcLightLevel(int lightlevel, int rellight, bool weapon, int blendfactor);
|
||||||
PalEntry CalcLightColor(int light, PalEntry pe, int blendfactor);
|
PalEntry CalcLightColor(int light, PalEntry pe, int blendfactor);
|
||||||
void SetShaderLight(FRenderState& state, float level, float olight);
|
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);
|
float GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity, int blendfactor);
|
||||||
|
|
||||||
|
|
|
@ -43,26 +43,12 @@ CUSTOM_CVAR(Int, gl_distfog, 70, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 256; i++)
|
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 - l) / 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;
|
|
||||||
|
|
||||||
if (i < 128)
|
distfogtable[1][i] = 5.f + (float)((gl_distfog >> 1) + (float)((gl_distfog)*(128 - (i >> 1)) / 70));
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
PalEntry fogcolor;
|
||||||
float fogdensity;
|
float fogdensity;
|
||||||
|
@ -101,7 +101,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
|
||||||
if (cmap != nullptr && !fullbright)
|
if (cmap != nullptr && !fullbright)
|
||||||
{
|
{
|
||||||
fogcolor = cmap->FadeColor;
|
fogcolor = cmap->FadeColor;
|
||||||
fogdensity = GetFogDensity(lightlevel, fogcolor, cmap->FogDensity, cmap->BlendFactor);
|
fogdensity = GetFogDensity(lightlevel, fogcolor, cmap->FogDensity, cmap->BlendFactor) * visibility;
|
||||||
fogcolor.a = 0;
|
fogcolor.a = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -160,16 +160,20 @@ void SetLightAndFog(HWDrawInfo* di, FRenderState& state, PalEntry fade, int pale
|
||||||
|
|
||||||
if (!di->isBuildSoftwareLighting() && !foggy)
|
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;
|
float inverselight = shade * 255.f / numshades;
|
||||||
if (fullbright) inverselight /= ShadeDiv;
|
if (inverselight < 0) fullbright = true;
|
||||||
int vislight = 10 - sizeToBits(int(visibility));
|
if (!fullbright) inverselight /= ShadeDiv;
|
||||||
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;
|
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 };
|
FColormap cm = { 0xffffffff };
|
||||||
di->SetColor(state, lightlevel, rellight, fullbright, cm, alpha);
|
di->SetColor(state, lightlevel, 32*rellight, fullbright, cm, alpha);
|
||||||
di->SetFog(state, lightlevel/2 + gvis + vislight, rellight, fullbright, &cm, false);
|
di->SetFog(state, lightlevel, visibility * g_visibility * (1.f/512.f), fullbright, &cm, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Fog must be done before the texture so that the texture selector can override it.
|
// Fog must be done before the texture so that the texture selector can override it.
|
||||||
|
|
Loading…
Reference in a new issue