mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 07:11:54 +00:00
- fixed the use of Doom-Legacy-style 3D floor lighting in light mode 8.
Legacy used some strange blending formula to calculate its colormaps for colored 3D floor lighting, this is not available in the software lighting mode, so for these the engine has to temporarily revert to light mode 2 to render them correctly.
This commit is contained in:
parent
3dcaa509ef
commit
1c3d4b46c6
7 changed files with 29 additions and 22 deletions
|
@ -103,10 +103,10 @@ void gl_SetColor(int sectorlightlevel, int rellight, bool fullbright, const FCol
|
|||
}
|
||||
else
|
||||
{
|
||||
int hwlightlevel = hw_CalcLightLevel(sectorlightlevel, rellight, weapon);
|
||||
int hwlightlevel = hw_CalcLightLevel(sectorlightlevel, rellight, weapon, cm.BlendFactor);
|
||||
PalEntry pe = hw_CalcLightColor(hwlightlevel, cm.LightColor, cm.BlendFactor);
|
||||
gl_RenderState.SetColorAlpha(pe, alpha, cm.Desaturation);
|
||||
gl_RenderState.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight));
|
||||
gl_RenderState.SetSoftLightLevel(hw_ClampLight(sectorlightlevel + rellight), cm.BlendFactor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ void gl_SetFog(int lightlevel, int rellight, bool fullbright, const FColormap *c
|
|||
else if (cmap != NULL && !fullbright)
|
||||
{
|
||||
fogcolor = cmap->FadeColor;
|
||||
fogdensity = hw_GetFogDensity(lightlevel, fogcolor, cmap->FogDensity);
|
||||
fogdensity = hw_GetFogDensity(lightlevel, fogcolor, cmap->FogDensity, cmap->BlendFactor);
|
||||
fogcolor.a=0;
|
||||
}
|
||||
else
|
||||
|
@ -184,9 +184,9 @@ void gl_SetFog(int lightlevel, int rellight, bool fullbright, const FColormap *c
|
|||
}
|
||||
else
|
||||
{
|
||||
if (level.lightmode == 2 && fogcolor == 0)
|
||||
if ((level.lightmode == 2 || (level.lightmode == 8) && cmap->BlendFactor > 0) && fogcolor == 0)
|
||||
{
|
||||
float light = hw_CalcLightLevel(lightlevel, rellight, false);
|
||||
float light = hw_CalcLightLevel(lightlevel, rellight, false, cmap->BlendFactor);
|
||||
gl_SetShaderLight(light, lightlevel);
|
||||
}
|
||||
else
|
||||
|
@ -205,7 +205,7 @@ void gl_SetFog(int lightlevel, int rellight, bool fullbright, const FColormap *c
|
|||
gl_RenderState.SetFog(fogcolor, fogdensity);
|
||||
|
||||
// Korshun: fullbright fog like in software renderer.
|
||||
if (level.lightmode == 8 && level.brightfog && fogdensity != 0 && fogcolor != 0)
|
||||
if (level.lightmode == 8 && cmap->BlendFactor == 0 && level.brightfog && fogdensity != 0 && fogcolor != 0)
|
||||
{
|
||||
gl_RenderState.SetSoftLightLevel(255);
|
||||
}
|
||||
|
|
|
@ -290,9 +290,9 @@ public:
|
|||
mGlowBottom.Set(b[0], b[1], b[2], b[3]);
|
||||
}
|
||||
|
||||
void SetSoftLightLevel(int llevel)
|
||||
void SetSoftLightLevel(int llevel, int blendfactor = 0)
|
||||
{
|
||||
if (level.lightmode == 8) mLightParms[3] = llevel / 255.f;
|
||||
if (level.lightmode == 8 && blendfactor == 0) mLightParms[3] = llevel / 255.f;
|
||||
else mLightParms[3] = -1.f;
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ void FDrawInfo::DrawSprite(GLSprite *sprite, int pass)
|
|||
if (!sprite->Colormap.FadeColor.isBlack())
|
||||
{
|
||||
float dist=Dist2(vp.Pos.X, vp.Pos.Y, sprite->x, sprite->y);
|
||||
int fogd = hw_GetFogDensity(sprite->lightlevel, sprite->Colormap.FadeColor, sprite->Colormap.FogDensity);
|
||||
int fogd = hw_GetFogDensity(sprite->lightlevel, sprite->Colormap.FadeColor, sprite->Colormap.FogDensity, sprite->Colormap.BlendFactor);
|
||||
|
||||
// this value was determined by trial and error and is scale dependent!
|
||||
float factor = 0.05f + exp(-fogd*dist / 62500.f);
|
||||
|
|
|
@ -190,7 +190,7 @@ static WeaponLighting GetWeaponLighting(sector_t *viewsector, const DVector3 &po
|
|||
if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) l.cm.ClearColor();
|
||||
}
|
||||
|
||||
l.lightlevel = hw_CalcLightLevel(l.lightlevel, getExtraLight(), true);
|
||||
l.lightlevel = hw_CalcLightLevel(l.lightlevel, getExtraLight(), true, 0);
|
||||
|
||||
if (level.lightmode == 8 || l.lightlevel < 92)
|
||||
{
|
||||
|
|
|
@ -82,13 +82,15 @@ CUSTOM_CVAR(Int,gl_fogmode,1,CVAR_ARCHIVE|CVAR_NOINITCALL)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
int hw_CalcLightLevel(int lightlevel, int rellight, bool weapon)
|
||||
int hw_CalcLightLevel(int lightlevel, int rellight, bool weapon, int blendfactor)
|
||||
{
|
||||
int light;
|
||||
|
||||
if (lightlevel == 0) return 0;
|
||||
|
||||
if ((level.lightmode & 2) && lightlevel < 192 && !weapon)
|
||||
bool darklightmode = (level.lightmode & 2) || (level.lightmode == 8 && blendfactor > 0);
|
||||
|
||||
if (darklightmode && lightlevel < 192 && !weapon)
|
||||
{
|
||||
if (lightlevel > 100)
|
||||
{
|
||||
|
@ -126,12 +128,13 @@ PalEntry hw_CalcLightColor(int light, PalEntry pe, int blendfactor)
|
|||
{
|
||||
int r,g,b;
|
||||
|
||||
if (blendfactor == 0)
|
||||
{
|
||||
if (level.lightmode == 8)
|
||||
{
|
||||
return pe;
|
||||
}
|
||||
else if (blendfactor == 0)
|
||||
{
|
||||
|
||||
r = pe.r * light / 255;
|
||||
g = pe.g * light / 255;
|
||||
b = pe.b * light / 255;
|
||||
|
@ -167,11 +170,14 @@ PalEntry hw_CalcLightColor(int light, PalEntry pe, int blendfactor)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
float hw_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity)
|
||||
float hw_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity, int blendfactor)
|
||||
{
|
||||
float density;
|
||||
|
||||
if (level.lightmode & 4)
|
||||
int lightmode = level.lightmode;
|
||||
if (lightmode == 8 && blendfactor > 0) lightmode = 2; // The blendfactor feature does not work with software-style lighting.
|
||||
|
||||
if (lightmode & 4)
|
||||
{
|
||||
// uses approximations of Legacy's default settings.
|
||||
density = level.fogdensity ? (float)level.fogdensity : 18;
|
||||
|
@ -184,7 +190,7 @@ float hw_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity)
|
|||
else if ((fogcolor.d & 0xffffff) == 0)
|
||||
{
|
||||
// case 2: black fog
|
||||
if (level.lightmode != 8 && !(level.flags3 & LEVEL3_NOLIGHTFADE))
|
||||
if ((lightmode != 8 || blendfactor > 0) && !(level.flags3 & LEVEL3_NOLIGHTFADE))
|
||||
{
|
||||
density = distfogtable[level.lightmode != 0][hw_ClampLight(lightlevel)];
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
struct Colormap;
|
||||
|
||||
int hw_CalcLightLevel(int lightlevel, int rellight, bool weapon);
|
||||
int hw_CalcLightLevel(int lightlevel, int rellight, bool weapon, int blendfactor);
|
||||
PalEntry hw_CalcLightColor(int light, PalEntry pe, int blendfactor);
|
||||
float hw_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity);
|
||||
float hw_GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfogdensity, int blendfactor);
|
||||
bool hw_CheckFog(sector_t *frontsector, sector_t *backsector);
|
||||
|
||||
inline int hw_ClampLight(int lightlevel)
|
||||
|
|
|
@ -428,6 +428,7 @@ void F2DDrawer::AddPoly(FTexture *texture, FVector2 *points, int npoints,
|
|||
// is necessary in order to best reproduce Doom's original lighting.
|
||||
double fadelevel;
|
||||
|
||||
// The hardware renderer's light modes 0, 1 and 4 use a linear light scale which must be used here as well. Otherwise the automap gets too dark.
|
||||
if (vid_rendermode != 4 || (level.lightmode >= 2 && level.lightmode != 4))
|
||||
{
|
||||
double map = (NUMCOLORMAPS * 2.) - ((lightlevel + 12) * (NUMCOLORMAPS / 128.));
|
||||
|
|
Loading…
Reference in a new issue