- fix heretic light torch in software renderer and remove some code duplication

This commit is contained in:
Magnus Norddahl 2018-12-17 06:13:00 +01:00
parent f35aeec6c3
commit 946f657a37
13 changed files with 41 additions and 36 deletions

View file

@ -503,7 +503,7 @@ namespace swrenderer
} }
else else
{ {
draw_segment->shade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mLineSegment->frontsector->lightlevel) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy); draw_segment->shade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mLineSegment->frontsector->lightlevel), foggy, Thread->Viewport.get());
} }
if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr) if (draw_segment->bFogBoundary || draw_segment->maskedtexturecol != nullptr)
@ -789,7 +789,7 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0) if (cameraLight->FixedColormap() == nullptr && cameraLight->FixedLightLevel() < 0)
{ {
wallshade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy); wallshade = LightVisibility::LightLevelToShade(mLineSegment->sidedef->GetLightLevel(foggy, mFrontSector->lightlevel), foggy, Thread->Viewport.get());
rw_lightleft = float(Thread->Light->WallVis(WallC.sz1, foggy)); rw_lightleft = float(Thread->Light->WallVis(WallC.sz1, foggy));
rw_lightstep = float((Thread->Light->WallVis(WallC.sz2, foggy) - rw_lightleft) / (WallC.sx2 - WallC.sx1)); rw_lightstep = float((Thread->Light->WallVis(WallC.sz2, foggy) - rw_lightleft) / (WallC.sx2 - WallC.sx1));
} }

View file

@ -114,7 +114,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, viewport), foggy); wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr), ds->foggy, viewport);
break; break;
} }
} }
@ -732,7 +732,7 @@ namespace swrenderer
lightlist_t *lit = &backsector->e->XFloor.lightlist[j]; lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy); wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr), foggy, Thread->Viewport.get());
break; break;
} }
} }
@ -746,7 +746,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy); wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr), foggy, Thread->Viewport.get());
break; break;
} }
} }
@ -918,7 +918,7 @@ namespace swrenderer
lightlist_t *lit = &backsector->e->XFloor.lightlist[j]; lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy); wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr), foggy, Thread->Viewport.get());
break; break;
} }
} }
@ -932,7 +932,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE)); // [RH] set foggy flag
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr) + LightVisibility::ActualExtraLight(ds->foggy, Thread->Viewport.get()), foggy); wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(ds->foggy, *lit->p_lightlevel, lit->lightsource != nullptr), foggy, Thread->Viewport.get());
break; break;
} }
} }

View file

@ -349,7 +349,9 @@ namespace swrenderer
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
bool fixed = (cameraLight->FixedColormap() != NULL || cameraLight->FixedLightLevel() >= 0); bool fixed = (cameraLight->FixedColormap() != NULL || cameraLight->FixedLightLevel() >= 0);
if (cameraLight->FixedColormap()) if (cameraLight->FixedLightLevel() >= 0)
drawerargs.SetLight(cameraLight->FixedColormap(), 0, cameraLight->FixedLightLevelShade());
else if (cameraLight->FixedColormap())
drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0); drawerargs.SetLight(cameraLight->FixedColormap(), 0, 0);
else else
drawerargs.SetLight(basecolormap, 0, 0); drawerargs.SetLight(basecolormap, 0, 0);
@ -420,7 +422,7 @@ namespace swrenderer
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i]; lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]); basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy); wallshade = LightVisibility::LightLevelToShade(curline->sidedef->GetLightLevel(foggy, *lit->p_lightlevel, lit->lightsource != NULL), foggy, Thread->Viewport.get());
} }
ProcessNormalWall(up, dwal, texturemid, swal, lwal); ProcessNormalWall(up, dwal, texturemid, swal, lwal);

View file

@ -153,7 +153,7 @@ namespace swrenderer
else else
{ {
plane_shade = true; plane_shade = true;
planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy); planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy, viewport);
} }
drawerargs.SetStyle(masked, additive, alpha); drawerargs.SetStyle(masked, additive, alpha);

View file

@ -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); planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy, viewport);
} }
// 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

View file

@ -99,7 +99,7 @@ namespace swrenderer
} }
} }
VisiblePlane *VisiblePlaneList::FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal, FDynamicColormap *basecolormap, Fake3DOpaque::Type fakeFloorType, fixed_t fakeAlpha) VisiblePlane *VisiblePlaneList::FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, bool foggy, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal, FDynamicColormap *basecolormap, Fake3DOpaque::Type fakeFloorType, fixed_t fakeAlpha)
{ {
secplane_t plane; secplane_t plane;
VisiblePlane *check; VisiblePlane *check;
@ -113,6 +113,8 @@ namespace swrenderer
RenderPortal *renderportal = Thread->Portal.get(); RenderPortal *renderportal = Thread->Portal.get();
lightlevel += LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get());
if (picnum == skyflatnum) // killough 10/98 if (picnum == skyflatnum) // killough 10/98
{ // most skies map together { // most skies map together
lightlevel = 0; lightlevel = 0;

View file

@ -40,7 +40,7 @@ namespace swrenderer
void Clear(); void Clear();
void ClearKeepFakePlanes(); void ClearKeepFakePlanes();
VisiblePlane *FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal, FDynamicColormap *basecolormap, Fake3DOpaque::Type fakeFloorType, fixed_t fakeAlpha); VisiblePlane *FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, bool foggy, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal, FDynamicColormap *basecolormap, Fake3DOpaque::Type fakeFloorType, fixed_t fakeAlpha);
VisiblePlane *GetRange(VisiblePlane *pl, int start, int stop); VisiblePlane *GetRange(VisiblePlane *pl, int start, int stop);
bool HasPortalPlanes() const; bool HasPortalPlanes() const;

View file

@ -142,7 +142,7 @@ namespace swrenderer
NoLightFade = !!(level.flags3 & LEVEL3_NOLIGHTFADE); NoLightFade = !!(level.flags3 & LEVEL3_NOLIGHTFADE);
} }
fixed_t LightVisibility::LightLevelToShade(int lightlevel, bool foggy) fixed_t LightVisibility::LightLevelToShadeImpl(int lightlevel, bool foggy)
{ {
bool nolightfade = !foggy && ((level.flags3 & LEVEL3_NOLIGHTFADE)); bool nolightfade = !foggy && ((level.flags3 & LEVEL3_NOLIGHTFADE));
if (nolightfade) if (nolightfade)

View file

@ -80,22 +80,26 @@ namespace swrenderer
void SetVisibility(RenderViewport *viewport, double visibility); void SetVisibility(RenderViewport *viewport, double visibility);
double GetVisibility() const { return CurrentVisibility; } double GetVisibility() const { return CurrentVisibility; }
double WallGlobVis(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 SlopePlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : TiltVisibility; }
// 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 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); }
static fixed_t LightLevelToShade(int lightlevel, bool foggy); double SlopePlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : TiltVisibility; }
static fixed_t LightLevelToShade(int lightlevel, bool foggy, RenderViewport *viewport) { return LightLevelToShadeImpl(lightlevel + ActualExtraLight(foggy, viewport), foggy); }
static int ActualExtraLight(bool fog, RenderViewport *viewport) { return fog ? 0 : viewport->viewpoint.extralight << 4; } static int ActualExtraLight(bool fog, RenderViewport *viewport) { return fog ? 0 : viewport->viewpoint.extralight << 4; }
private: private:
double WallGlobVis(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; }
static fixed_t LightLevelToShadeImpl(int lightlevel, bool foggy);
double BaseVisibility = 0.0; double BaseVisibility = 0.0;
double WallVisibility = 0.0; double WallVisibility = 0.0;
double FloorVisibility = 0.0; double FloorVisibility = 0.0;

View file

@ -548,7 +548,7 @@ namespace swrenderer
ceilingplane = Thread->PlaneList->FindPlane( ceilingplane = Thread->PlaneList->FindPlane(
frontsector->ceilingplane, frontsector->ceilingplane,
frontsector->GetTexture(sector_t::ceiling), frontsector->GetTexture(sector_t::ceiling),
adjusted_ceilinglightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), adjusted_ceilinglightlevel, foggy,
frontsector->GetAlpha(sector_t::ceiling), frontsector->GetAlpha(sector_t::ceiling),
!!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE), !!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE),
frontsector->planes[sector_t::ceiling].xform, frontsector->planes[sector_t::ceiling].xform,
@ -588,7 +588,7 @@ namespace swrenderer
{ {
floorplane = Thread->PlaneList->FindPlane(frontsector->floorplane, floorplane = Thread->PlaneList->FindPlane(frontsector->floorplane,
frontsector->GetTexture(sector_t::floor), frontsector->GetTexture(sector_t::floor),
adjusted_floorlightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), adjusted_floorlightlevel, foggy,
frontsector->GetAlpha(sector_t::floor), frontsector->GetAlpha(sector_t::floor),
!!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE), !!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE),
frontsector->planes[sector_t::floor].xform, frontsector->planes[sector_t::floor].xform,
@ -613,7 +613,7 @@ 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 + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy); int shade = LightVisibility::LightLevelToShade((floorlightlevel + ceilinglightlevel) / 2, foggy, Thread->Viewport.get());
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, shade, FakeSide, foggy);
@ -732,7 +732,7 @@ namespace swrenderer
VisiblePlane *floorplane3d = Thread->PlaneList->FindPlane( VisiblePlane *floorplane3d = Thread->PlaneList->FindPlane(
tempsec.floorplane, tempsec.floorplane,
tempsec.GetTexture(sector_t::floor), tempsec.GetTexture(sector_t::floor),
floorlightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), floorlightlevel, foggy,
tempsec.GetAlpha(sector_t::floor), tempsec.GetAlpha(sector_t::floor),
!!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS), !!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS),
tempsec.planes[position].xform, tempsec.planes[position].xform,
@ -800,7 +800,7 @@ namespace swrenderer
VisiblePlane *ceilingplane3d = Thread->PlaneList->FindPlane( VisiblePlane *ceilingplane3d = Thread->PlaneList->FindPlane(
tempsec.ceilingplane, tempsec.ceilingplane,
tempsec.GetTexture(sector_t::ceiling), tempsec.GetTexture(sector_t::ceiling),
ceilinglightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), ceilinglightlevel, foggy,
tempsec.GetAlpha(sector_t::ceiling), tempsec.GetAlpha(sector_t::ceiling),
!!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS), !!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS),
tempsec.planes[position].xform, tempsec.planes[position].xform,
@ -891,7 +891,7 @@ namespace swrenderer
//sec->validcount = validcount; //sec->validcount = validcount;
SeenSpriteSectors.insert(sec); SeenSpriteSectors.insert(sec);
int spriteshade = LightVisibility::LightLevelToShade(lightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy); 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)
@ -951,7 +951,7 @@ namespace swrenderer
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(); int lightlevel = thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
thingShade = LightVisibility::LightLevelToShade(lightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()), foggy); 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);
} }

View file

@ -80,7 +80,6 @@ namespace swrenderer
void RenderPlayerSprites::Render() void RenderPlayerSprites::Render()
{ {
int i; int i;
int lightnum;
DPSprite* psp; DPSprite* psp;
DPSprite* weapon; DPSprite* weapon;
sector_t* sec = NULL; sector_t* sec = NULL;
@ -138,8 +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
lightnum = ((floorlight + ceilinglight) >> 1) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()); int spriteshade = LightVisibility::LightLevelToShade((floorlight + ceilinglight) >> 1, foggy, Thread->Viewport.get()) - 24 * FRACUNIT;
int spriteshade = LightVisibility::LightLevelToShade(lightnum, foggy) - 24 * FRACUNIT;
if (Thread->Viewport->viewpoint.camera->player != NULL) if (Thread->Viewport->viewpoint.camera->player != NULL)
{ {

View file

@ -163,7 +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 + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), foggy); int spriteshade = LightVisibility::LightLevelToShade(sec->lightlevel, foggy, thread->Viewport.get());
Light.SetColormap(thread->Light->SpriteVis(spr->depth, foggy), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack); Light.SetColormap(thread->Light->SpriteVis(spr->depth, foggy), spriteshade, mybasecolormap, isFullBright, invertcolormap, fadeToBlack);
} }

View file

@ -190,10 +190,9 @@ namespace swrenderer
SpriteDrawerArgs drawerargs; SpriteDrawerArgs drawerargs;
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), spr->foggy); int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel, spr->foggy, thread->Viewport.get());
double GlobVis = thread->Light->WallGlobVis(foggy); float lightleft = float(thread->Light->WallVis(spr->wallc.sz1, foggy));
float lightleft = float(GlobVis / spr->wallc.sz1); float lightstep = float((thread->Light->WallVis(spr->wallc.sz2, foggy) - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
float light = lightleft + (x1 - spr->wallc.sx1) * lightstep; float light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
CameraLight *cameraLight = CameraLight::Instance(); CameraLight *cameraLight = CameraLight::Instance();
if (cameraLight->FixedLightLevel() >= 0) if (cameraLight->FixedLightLevel() >= 0)