mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 06:12:19 +00:00
- fix heretic light torch in software renderer and remove some code duplication
This commit is contained in:
parent
f35aeec6c3
commit
946f657a37
13 changed files with 41 additions and 36 deletions
|
@ -503,7 +503,7 @@ namespace swrenderer
|
|||
}
|
||||
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)
|
||||
|
@ -789,7 +789,7 @@ namespace swrenderer
|
|||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
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_lightstep = float((Thread->Light->WallVis(WallC.sz2, foggy) - rw_lightleft) / (WallC.sx2 - WallC.sx1));
|
||||
}
|
||||
|
|
|
@ -114,7 +114,7 @@ namespace swrenderer
|
|||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -732,7 +732,7 @@ namespace swrenderer
|
|||
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ namespace swrenderer
|
|||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -918,7 +918,7 @@ namespace swrenderer
|
|||
lightlist_t *lit = &backsector->e->XFloor.lightlist[j];
|
||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -932,7 +932,7 @@ namespace swrenderer
|
|||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[j];
|
||||
basecolormap = GetColorTable(lit->extra_colormap, frontsector->SpecialColors[sector_t::walltop]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -349,7 +349,9 @@ namespace swrenderer
|
|||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
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);
|
||||
else
|
||||
drawerargs.SetLight(basecolormap, 0, 0);
|
||||
|
@ -420,7 +422,7 @@ namespace swrenderer
|
|||
|
||||
lightlist_t *lit = &frontsector->e->XFloor.lightlist[i];
|
||||
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);
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace swrenderer
|
|||
else
|
||||
{
|
||||
plane_shade = true;
|
||||
planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy);
|
||||
planeshade = LightVisibility::LightLevelToShade(pl->lightlevel, foggy, viewport);
|
||||
}
|
||||
|
||||
drawerargs.SetStyle(masked, additive, alpha);
|
||||
|
|
|
@ -197,7 +197,7 @@ namespace swrenderer
|
|||
{
|
||||
drawerargs.SetLight(basecolormap, 0, 0);
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
VisiblePlane *check;
|
||||
|
@ -113,6 +113,8 @@ namespace swrenderer
|
|||
|
||||
RenderPortal *renderportal = Thread->Portal.get();
|
||||
|
||||
lightlevel += LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get());
|
||||
|
||||
if (picnum == skyflatnum) // killough 10/98
|
||||
{ // most skies map together
|
||||
lightlevel = 0;
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace swrenderer
|
|||
void Clear();
|
||||
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);
|
||||
|
||||
bool HasPortalPlanes() const;
|
||||
|
|
|
@ -142,7 +142,7 @@ namespace swrenderer
|
|||
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));
|
||||
if (nolightfade)
|
||||
|
|
|
@ -80,22 +80,26 @@ namespace swrenderer
|
|||
void SetVisibility(RenderViewport *viewport, double visibility);
|
||||
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
|
||||
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 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); }
|
||||
|
||||
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; }
|
||||
|
||||
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 WallVisibility = 0.0;
|
||||
double FloorVisibility = 0.0;
|
||||
|
|
|
@ -548,7 +548,7 @@ namespace swrenderer
|
|||
ceilingplane = Thread->PlaneList->FindPlane(
|
||||
frontsector->ceilingplane,
|
||||
frontsector->GetTexture(sector_t::ceiling),
|
||||
adjusted_ceilinglightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()),
|
||||
adjusted_ceilinglightlevel, foggy,
|
||||
frontsector->GetAlpha(sector_t::ceiling),
|
||||
!!(frontsector->GetFlags(sector_t::ceiling) & PLANEF_ADDITIVE),
|
||||
frontsector->planes[sector_t::ceiling].xform,
|
||||
|
@ -588,7 +588,7 @@ namespace swrenderer
|
|||
{
|
||||
floorplane = Thread->PlaneList->FindPlane(frontsector->floorplane,
|
||||
frontsector->GetTexture(sector_t::floor),
|
||||
adjusted_floorlightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()),
|
||||
adjusted_floorlightlevel, foggy,
|
||||
frontsector->GetAlpha(sector_t::floor),
|
||||
!!(frontsector->GetFlags(sector_t::floor) & PLANEF_ADDITIVE),
|
||||
frontsector->planes[sector_t::floor].xform,
|
||||
|
@ -613,7 +613,7 @@ namespace swrenderer
|
|||
// [RH] Add particles
|
||||
if ((unsigned int)(sub->Index()) < level.subsectors.Size())
|
||||
{ // 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)
|
||||
{
|
||||
RenderParticle::Project(Thread, &Particles[i], sub->sector, shade, FakeSide, foggy);
|
||||
|
@ -732,7 +732,7 @@ namespace swrenderer
|
|||
VisiblePlane *floorplane3d = Thread->PlaneList->FindPlane(
|
||||
tempsec.floorplane,
|
||||
tempsec.GetTexture(sector_t::floor),
|
||||
floorlightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()),
|
||||
floorlightlevel, foggy,
|
||||
tempsec.GetAlpha(sector_t::floor),
|
||||
!!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS),
|
||||
tempsec.planes[position].xform,
|
||||
|
@ -800,7 +800,7 @@ namespace swrenderer
|
|||
VisiblePlane *ceilingplane3d = Thread->PlaneList->FindPlane(
|
||||
tempsec.ceilingplane,
|
||||
tempsec.GetTexture(sector_t::ceiling),
|
||||
ceilinglightlevel + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get()),
|
||||
ceilinglightlevel, foggy,
|
||||
tempsec.GetAlpha(sector_t::ceiling),
|
||||
!!(clip3d->fakeFloor->fakeFloor->flags & FF_ADDITIVETRANS),
|
||||
tempsec.planes[position].xform,
|
||||
|
@ -891,7 +891,7 @@ namespace swrenderer
|
|||
//sec->validcount = validcount;
|
||||
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.
|
||||
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.
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ namespace swrenderer
|
|||
void RenderPlayerSprites::Render()
|
||||
{
|
||||
int i;
|
||||
int lightnum;
|
||||
DPSprite* psp;
|
||||
DPSprite* weapon;
|
||||
sector_t* sec = NULL;
|
||||
|
@ -138,8 +137,7 @@ namespace swrenderer
|
|||
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
|
||||
|
||||
// get light level
|
||||
lightnum = ((floorlight + ceilinglight) >> 1) + LightVisibility::ActualExtraLight(foggy, Thread->Viewport.get());
|
||||
int spriteshade = LightVisibility::LightLevelToShade(lightnum, foggy) - 24 * FRACUNIT;
|
||||
int spriteshade = LightVisibility::LightLevelToShade((floorlight + ceilinglight) >> 1, foggy, Thread->Viewport.get()) - 24 * FRACUNIT;
|
||||
|
||||
if (Thread->Viewport->viewpoint.camera->player != NULL)
|
||||
{
|
||||
|
|
|
@ -163,7 +163,7 @@ namespace swrenderer
|
|||
bool isFullBright = !foggy && (renderflags & RF_FULLBRIGHT);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -190,10 +190,9 @@ namespace swrenderer
|
|||
|
||||
SpriteDrawerArgs drawerargs;
|
||||
|
||||
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel + LightVisibility::ActualExtraLight(spr->foggy, thread->Viewport.get()), spr->foggy);
|
||||
double GlobVis = thread->Light->WallGlobVis(foggy);
|
||||
float lightleft = float(GlobVis / spr->wallc.sz1);
|
||||
float lightstep = float((GlobVis / spr->wallc.sz2 - lightleft) / (spr->wallc.sx2 - spr->wallc.sx1));
|
||||
int shade = LightVisibility::LightLevelToShade(spr->sector->lightlevel, spr->foggy, thread->Viewport.get());
|
||||
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 light = lightleft + (x1 - spr->wallc.sx1) * lightstep;
|
||||
CameraLight *cameraLight = CameraLight::Instance();
|
||||
if (cameraLight->FixedLightLevel() >= 0)
|
||||
|
|
Loading…
Reference in a new issue