Minor code clean up

This commit is contained in:
Magnus Norddahl 2017-03-06 23:27:02 +01:00
parent cb8b2de287
commit 65f8d65858
17 changed files with 56 additions and 67 deletions

View file

@ -2951,7 +2951,7 @@ void OpenGLSWFrameBuffer::FillSimplePoly(FTexture *texture, FVector2 *points, in
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
{
// Use an equation similar to player sprites to determine shade
double fadelevel = clamp((swrenderer::LIGHT2SHADE(lightlevel, true) / 65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
double fadelevel = clamp((swrenderer::LightVisibility::LightLevelToShade(lightlevel, true) / 65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
BufferedTris *quad;
FBVERTEX *verts;

View file

@ -223,7 +223,7 @@ void RenderPolyPlayerSprites::RenderSprite(DPSprite *sprite, AActor *owner, floa
bool foggy = false;
int actualextralight = foggy ? 0 : extralight << 4;
int spriteshade = swrenderer::LIGHT2SHADE(owner->Sector->lightlevel + actualextralight, foggy);
int spriteshade = swrenderer::LightVisibility::LightLevelToShade(owner->Sector->lightlevel + actualextralight, foggy);
double minz = double((2048 * 4) / double(1 << 20));
ColormapNum = GETPALOOKUP(swrenderer::LightVisibility::Instance()->SpriteGlobVis(foggy) / minz, spriteshade);

View file

@ -496,7 +496,7 @@ namespace swrenderer
}
else
{
draw_segment->shade = LIGHT2SHADE(mLineSegment->sidedef->GetLightLevel(foggy, mLineSegment->frontsector->lightlevel) + R_ActualExtraLight(foggy), foggy);
draw_segment->shade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mLineSegment->frontsector->lightlevel) + LightVisibility::ActualExtraLight(foggy), foggy);
}
if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr)
@ -781,7 +781,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
{
wallshade = LIGHT2SHADE(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + R_ActualExtraLight(foggy), foggy);
wallshade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + LightVisibility::ActualExtraLight(foggy), foggy);
double GlobVis = LightVisibility::Instance()->WallGlobVis(foggy);
rw_lightleft = float(GlobVis / WallC.sz1);
rw_lightstep = float((GlobVis / WallC.sz2 - rw_lightleft) / (WallC.sx2 - WallC.sx1));
@ -1156,7 +1156,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
else if (cameraLight->FixedColormap() != nullptr)
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
@ -1203,7 +1203,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
else if (cameraLight->FixedColormap() != nullptr)
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
@ -1251,7 +1251,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
else if (cameraLight->FixedColormap() != nullptr)
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);

View file

@ -127,7 +127,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
basecolormap = lit->extra_colormap;
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(ds->foggy), foggy);
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy), foggy);
break;
}
}
@ -159,8 +159,8 @@ namespace swrenderer
if (cameraLight->FixedLightLevel() >= 0)
{
walldrawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
columndrawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
walldrawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
columndrawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
}
else if (cameraLight->FixedColormap() != nullptr)
{
@ -468,7 +468,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap, 0, cameraLight->FixedLightLevelShade());
else if (cameraLight->FixedColormap() != nullptr)
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
@ -704,7 +704,7 @@ namespace swrenderer
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(ds->foggy), foggy);
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy), foggy);
break;
}
}
@ -718,7 +718,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(ds->foggy), foggy);
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy), foggy);
break;
}
}
@ -881,7 +881,7 @@ namespace swrenderer
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(ds->foggy), foggy);
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy), foggy);
break;
}
}
@ -895,7 +895,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = lit->extra_colormap;
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + R_ActualExtraLight(ds->foggy), foggy);
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy), foggy);
break;
}
}

View file

@ -401,7 +401,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
basecolormap = lit->extra_colormap;
wallshade = LIGHT2SHADE(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + R_ActualExtraLight(foggy), foggy);
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + LightVisibility::ActualExtraLight(foggy), foggy);
}
ProcessNormalWall(up, dwal, texturemid, swal, lwal);

View file

@ -125,7 +125,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
{
drawerargs.SetLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight(basecolormap, 0, cameraLight->FixedLightLevelShade());
plane_shade = false;
}
else if (cameraLight->FixedColormap())
@ -136,7 +136,7 @@ namespace swrenderer
else
{
plane_shade = true;
planeshade = LIGHT2SHADE(pl->lightlevel, foggy);
planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy);
}
drawerargs.SetStyle(masked, additive, alpha);

View file

@ -166,7 +166,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
{
drawerargs.SetLight(basecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight(basecolormap, 0, cameraLight->FixedLightLevelShade());
plane_shade = false;
}
else if (cameraLight->FixedColormap())
@ -178,7 +178,7 @@ namespace swrenderer
{
drawerargs.SetLight(basecolormap, 0, 0);
plane_shade = true;
planeshade = LIGHT2SHADE(pl->lightlevel, foggy);
planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy);
}
// Hack in support for 1 x Z and Z x 1 texture sizes

View file

@ -198,7 +198,7 @@ void SWCanvas::FillSimplePoly(DCanvas *canvas, FTexture *tex, FVector2 *points,
FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
{
// Use an equation similar to player sprites to determine shade
fixed_t shade = LIGHT2SHADE(lightlevel, true) - 12 * FRACUNIT;
fixed_t shade = LightVisibility::LightLevelToShade(lightlevel, true) - 12 * FRACUNIT;
float topy, boty, leftx, rightx;
int toppt, botpt, pt1, pt2;
int i;

View file

@ -39,13 +39,6 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
namespace swrenderer
{
fixed_t LIGHT2SHADE(int l, bool foggy)
{
return (!foggy && (glset.nolightfade) ?
((MAX(255 - l, 0) * NUMCOLORMAPS) << (FRACBITS - 8)) :
((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128))));
}
CameraLight *CameraLight::Instance()
{
static CameraLight instance;
@ -155,11 +148,22 @@ namespace swrenderer
TiltVisibility = float(vis * FocalTangent * (16.f * 320.f) / viewwidth);
NoLightFade = glset.nolightfade;
}
// Disable diminishing light
// WallVisibility = 0.0;
// FloorVisibility = 0.0;
// TiltVisibility = 0.0f;
fixed_t LightVisibility::LightLevelToShade(int lightlevel, bool foggy)
{
bool nolightfade = !foggy && (glset.nolightfade);
if (nolightfade)
{
return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8);
}
else
{
// Convert a light level into an unbounded colormap index (shade). Result is
// fixed point. Why the +12? I wish I knew, but experimentation indicates it
// is necessary in order to best reproduce Doom's original lighting.
return (NUMCOLORMAPS * 2 * FRACUNIT) - ((lightlevel + 12) * (FRACUNIT*NUMCOLORMAPS / 128));
}
}
// Controls how quickly light ramps across a 1/z range. Set this, and it

View file

@ -29,19 +29,6 @@
// The size of a single colormap, in bits
#define COLORMAPSHIFT 8
// Convert a light level into an unbounded colormap index (shade). Result is
// fixed point. Why the +12? I wish I knew, but experimentation indicates it
// is necessary in order to best reproduce Doom's original lighting.
//#define LIGHT2SHADE(l) ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128)))
// Disable diminishing light (To do: merge with LIGHT2SHADE and let a cvar control it, maybe by converting this to a function, like R_ActualExtraLight)
//#define LIGHT2SHADE(lightlev) ((MAX(255 - lightlev, 0) * NUMCOLORMAPS) << (FRACBITS - 8))
// combined!
//#define LIGHT2SHADE(l) ((glset.nolightfade)? \
// ((MAX(255 - l, 0) * NUMCOLORMAPS) << (FRACBITS - 8)) : \
// ((NUMCOLORMAPS*2*FRACUNIT)-(((l)+12)*(FRACUNIT*NUMCOLORMAPS/128))))
// MAXLIGHTSCALE from original DOOM, divided by 2.
#define MAXLIGHTVIS (24.0)
@ -55,15 +42,10 @@
// Returns a value between 0 and 1 in fixed point
#define LIGHTSCALE(vis,shade) FLOAT2FIXED(clamp((FIXED2DBL(shade) - (MIN(MAXLIGHTVIS,double(vis)))) / NUMCOLORMAPS, 0.0, (NUMCOLORMAPS-1)/(double)NUMCOLORMAPS))
// Converts fixedlightlev into a shade value
#define FIXEDLIGHT2SHADE(lightlev) (((lightlev) >> COLORMAPSHIFT) << FRACBITS)
struct FSWColormap;
namespace swrenderer
{
fixed_t LIGHT2SHADE(int lightlevel, bool foggy);
class CameraLight
{
public:
@ -73,6 +55,8 @@ namespace swrenderer
FSWColormap *FixedColormap() const { return fixedcolormap; }
FSpecialColormap *ShaderColormap() const { return realfixedcolormap; }
fixed_t FixedLightLevelShade() const { return (FixedLightLevel() >> COLORMAPSHIFT) << FRACBITS; }
void SetCamera(AActor *actor);
void ClearShaderColormap() { realfixedcolormap = nullptr; }
@ -102,6 +86,9 @@ namespace swrenderer
double ParticleVis(double screenZ, bool foggy) const { return ParticleGlobVis(foggy) / screenZ; }
double FlatPlaneVis(int screenY, double planeZ, bool foggy) const { return FlatPlaneGlobVis(foggy) / fabs(planeZ - ViewPos.Z) * fabs(RenderViewport::Instance()->CenterY - screenY); }
static fixed_t LightLevelToShade(int lightlevel, bool foggy);
static int ActualExtraLight(bool fog) { return fog ? 0 : extralight << 4; }
private:
double BaseVisibility = 0.0;
double WallVisibility = 0.0;
@ -123,6 +110,4 @@ namespace swrenderer
void SetColormap(double visibility, int shade, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack);
};
inline int R_ActualExtraLight(bool fog) { return fog ? 0 : extralight << 4; }
}

View file

@ -509,7 +509,7 @@ namespace swrenderer
frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ?
Thread->PlaneList->FindPlane(frontsector->ceilingplane, // killough 3/8/98
frontsector->GetTexture(sector_t::ceiling),
ceilinglightlevel + R_ActualExtraLight(foggy), // killough 4/11/98
ceilinglightlevel + LightVisibility::ActualExtraLight(foggy), // killough 4/11/98
frontsector->GetAlpha(sector_t::ceiling),
!!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE),
frontsector->planes[sector_t::ceiling].xform,
@ -550,7 +550,7 @@ namespace swrenderer
frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ?
Thread->PlaneList->FindPlane(frontsector->floorplane,
frontsector->GetTexture(sector_t::floor),
floorlightlevel + R_ActualExtraLight(foggy), // killough 3/16/98
floorlightlevel + LightVisibility::ActualExtraLight(foggy), // killough 3/16/98
frontsector->GetAlpha(sector_t::floor),
!!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE),
frontsector->planes[sector_t::floor].xform,
@ -616,7 +616,7 @@ namespace swrenderer
ceilingplane = nullptr;
floorplane = Thread->PlaneList->FindPlane(frontsector->floorplane,
frontsector->GetTexture(sector_t::floor),
floorlightlevel + R_ActualExtraLight(foggy), // killough 3/16/98
floorlightlevel + LightVisibility::ActualExtraLight(foggy), // killough 3/16/98
frontsector->GetAlpha(sector_t::floor),
!!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS),
frontsector->planes[position].xform,
@ -682,7 +682,7 @@ namespace swrenderer
floorplane = nullptr;
ceilingplane = Thread->PlaneList->FindPlane(frontsector->ceilingplane, // killough 3/8/98
frontsector->GetTexture(sector_t::ceiling),
ceilinglightlevel + R_ActualExtraLight(foggy), // killough 4/11/98
ceilinglightlevel + LightVisibility::ActualExtraLight(foggy), // killough 4/11/98
frontsector->GetAlpha(sector_t::ceiling),
!!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS),
frontsector->planes[position].xform,
@ -717,7 +717,7 @@ namespace swrenderer
// [RH] Add particles
if ((unsigned int)(sub - subsectors) < (unsigned int)numsubsectors)
{ // Only do it for the main BSP.
int shade = LIGHT2SHADE((floorlightlevel + ceilinglightlevel) / 2 + R_ActualExtraLight(foggy), foggy);
int shade = LightVisibility::LightLevelToShade((floorlightlevel + ceilinglightlevel) / 2 + LightVisibility::ActualExtraLight(foggy), foggy);
for (WORD i = ParticlesInSubsec[(unsigned int)(sub - subsectors)]; i != NO_PARTICLE; i = Particles[i].snext)
{
RenderParticle::Project(Thread, Particles + i, subsectors[sub - subsectors].sector, shade, FakeSide, foggy);
@ -834,7 +834,7 @@ namespace swrenderer
//sec->validcount = validcount;
SeenSpriteSectors.insert(sec);
int spriteshade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy), foggy);
int spriteshade = LightVisibility::LightLevelToShade(lightlevel + LightVisibility::ActualExtraLight(foggy), foggy);
// Handle all things in sector.
for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext)
@ -886,7 +886,7 @@ namespace swrenderer
if (sec->sectornum != thing->Sector->sectornum) // compare sectornums to account for R_FakeFlat copies.
{
int lightlevel = thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
thingShade = LIGHT2SHADE(lightlevel + R_ActualExtraLight(foggy), foggy);
thingShade = LightVisibility::LightLevelToShade(lightlevel + LightVisibility::ActualExtraLight(foggy), foggy);
thingColormap = thing->Sector->ColorMap;
}

View file

@ -279,7 +279,7 @@ namespace swrenderer
SpriteDrawerArgs drawerargs;
if (cameraLight->FixedLightLevel() >= 0)
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight((r_fullbrightignoresectorcolor) ? &FullNormalLight : usecolormap, 0, cameraLight->FixedLightLevelShade());
else if (cameraLight->FixedColormap() != NULL)
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
else if (!foggy && (decal->RenderFlags & RF_FULLBRIGHT))

View file

@ -130,8 +130,8 @@ namespace swrenderer
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
// get light level
lightnum = ((floorlight + ceilinglight) >> 1) + R_ActualExtraLight(foggy);
int spriteshade = LIGHT2SHADE(lightnum, foggy) - 24 * FRACUNIT;
lightnum = ((floorlight + ceilinglight) >> 1) + LightVisibility::ActualExtraLight(foggy);
int spriteshade = LightVisibility::LightLevelToShade(lightnum, foggy) - 24 * FRACUNIT;
if (camera->player != NULL)
{

View file

@ -138,7 +138,7 @@ namespace swrenderer
bool isFullBright = !foggy && (renderflags & RF_FULLBRIGHT);
bool fadeToBlack = spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0;
int spriteshade = LIGHT2SHADE(sec->lightlevel + R_ActualExtraLight(spr->foggy), foggy);
int spriteshade = LightVisibility::LightLevelToShade(sec->lightlevel + LightVisibility::ActualExtraLight(spr->foggy), foggy);
Light.SetColormap(LightVisibility::Instance()->SpriteGlobVis(foggy) / MAX(MINZ, (double)spr->depth), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
}

View file

@ -182,14 +182,14 @@ namespace swrenderer
SpriteDrawerArgs drawerargs;
int shade = LIGHT2SHADE(spr->sector->lightlevel + R_ActualExtraLight(spr->foggy), spr->foggy);
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel + LightVisibility::ActualExtraLight(spr->foggy), spr->foggy);
double GlobVis = LightVisibility::Instance()->WallGlobVis(foggy);
float lightleft = float(GlobVis / spr->wallc.sz1);
float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
drawerargs.SetLight(usecolormap, 0, FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel()));
drawerargs.SetLight(usecolormap, 0, cameraLight->FixedLightLevelShade());
else if (cameraLight->FixedColormap() != NULL)
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
else if (!spr->foggy && (spr->renderflags & RF_FULLBRIGHT))

View file

@ -445,7 +445,7 @@ namespace swrenderer
if (cameraLight->FixedLightLevel() >= 0 && !cameraLight->FixedColormap())
{
fixed_t shade = shadedlightshade;
if (shade == 0) FIXEDLIGHT2SHADE(cameraLight->FixedLightLevel());
if (shade == 0) shade = cameraLight->FixedLightLevelShade();
SetLight(basecolormap, 0, shade);
}
else

View file

@ -3130,7 +3130,7 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints,
DAngle rotation, FDynamicColormap *colormap, PalEntry flatcolor, int lightlevel, int bottomclip)
{
// Use an equation similar to player sprites to determine shade
double fadelevel = clamp((swrenderer::LIGHT2SHADE(lightlevel, true)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
double fadelevel = clamp((swrenderer::LightVisibility::LightLevelToShade(lightlevel, true)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0);
BufferedTris *quad;
FBVERTEX *verts;