- changed handling of DynLight in shader to serve as a global dynamic light color for all lighting modes.
This commit is contained in:
parent
53f4cd0108
commit
52056a05bd
12 changed files with 61 additions and 89 deletions
|
|
@ -256,13 +256,15 @@ PalEntry gl_CalcLightColor(int light, PalEntry pe, int blendfactor, bool force)
|
|||
}
|
||||
else
|
||||
{
|
||||
// This is what Legacy does with colored light in 3D volumes. No, it doesn't really make sense...
|
||||
// It also doesn't translate well to software style lighting.
|
||||
int mixlight = light * (255 - blendfactor);
|
||||
|
||||
r = (mixlight + pe.r * blendfactor) / 255;
|
||||
g = (mixlight + pe.g * blendfactor) / 255;
|
||||
b = (mixlight + pe.b * blendfactor) / 255;
|
||||
}
|
||||
return PalEntry(BYTE(r), BYTE(g), BYTE(b));
|
||||
return PalEntry(255, BYTE(r), BYTE(g), BYTE(b));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
@ -373,7 +375,7 @@ void gl_SetColor(int light, int rellight, const FColormap * cm, float alpha, Pal
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
float gl_GetFogDensity(int lightlevel, PalEntry fogcolor)
|
||||
static float gl_GetFogDensity(int lightlevel, PalEntry fogcolor)
|
||||
{
|
||||
float density;
|
||||
|
||||
|
|
@ -417,98 +419,65 @@ float gl_GetFogDensity(int lightlevel, PalEntry fogcolor)
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Check fog by current lighting info
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool gl_CheckFog(FColormap *cm, int lightlevel)
|
||||
{
|
||||
// Check for fog boundaries. This needs a few more checks for the sectors
|
||||
bool frontfog;
|
||||
|
||||
PalEntry fogcolor = cm->FadeColor;
|
||||
|
||||
if ((fogcolor.d & 0xffffff) == 0)
|
||||
{
|
||||
frontfog = false;
|
||||
}
|
||||
else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff))
|
||||
{
|
||||
frontfog = true;
|
||||
}
|
||||
else if (fogdensity!=0 || (glset.lightmode & 4))
|
||||
{
|
||||
// case 3: level has fog density set
|
||||
frontfog = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// case 4: use light level
|
||||
frontfog = lightlevel < 248;
|
||||
}
|
||||
return frontfog;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Check if the current linedef is a candidate for a fog boundary
|
||||
//
|
||||
// Requirements for a fog boundary:
|
||||
// - front sector has no fog
|
||||
// - back sector has fog
|
||||
// - at least one of both does not have a sky ceiling.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool gl_CheckFog(sector_t *frontsector, sector_t *backsector)
|
||||
{
|
||||
if (gl_fixedcolormap) return false;
|
||||
if (frontsector == backsector) return false; // there can't be a boundary if both sides are in the same sector.
|
||||
|
||||
// Check for fog boundaries. This needs a few more checks for the sectors
|
||||
bool frontfog, backfog;
|
||||
|
||||
PalEntry fogcolor = frontsector->ColorMap->Fade;
|
||||
|
||||
if ((fogcolor.d & 0xffffff) == 0)
|
||||
{
|
||||
frontfog = false;
|
||||
return false;
|
||||
}
|
||||
else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff))
|
||||
{
|
||||
frontfog = true;
|
||||
}
|
||||
else if (fogdensity!=0 || (glset.lightmode & 4))
|
||||
{
|
||||
// case 3: level has fog density set
|
||||
frontfog = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// case 4: use light level
|
||||
frontfog = frontsector->lightlevel < 248;
|
||||
if (frontsector->lightlevel >= 248) return false;
|
||||
}
|
||||
|
||||
if (backsector == NULL) return frontfog;
|
||||
|
||||
fogcolor = backsector->ColorMap->Fade;
|
||||
|
||||
if ((fogcolor.d & 0xffffff) == 0)
|
||||
{
|
||||
backfog = false;
|
||||
}
|
||||
else if (outsidefogdensity != 0 && outsidefogcolor.a!=0xff && (fogcolor.d & 0xffffff) == (outsidefogcolor.d & 0xffffff))
|
||||
{
|
||||
backfog = true;
|
||||
return false;
|
||||
}
|
||||
else if (fogdensity!=0 || (glset.lightmode & 4))
|
||||
{
|
||||
// case 3: level has fog density set
|
||||
backfog = true;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// case 4: use light level
|
||||
backfog = backsector->lightlevel < 248;
|
||||
if (backsector->lightlevel < 248) return false;
|
||||
}
|
||||
|
||||
// in all other cases this might create more problems than it solves.
|
||||
return (frontfog && !backfog && !gl_fixedcolormap &&
|
||||
(frontsector->GetTexture(sector_t::ceiling)!=skyflatnum ||
|
||||
return ((frontsector->GetTexture(sector_t::ceiling)!=skyflatnum ||
|
||||
backsector->GetTexture(sector_t::ceiling)!=skyflatnum));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue