- delay converting sprite lightlevels to a shade until we hit ColormapLight

This commit is contained in:
Magnus Norddahl 2018-12-17 07:54:46 +01:00
commit 2ce91ea62f
22 changed files with 57 additions and 55 deletions

View file

@ -160,7 +160,7 @@ namespace swrenderer
/////////////////////////////////////////////////////////////////////////
void ColormapLight::SetColormap(double visibility, int shade, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack)
void ColormapLight::SetColormap(RenderThread *thread, double z, int lightlevel, bool foggy, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack, bool psprite, bool particle)
{
if (fadeToBlack)
{
@ -181,16 +181,16 @@ namespace swrenderer
}
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedColormap())
{
BaseColormap = cameraLight->FixedColormap();
ColormapNum = 0;
}
else if (cameraLight->FixedLightLevel() >= 0)
if (cameraLight->FixedLightLevel() >= 0)
{
BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap;
ColormapNum = cameraLight->FixedLightLevel() >> COLORMAPSHIFT;
}
else if (cameraLight->FixedColormap())
{
BaseColormap = cameraLight->FixedColormap();
ColormapNum = 0;
}
else if (fullbright)
{
BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap;
@ -198,6 +198,14 @@ namespace swrenderer
}
else
{
double visibility = thread->Light->SpriteVis(z, foggy);
if (particle)
visibility *= 0.5;
int shade = LightVisibility::LightLevelToShade(lightlevel, foggy, thread->Viewport.get());
if (psprite)
shade -= 24 * FRACUNIT;
BaseColormap = basecolormap;
ColormapNum = GETPALOOKUP(visibility, shade);
}