Skip to content

Commit

Permalink
Revert software renderer parts of "- sprite lightlevel cleanup and fi…
Browse files Browse the repository at this point in the history
…xes."

This code had some issues which are not easily fixed, so it's better to just undo it all.
  • Loading branch information
coelckers authored and drfrag666 committed Jun 6, 2024
1 parent d0b3278 commit 72dcfeb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions src/rendering/swrenderer/scene/r_opaque_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,8 @@ namespace swrenderer
}

Add3DFloorPlanes(sub, frontsector, basecolormap, foggy, adjusted_ceilinglightlevel, adjusted_floorlightlevel);
AddSprites(sub->sector, frontsector, FakeSide, foggy);
auto nc = !!(frontsector->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING);
AddSprites(sub->sector, frontsector->GetTexture(sector_t::ceiling) == skyflatnum ? ceilinglightlevel : floorlightlevel, FakeSide, foggy, GetSpriteColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::sprites], nc));

// [RH] Add particles
if ((unsigned int)(sub->Index()) < Level->subsectors.Size())
Expand Down Expand Up @@ -874,7 +875,7 @@ namespace swrenderer
fillshort(ceilingclip, viewwidth, 0);
}

void RenderOpaquePass::AddSprites(sector_t *sec, sector_t* frontsector, WaterFakeSide fakeside, bool foggy)
void RenderOpaquePass::AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy, FDynamicColormap *basecolormap)
{
// BSP is traversed by subsector.
// A sector might have been split into several
Expand Down Expand Up @@ -940,22 +941,23 @@ namespace swrenderer
}
else if (GetThingSprite(thing, sprite))
{
int thinglightlevel;
FDynamicColormap *thingColormap = basecolormap;
int thinglightlevel = lightlevel;
if (sec->sectornum != thing->Sector->sectornum) // compare sectornums to account for R_FakeFlat copies.
{
frontsector = thing->Sector;
thinglightlevel = thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
auto nc = !!(thing->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING);
thingColormap = GetSpriteColorTable(thing->Sector->Colormap, thing->Sector->SpecialColors[sector_t::sprites], nc);
}
auto nc = !!(thing->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING);
FDynamicColormap* thingColormap = GetSpriteColorTable(frontsector->Colormap, frontsector->SpecialColors[sector_t::sprites], nc);

// per-sprite lightlevel and fog do not mix well in the software renderer.
if (!foggy)
{
thinglightlevel = clamp(thing->GetLightLevel(frontsector), 0, 255);
}
else
if (thing->LightLevel > -1)
{
thinglightlevel = clamp<int>(frontsector->lightlevel, 0, 255);
thinglightlevel = thing->LightLevel;

if (thing->flags8 & MF8_ADDLIGHTLEVEL)
{
thinglightlevel += thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
thinglightlevel = clamp(thinglightlevel, 0, 255);
}
}
if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE)
{
Expand Down
2 changes: 1 addition & 1 deletion src/rendering/swrenderer/scene/r_opaque_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace swrenderer
void FakeDrawLoop(subsector_t *sub, sector_t *frontsector, VisiblePlane *floorplane, VisiblePlane *ceilingplane, Fake3DOpaque opaque3dfloor);
void Add3DFloorLine(seg_t *line, sector_t *frontsector);

void AddSprites(sector_t *sec, sector_t* frontsector, WaterFakeSide fakeside, bool foggy);
void AddSprites(sector_t *sec, int lightlevel, WaterFakeSide fakeside, bool foggy, FDynamicColormap *basecolormap);
bool IsPotentiallyVisible(AActor *thing);
bool GetThingSprite(AActor *thing, ThingSprite &sprite);

Expand Down

0 comments on commit 72dcfeb

Please sign in to comment.