- 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
parent 66b5e6e2ee
commit 2ce91ea62f
22 changed files with 57 additions and 55 deletions

View file

@ -54,12 +54,13 @@
namespace swrenderer namespace swrenderer
{ {
void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap) void RenderFogBoundary::Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int lightlevel, bool foggy, float lightleft, float lightstep, FDynamicColormap *basecolormap)
{ {
// This is essentially the same as R_MapVisPlane but with an extra step // This is essentially the same as R_MapVisPlane but with an extra step
// to create new horizontal spans whenever the light changes enough that // to create new horizontal spans whenever the light changes enough that
// we need to use a new colormap. // we need to use a new colormap.
int wallshade = LightVisibility::LightLevelToShade(lightlevel, foggy, thread->Viewport.get());
float light = lightleft + lightstep*(x2 - x1 - 1); float light = lightleft + lightstep*(x2 - x1 - 1);
int x = x2 - 1; int x = x2 - 1;
int t2 = uclip[x]; int t2 = uclip[x];
@ -73,7 +74,7 @@ namespace swrenderer
fillshort(spanend + t2, b2 - t2, x); fillshort(spanend + t2, b2 - t2, x);
} }
drawerargs.SetLight(basecolormap, (float)light, wallshade); drawerargs.SetLight(basecolormap, (float)light, lightlevel, foggy, thread->Viewport.get());
uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT); uint8_t *fake_dc_colormap = basecolormap->Maps + (GETPALOOKUP(light, wallshade) << COLORMAPSHIFT);

View file

@ -31,7 +31,7 @@ namespace swrenderer
class RenderFogBoundary class RenderFogBoundary
{ {
public: public:
void Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int wallshade, float lightleft, float lightstep, FDynamicColormap *basecolormap); void Render(RenderThread *thread, int x1, int x2, const short *uclip, const short *dclip, int lightlevel, bool foggy, float lightleft, float lightstep, FDynamicColormap *basecolormap);
private: private:
void RenderSection(RenderThread *thread, int y, int y2, int x1); void RenderSection(RenderThread *thread, int y, int y2, int x1);

View file

@ -129,7 +129,7 @@ namespace swrenderer
const short *mceilingclip = ds->sprtopclip - ds->x1; const short *mceilingclip = ds->sprtopclip - ds->x1;
RenderFogBoundary renderfog; RenderFogBoundary renderfog;
renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, LightVisibility::LightLevelToShade(lightlevel, ds->foggy, Thread->Viewport.get()), rw_light, rw_lightstep, basecolormap); renderfog.Render(Thread, x1, x2, mceilingclip, mfloorclip, lightlevel, ds->foggy, rw_light, rw_lightstep, basecolormap);
if (ds->maskedtexturecol == nullptr) if (ds->maskedtexturecol == nullptr)
renderwall = false; renderwall = false;

View file

@ -153,7 +153,7 @@ namespace swrenderer
else else
{ {
plane_shade = true; plane_shade = true;
planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy, viewport); lightlevel = pl->lightlevel;
} }
drawerargs.SetStyle(masked, additive, alpha); drawerargs.SetStyle(masked, additive, alpha);
@ -200,7 +200,7 @@ namespace swrenderer
if (plane_shade) if (plane_shade)
{ {
// Determine lighting based on the span's distance from the viewer. // Determine lighting based on the span's distance from the viewer.
drawerargs.SetLight(basecolormap, (float)Thread->Light->FlatPlaneVis(y, planeheight, foggy, viewport), planeshade); drawerargs.SetLight(basecolormap, (float)Thread->Light->FlatPlaneVis(y, planeheight, foggy, viewport), lightlevel, foggy, viewport);
} }
if (r_dynlights) if (r_dynlights)

View file

@ -44,7 +44,7 @@ namespace swrenderer
int minx; int minx;
double planeheight; double planeheight;
bool plane_shade; bool plane_shade;
int planeshade; int lightlevel;
bool foggy; bool foggy;
FDynamicColormap *basecolormap; FDynamicColormap *basecolormap;
double pviewx, pviewy; double pviewx, pviewy;

View file

@ -174,7 +174,7 @@ namespace swrenderer
// [RH] set foggy flag // [RH] set foggy flag
basecolormap = colormap; basecolormap = colormap;
bool foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);; foggy = level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE);;
planelightfloat = (Thread->Light->SlopePlaneGlobVis(foggy) * lxscale * lyscale) / (fabs(pl->height.ZatPoint(Thread->Viewport->viewpoint.Pos) - Thread->Viewport->viewpoint.Pos.Z)) / 65536.f; planelightfloat = (Thread->Light->SlopePlaneGlobVis(foggy) * lxscale * lyscale) / (fabs(pl->height.ZatPoint(Thread->Viewport->viewpoint.Pos) - Thread->Viewport->viewpoint.Pos.Z)) / 65536.f;
@ -197,7 +197,7 @@ namespace swrenderer
{ {
drawerargs.SetLight(basecolormap, 0, 0); drawerargs.SetLight(basecolormap, 0, 0);
plane_shade = true; plane_shade = true;
planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy, viewport); lightlevel = pl->lightlevel;
} }
// Hack in support for 1 x Z and Z x 1 texture sizes // Hack in support for 1 x Z and Z x 1 texture sizes
@ -215,7 +215,7 @@ namespace swrenderer
void RenderSlopePlane::RenderLine(int y, int x1, int x2) void RenderSlopePlane::RenderLine(int y, int x1, int x2)
{ {
drawerargs.DrawTiltedSpan(Thread, y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap); drawerargs.DrawTiltedSpan(Thread, y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, lightlevel, foggy, planelightfloat, pviewx, pviewy, basecolormap);
if (r_modelscene) if (r_modelscene)
{ {

View file

@ -43,7 +43,8 @@ namespace swrenderer
FVector3 plane_sz, plane_su, plane_sv; FVector3 plane_sz, plane_su, plane_sv;
float planelightfloat; float planelightfloat;
bool plane_shade; bool plane_shade;
int planeshade; int lightlevel;
bool foggy;
fixed_t pviewx, pviewy; fixed_t pviewx, pviewy;
fixed_t xscale, yscale; fixed_t xscale, yscale;
FDynamicColormap *basecolormap; FDynamicColormap *basecolormap;

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) if (fadeToBlack)
{ {
@ -181,16 +181,16 @@ namespace swrenderer
} }
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedColormap()) if (cameraLight->FixedLightLevel() >= 0)
{
BaseColormap = cameraLight->FixedColormap();
ColormapNum = 0;
}
else if (cameraLight->FixedLightLevel() >= 0)
{ {
BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap; BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap;
ColormapNum = cameraLight->FixedLightLevel() >> COLORMAPSHIFT; ColormapNum = cameraLight->FixedLightLevel() >> COLORMAPSHIFT;
} }
else if (cameraLight->FixedColormap())
{
BaseColormap = cameraLight->FixedColormap();
ColormapNum = 0;
}
else if (fullbright) else if (fullbright)
{ {
BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap; BaseColormap = (r_fullbrightignoresectorcolor) ? &FullNormalLight : basecolormap;
@ -198,6 +198,14 @@ namespace swrenderer
} }
else 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; BaseColormap = basecolormap;
ColormapNum = GETPALOOKUP(visibility, shade); ColormapNum = GETPALOOKUP(visibility, shade);
} }

View file

@ -83,7 +83,6 @@ namespace swrenderer
// The vis value to pass into the GETPALOOKUP or LIGHTSCALE macros // The vis value to pass into the GETPALOOKUP or LIGHTSCALE macros
double WallVis(double screenZ, bool foggy) const { return WallGlobVis(foggy) / screenZ; } double WallVis(double screenZ, bool foggy) const { return WallGlobVis(foggy) / screenZ; }
double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / MAX(screenZ, MINZ); } double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / MAX(screenZ, MINZ); }
double ParticleVis(double screenZ, bool foggy) const { return ParticleGlobVis(foggy) / screenZ; }
double FlatPlaneVis(int screenY, double planeheight, bool foggy, RenderViewport *viewport) const { return FlatPlaneGlobVis(foggy) / planeheight * fabs(viewport->CenterY - screenY); } double FlatPlaneVis(int screenY, double planeheight, bool foggy, RenderViewport *viewport) const { return FlatPlaneGlobVis(foggy) / planeheight * fabs(viewport->CenterY - screenY); }
double SlopePlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : TiltVisibility; } double SlopePlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : TiltVisibility; }
@ -95,7 +94,6 @@ namespace swrenderer
private: private:
double WallGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : WallVisibility; } double WallGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : WallVisibility; }
double SpriteGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : WallVisibility; } double SpriteGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : WallVisibility; }
double ParticleGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : (WallVisibility * 0.5); }
double FlatPlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : FloorVisibility; } double FlatPlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : FloorVisibility; }
static fixed_t LightLevelToShadeImpl(int lightlevel, bool foggy); static fixed_t LightLevelToShadeImpl(int lightlevel, bool foggy);
@ -118,6 +116,6 @@ namespace swrenderer
int ColormapNum = 0; int ColormapNum = 0;
FSWColormap *BaseColormap = nullptr; FSWColormap *BaseColormap = nullptr;
void SetColormap(double visibility, int shade, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack); void SetColormap(RenderThread *thread, double z, int lightlevel, bool foggy, FDynamicColormap *basecolormap, bool fullbright, bool invertColormap, bool fadeToBlack, bool psprite, bool particle);
}; };
} }

View file

@ -613,10 +613,10 @@ namespace swrenderer
// [RH] Add particles // [RH] Add particles
if ((unsigned int)(sub->Index()) < level.subsectors.Size()) if ((unsigned int)(sub->Index()) < level.subsectors.Size())
{ // Only do it for the main BSP. { // Only do it for the main BSP.
int shade = LightVisibility::LightLevelToShade((floorlightlevel + ceilinglightlevel) / 2, foggy, Thread->Viewport.get()); int lightlevel = (floorlightlevel + ceilinglightlevel) / 2;
for (int i = ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Particles[i].snext) for (int i = ParticlesInSubsec[sub->Index()]; i != NO_PARTICLE; i = Particles[i].snext)
{ {
RenderParticle::Project(Thread, &Particles[i], sub->sector, shade, FakeSide, foggy); RenderParticle::Project(Thread, &Particles[i], sub->sector, lightlevel, FakeSide, foggy);
} }
} }
@ -891,8 +891,6 @@ namespace swrenderer
//sec->validcount = validcount; //sec->validcount = validcount;
SeenSpriteSectors.insert(sec); SeenSpriteSectors.insert(sec);
int spriteshade = LightVisibility::LightLevelToShade(lightlevel, foggy, Thread->Viewport.get());
// Handle all things in sector. // Handle all things in sector.
for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext) for (auto p = sec->touching_renderthings; p != nullptr; p = p->m_snext)
{ {
@ -947,25 +945,24 @@ namespace swrenderer
else if (GetThingSprite(thing, sprite)) else if (GetThingSprite(thing, sprite))
{ {
FDynamicColormap *thingColormap = basecolormap; FDynamicColormap *thingColormap = basecolormap;
int thingShade = spriteshade; int thinglightlevel = lightlevel;
if (sec->sectornum != thing->Sector->sectornum) // compare sectornums to account for R_FakeFlat copies. 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(); thinglightlevel = thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
thingShade = LightVisibility::LightLevelToShade(lightlevel, foggy, Thread->Viewport.get());
thingColormap = GetColorTable(thing->Sector->Colormap, thing->Sector->SpecialColors[sector_t::sprites], true); thingColormap = GetColorTable(thing->Sector->Colormap, thing->Sector->SpecialColors[sector_t::sprites], true);
} }
if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE)
{ {
RenderWallSprite::Project(Thread, thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, thingShade, foggy, thingColormap); RenderWallSprite::Project(Thread, thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, thinglightlevel, foggy, thingColormap);
} }
else if (sprite.voxel) else if (sprite.voxel)
{ {
RenderVoxel::Project(Thread, thing, sprite.pos, sprite.voxel, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, thingShade, foggy, thingColormap); RenderVoxel::Project(Thread, thing, sprite.pos, sprite.voxel, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, thinglightlevel, foggy, thingColormap);
} }
else else
{ {
RenderSprite::Project(Thread, thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, thingShade, foggy, thingColormap); RenderSprite::Project(Thread, thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, fakeside, fakefloor, fakeceiling, sec, thinglightlevel, foggy, thingColormap);
} }
} }
} }

View file

@ -69,7 +69,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void RenderParticle::Project(RenderThread *thread, particle_t *particle, const sector_t *sector, int shade, WaterFakeSide fakeside, bool foggy) void RenderParticle::Project(RenderThread *thread, particle_t *particle, const sector_t *sector, int lightlevel, WaterFakeSide fakeside, bool foggy)
{ {
double tr_x, tr_y; double tr_x, tr_y;
double tx, ty; double tx, ty;
@ -220,7 +220,7 @@ namespace swrenderer
vis->floorclip = 0; vis->floorclip = 0;
vis->foggy = foggy; vis->foggy = foggy;
vis->Light.SetColormap(thread->Light->ParticleVis(tz, foggy), shade, map, particle->bright != 0, false, false); vis->Light.SetColormap(thread, tz, lightlevel, foggy, map, particle->bright != 0, false, false, false, true);
thread->SpriteList->Push(vis); thread->SpriteList->Push(vis);
} }

View file

@ -137,7 +137,7 @@ namespace swrenderer
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
// get light level // get light level
int spriteshade = LightVisibility::LightLevelToShade((floorlight + ceilinglight) >> 1, foggy, Thread->Viewport.get()) - 24 * FRACUNIT; int lightlevel = (floorlight + ceilinglight) >> 1;
if (Thread->Viewport->viewpoint.camera->player != NULL) if (Thread->Viewport->viewpoint.camera->player != NULL)
{ {
@ -182,7 +182,7 @@ namespace swrenderer
if ((psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && psp->GetCaller() != nullptr) if ((psp->GetID() != PSP_TARGETCENTER || CrosshairImage == nullptr) && psp->GetCaller() != nullptr)
{ {
RenderSprite(psp, viewport->viewpoint.camera, bobx, boby, wx, wy, viewport->viewpoint.TicFrac, spriteshade, basecolormap, foggy); RenderSprite(psp, viewport->viewpoint.camera, bobx, boby, wx, wy, viewport->viewpoint.TicFrac, lightlevel, basecolormap, foggy);
} }
psp = psp->GetNext(); psp = psp->GetNext();
@ -192,7 +192,7 @@ namespace swrenderer
} }
} }
void RenderPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int spriteshade, FDynamicColormap *basecolormap, bool foggy) void RenderPlayerSprites::RenderSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int lightlevel, FDynamicColormap *basecolormap, bool foggy)
{ {
double tx; double tx;
int x1; int x1;
@ -350,7 +350,7 @@ namespace swrenderer
bool fullbright = !foggy && (psprState == nullptr ? false : psprState->GetFullbright()); bool fullbright = !foggy && (psprState == nullptr ? false : psprState->GetFullbright());
bool fadeToBlack = (vis.RenderStyle.Flags & STYLEF_FadeToBlack) != 0; bool fadeToBlack = (vis.RenderStyle.Flags & STYLEF_FadeToBlack) != 0;
vis.Light.SetColormap(0, spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack); vis.Light.SetColormap(Thread, MINZ, lightlevel, foggy, basecolormap, fullbright, invertcolormap, fadeToBlack, true, false);
colormap_to_use = (FDynamicColormap*)vis.Light.BaseColormap; colormap_to_use = (FDynamicColormap*)vis.Light.BaseColormap;

View file

@ -90,7 +90,7 @@ namespace swrenderer
RenderThread *Thread = nullptr; RenderThread *Thread = nullptr;
private: private:
void RenderSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int spriteshade, FDynamicColormap *basecolormap, bool foggy); void RenderSprite(DPSprite *pspr, AActor *owner, float bobx, float boby, double wx, double wy, double ticfrac, int lightlevel, FDynamicColormap *basecolormap, bool foggy);
enum { BASEXCENTER = 160 }; enum { BASEXCENTER = 160 };
enum { BASEYCENTER = 100 }; enum { BASEYCENTER = 100 };

View file

@ -72,7 +72,7 @@ EXTERN_CVAR(Bool, gl_light_sprites)
namespace swrenderer namespace swrenderer
{ {
void RenderSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ttex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap) void RenderSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ttex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int lightlevel, bool foggy, FDynamicColormap *basecolormap)
{ {
FSoftwareTexture *tex = ttex->GetSoftwareTexture(); FSoftwareTexture *tex = ttex->GetSoftwareTexture();
// transform the origin point // transform the origin point
@ -300,7 +300,7 @@ namespace swrenderer
vis->dynlightcolor = 0; vis->dynlightcolor = 0;
} }
vis->Light.SetColormap(thread->Light->SpriteVis(tz, foggy), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack); vis->Light.SetColormap(thread, tz, lightlevel, foggy, basecolormap, fullbright, invertcolormap, fadeToBlack, false, false);
thread->SpriteList->Push(vis); thread->SpriteList->Push(vis);
} }

View file

@ -7,7 +7,7 @@ namespace swrenderer
class RenderSprite : public VisibleSprite class RenderSprite : public VisibleSprite
{ {
public: public:
static void Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *tex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap); static void Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *tex, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int lightlevel, bool foggy, FDynamicColormap *basecolormap);
protected: protected:
void Render(RenderThread *thread, short *cliptop, short *clipbottom, int minZ, int maxZ, Fake3DTranslucent clip3DFloor) override; void Render(RenderThread *thread, short *cliptop, short *clipbottom, int minZ, int maxZ, Fake3DTranslucent clip3DFloor) override;

View file

@ -163,9 +163,7 @@ namespace swrenderer
bool isFullBright = !foggy && (renderflags & RF_FULLBRIGHT); bool isFullBright = !foggy && (renderflags & RF_FULLBRIGHT);
bool fadeToBlack = spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0; bool fadeToBlack = spr->RenderStyle == LegacyRenderStyles[STYLE_Add] && mybasecolormap->Fade != 0;
int spriteshade = LightVisibility::LightLevelToShade(sec->lightlevel, foggy, thread->Viewport.get()); Light.SetColormap(thread, spr->depth, sec->lightlevel, foggy, mybasecolormap, isFullBright, invertcolormap, fadeToBlack, false, false);
Light.SetColormap(thread->Light->SpriteVis(spr->depth, foggy), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
} }
} }

View file

@ -60,7 +60,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor)
namespace swrenderer namespace swrenderer
{ {
void RenderVoxel::Project(RenderThread *thread, AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap) void RenderVoxel::Project(RenderThread *thread, AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int lightlevel, bool foggy, FDynamicColormap *basecolormap)
{ {
// transform the origin point // transform the origin point
double tr_x = pos.X - thread->Viewport->viewpoint.Pos.X; double tr_x = pos.X - thread->Viewport->viewpoint.Pos.X;
@ -188,7 +188,7 @@ namespace swrenderer
bool fullbright = !vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); bool fullbright = !vis->foggy && ((renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT));
bool fadeToBlack = (vis->RenderStyle.Flags & STYLEF_FadeToBlack) != 0; bool fadeToBlack = (vis->RenderStyle.Flags & STYLEF_FadeToBlack) != 0;
vis->Light.SetColormap(thread->Light->SpriteVis(tz, foggy), spriteshade, basecolormap, fullbright, invertcolormap, fadeToBlack); vis->Light.SetColormap(thread, tz, lightlevel, foggy, basecolormap, fullbright, invertcolormap, fadeToBlack, false, false);
// Fake a voxel drawing to find its extents.. // Fake a voxel drawing to find its extents..
SpriteDrawerArgs drawerargs; SpriteDrawerArgs drawerargs;

View file

@ -58,7 +58,7 @@ namespace swrenderer
class RenderVoxel : public VisibleSprite class RenderVoxel : public VisibleSprite
{ {
public: public:
static void Project(RenderThread *thread, AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int spriteshade, bool foggy, FDynamicColormap *basecolormap); static void Project(RenderThread *thread, AActor *thing, DVector3 pos, FVoxelDef *voxel, const DVector2 &spriteScale, int renderflags, WaterFakeSide fakeside, F3DFloor *fakefloor, F3DFloor *fakeceiling, sector_t *current_sector, int lightlevel, bool foggy, FDynamicColormap *basecolormap);
static void Deinit(); static void Deinit();

View file

@ -71,7 +71,7 @@ EXTERN_CVAR(Bool, r_fullbrightignoresectorcolor);
namespace swrenderer namespace swrenderer
{ {
void RenderWallSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ppic, const DVector2 &scale, int renderflags, int spriteshade, bool foggy, FDynamicColormap *basecolormap) void RenderWallSprite::Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *ppic, const DVector2 &scale, int renderflags, int lightlevel, bool foggy, FDynamicColormap *basecolormap)
{ {
FSoftwareTexture *pic = ppic->GetSoftwareTexture(); FSoftwareTexture *pic = ppic->GetSoftwareTexture();
FWallCoords wallc; FWallCoords wallc;
@ -141,7 +141,7 @@ namespace swrenderer
vis->wallc = wallc; vis->wallc = wallc;
vis->foggy = foggy; vis->foggy = foggy;
vis->Light.SetColormap(thread->Light->SpriteVis(tz, foggy), spriteshade, basecolormap, false, false, false); vis->Light.SetColormap(thread, tz, lightlevel, foggy, basecolormap, false, false, false, false, false);
thread->SpriteList->Push(vis); thread->SpriteList->Push(vis);
} }
@ -190,7 +190,6 @@ namespace swrenderer
SpriteDrawerArgs drawerargs; SpriteDrawerArgs drawerargs;
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel, spr->foggy, thread->Viewport.get());
float lightleft = float(thread->Light->WallVis(spr->wallc.sz1, foggy)); float lightleft = float(thread->Light->WallVis(spr->wallc.sz1, foggy));
float lightstep = float((thread->Light->WallVis(spr->wallc.sz2, foggy) - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1)); float lightstep = float((thread->Light->WallVis(spr->wallc.sz2, foggy) - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep; float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
@ -244,7 +243,7 @@ namespace swrenderer
{ {
if (calclighting) if (calclighting)
{ // calculate lighting { // calculate lighting
drawerargs.SetLight(usecolormap, light, shade); drawerargs.SetLight(usecolormap, light, spr->sector->lightlevel, spr->foggy, thread->Viewport.get());
} }
if (!translucentPass->ClipSpriteColumnWithPortals(x, spr)) if (!translucentPass->ClipSpriteColumnWithPortals(x, spr))
DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, spr->RenderStyle); DrawColumn(thread, drawerargs, x, WallSpriteTile, walltexcoords, texturemid, maskedScaleY, sprflipvert, mfloorclip, mceilingclip, spr->RenderStyle);

View file

@ -10,7 +10,7 @@ namespace swrenderer
class RenderWallSprite : public VisibleSprite class RenderWallSprite : public VisibleSprite
{ {
public: public:
static void Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *pic, const DVector2 &scale, int renderflags, int spriteshade, bool foggy, FDynamicColormap *basecolormap); static void Project(RenderThread *thread, AActor *thing, const DVector3 &pos, FTexture *pic, const DVector2 &scale, int renderflags, int lightlevel, bool foggy, FDynamicColormap *basecolormap);
protected: protected:
bool IsWallSprite() const override { return true; } bool IsWallSprite() const override { return true; }

View file

@ -117,12 +117,12 @@ namespace swrenderer
(thread->Drawers(ds_viewport)->*spanfunc)(*this); (thread->Drawers(ds_viewport)->*spanfunc)(*this);
} }
void SpanDrawerArgs::DrawTiltedSpan(RenderThread *thread, int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap) void SpanDrawerArgs::DrawTiltedSpan(RenderThread *thread, int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int lightlevel, bool foggy, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap)
{ {
SetDestY(thread->Viewport.get(), y); SetDestY(thread->Viewport.get(), y);
SetDestX1(x1); SetDestX1(x1);
SetDestX2(x2); SetDestX2(x2);
thread->Drawers(ds_viewport)->DrawTiltedSpan(*this, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy, basecolormap); thread->Drawers(ds_viewport)->DrawTiltedSpan(*this, plane_sz, plane_su, plane_sv, plane_shade, LightVisibility::LightLevelToShade(lightlevel, foggy, thread->Viewport.get()), planelightfloat, pviewx, pviewy, basecolormap);
} }
void SpanDrawerArgs::DrawFogBoundaryLine(RenderThread *thread, int y, int x1, int x2) void SpanDrawerArgs::DrawFogBoundaryLine(RenderThread *thread, int y, int x1, int x2)

View file

@ -29,7 +29,7 @@ namespace swrenderer
void DrawDepthSpan(RenderThread *thread, float idepth1, float idepth2); void DrawDepthSpan(RenderThread *thread, float idepth1, float idepth2);
void DrawSpan(RenderThread *thread); void DrawSpan(RenderThread *thread);
void DrawTiltedSpan(RenderThread *thread, int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int planeshade, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap); void DrawTiltedSpan(RenderThread *thread, int y, int x1, int x2, const FVector3 &plane_sz, const FVector3 &plane_su, const FVector3 &plane_sv, bool plane_shade, int lightlevel, bool foggy, float planelightfloat, fixed_t pviewx, fixed_t pviewy, FDynamicColormap *basecolormap);
void DrawColoredSpan(RenderThread *thread, int y, int x1, int x2); void DrawColoredSpan(RenderThread *thread, int y, int x1, int x2);
void DrawFogBoundaryLine(RenderThread *thread, int y, int x1, int x2); void DrawFogBoundaryLine(RenderThread *thread, int y, int x1, int x2);