Skip to content

Commit

Permalink
Fix broken fixed camera light for walls
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Jan 17, 2020
1 parent 1f011cd commit 3b336a1
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 27 deletions.
12 changes: 8 additions & 4 deletions src/rendering/swrenderer/drawers/r_draw.cpp
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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
Expand Down
28 changes: 24 additions & 4 deletions src/rendering/swrenderer/line/r_walldraw.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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, 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.SetStyle(mask, additive, alpha, mLight.GetBaseColormap(), light_list);
drawerargs.SetBaseColormap(mLight.GetBaseColormap());
drawerargs.SetLight(0.0f, mLight.GetLightLevel(), mLight.GetFoggy(), viewport);
drawerargs.fixedlight = false;
}

int count = x2 - x1;
Expand All @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 3 additions & 0 deletions src/rendering/swrenderer/viewport/r_drawerargs.h
Expand Up @@ -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);

Expand Down
18 changes: 1 addition & 17 deletions src/rendering/swrenderer/viewport/r_walldrawer.cpp
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
}
}
}
3 changes: 1 addition & 2 deletions src/rendering/swrenderer/viewport/r_walldrawer.h
Expand Up @@ -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);

Expand All @@ -35,7 +35,6 @@ namespace swrenderer

float lightpos;
float lightstep;
int mShade;

int texwidth;
int texheight;
Expand Down

0 comments on commit 3b336a1

Please sign in to comment.