Fix broken fixed camera light for walls

This commit is contained in:
Magnus Norddahl 2020-01-17 01:15:44 +01:00
parent 1f011cda7f
commit 3b336a1476
5 changed files with 37 additions and 27 deletions

View file

@ -232,8 +232,6 @@ namespace swrenderer
WallColumnDrawerArgs& drawerargs = *thread->columndrawer.get();
drawerargs.wallargs = &wallargs;
bool fixed = wallargs.fixedlight;
bool haslights = r_dynlights && wallargs.lightlist;
if (haslights)
{
@ -249,7 +247,13 @@ namespace swrenderer
float curlight = wallargs.lightpos;
float lightstep = wallargs.lightstep;
int shade = wallargs.mShade;
int shade = wallargs.Shade();
if (wallargs.fixedlight)
{
curlight = wallargs.FixedLight();
lightstep = 0;
}
float upos = wallargs.texcoords.upos, ustepX = wallargs.texcoords.ustepX, ustepY = wallargs.texcoords.ustepY;
float vpos = wallargs.texcoords.vpos, vstepX = wallargs.texcoords.vstepX, vstepY = wallargs.texcoords.vstepY;
@ -274,7 +278,7 @@ namespace swrenderer
int y2 = dwal[x];
if (y2 > y1)
{
if (!fixed) drawerargs.SetLight(curlight, shade);
drawerargs.SetLight(curlight, shade);
if (haslights)
SetLights(drawerargs, x, y1);
else

View file

@ -52,6 +52,8 @@
#include "swrenderer/r_renderthread.h"
#include "swrenderer/r_memory.h"
EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
namespace swrenderer
{
RenderWallPart::RenderWallPart(RenderThread* thread)
@ -130,11 +132,30 @@ namespace swrenderer
// Textures that aren't masked can use the faster opaque drawer
if (!pic->GetTexture()->isMasked() && mask && alpha >= OPAQUE && !additive)
{
drawerargs.SetStyle(true, false, OPAQUE, mLight.GetBaseColormap(), light_list);
drawerargs.SetStyle(true, false, OPAQUE, light_list);
}
else
{
drawerargs.SetStyle(mask, additive, alpha, mLight.GetBaseColormap(), light_list);
drawerargs.SetStyle(mask, additive, alpha, light_list);
}
if (cameraLight->FixedLightLevel() >= 0)
{
drawerargs.SetBaseColormap((r_fullbrightignoresectorcolor) ? &FullNormalLight : mLight.GetBaseColormap());
drawerargs.SetLight(0.0f, cameraLight->FixedLightLevelShade());
drawerargs.fixedlight = true;
}
else if (cameraLight->FixedColormap())
{
drawerargs.SetBaseColormap(cameraLight->FixedColormap());
drawerargs.SetLight(0.0f, 0);
drawerargs.fixedlight = true;
}
else
{
drawerargs.SetBaseColormap(mLight.GetBaseColormap());
drawerargs.SetLight(0.0f, mLight.GetLightLevel(), mLight.GetFoggy(), viewport);
drawerargs.fixedlight = false;
}
int count = x2 - x1;
@ -151,7 +172,7 @@ namespace swrenderer
drawerargs.lightpos = mLight.GetLightPos(x1);
drawerargs.lightstep = mLight.GetLightStep();
drawerargs.mShade = LightVisibility::LightLevelToShade(mLight.GetLightLevel(), mLight.GetFoggy(), viewport);
drawerargs.lightlist = light_list;
drawerargs.texwidth = pic->GetPhysicalWidth();
@ -183,7 +204,6 @@ namespace swrenderer
drawerargs.TanCos = Thread->Viewport->viewpoint.TanCos;
drawerargs.TanSin = Thread->Viewport->viewpoint.TanSin;
drawerargs.PortalMirrorFlags = Thread->Portal->MirrorFlags;
drawerargs.fixedlight = (cameraLight->FixedColormap() || cameraLight->FixedLightLevel() >= 0);
drawerargs.DrawWall(Thread);
}

View file

@ -43,6 +43,9 @@ namespace swrenderer
ShadeConstants ColormapConstants() const;
fixed_t Light() const { return LIGHTSCALE(mLight, mShade); }
float FixedLight() const { return mLight; }
int Shade() const { return mShade; }
protected:
void SetLight(const ColormapLight &light);

View file

@ -35,7 +35,7 @@ namespace swrenderer
(thread->Drawers(dc_viewport)->*wallfunc)(*this);
}
void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha, FDynamicColormap *basecolormap, bool dynlights)
void WallDrawerArgs::SetStyle(bool masked, bool additive, fixed_t alpha, bool dynlights)
{
if (alpha < OPAQUE || additive)
{
@ -72,21 +72,5 @@ namespace swrenderer
{
wallfunc = &SWPixelFormatDrawers::DrawWall;
}
CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0)
{
SetBaseColormap((r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap);
SetLight(0.0f, cameraLight->FixedLightLevelShade());
}
else if (cameraLight->FixedColormap() != nullptr)
{
SetBaseColormap(cameraLight->FixedColormap());
SetLight(0.0f, 0);
}
else
{
SetBaseColormap(basecolormap);
}
}
}

View file

@ -15,7 +15,7 @@ namespace swrenderer
class WallDrawerArgs : public DrawerArgs
{
public:
void SetStyle(bool masked, bool additive, fixed_t alpha, FDynamicColormap *basecolormap, bool dynlights);
void SetStyle(bool masked, bool additive, fixed_t alpha, bool dynlights);
void SetDest(RenderViewport *viewport);
void DrawWall(RenderThread *thread);
@ -35,7 +35,6 @@ namespace swrenderer
float lightpos;
float lightstep;
int mShade;
int texwidth;
int texheight;