From 18cf208b7d057c805134fb90a332d51ab0666244 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Mar 2021 22:29:13 +0200 Subject: [PATCH] - fixed SW shadows in new renderer. shade clamping and full sprite sort was missing, --- source/core/rendering/scene/hw_drawlist.cpp | 2 +- source/core/rendering/scene/hw_flats.cpp | 6 +++--- source/core/rendering/scene/hw_sprites.cpp | 2 +- source/core/rendering/scene/hw_walls.cpp | 6 +++--- source/games/sw/src/draw.cpp | 10 +++++----- source/games/sw/src/rooms.cpp | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/core/rendering/scene/hw_drawlist.cpp b/source/core/rendering/scene/hw_drawlist.cpp index 81d9043f6..126a36ee7 100644 --- a/source/core/rendering/scene/hw_drawlist.cpp +++ b/source/core/rendering/scene/hw_drawlist.cpp @@ -591,7 +591,7 @@ inline int HWDrawList::CompareSprites(SortNode * a,SortNode * b) if (s1->depth < s2->depth) return 1; if (s1->depth > s2->depth) return -1; - return reverseSort? s2->index-s1->index : s1->index-s2->index; + return s1->sprite->time - s2->sprite->time; } //========================================================================== diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index 9ef8de751..40a71611f 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -284,7 +284,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int which) { // process the original floor first. - shade = frontsector->floorshade; + shade = clamp(frontsector->floorshade, 0, numshades-1); palette = frontsector->floorpal; //port = frontsector->ValidatePortal(sector_t::floor); @@ -323,7 +323,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int which) { // process the original ceiling first. - shade = frontsector->ceilingshade; + shade = clamp(frontsector->ceilingshade, 0, numshades-1); palette = frontsector->ceilingpal; @@ -371,7 +371,7 @@ void HWFlat::ProcessFlatSprite(HWDrawInfo* di, spritetype* sprite, sectortype* s { this->sprite = sprite; sec = sector; - shade = sprite->shade; + shade = clamp(sprite->shade, 0, numshades - 1); palette = sprite->pal; fade = lookups.getFade(sector[sprite->sectnum].floorpal); // fog is per sector. diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index ebe9202c9..fa9f9d8ef 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -320,7 +320,7 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int modelframe = 0; dynlightindex = -1; - shade = spr->shade; + shade = clamp(spr->shade, 0, numshades-1); palette = spr->pal; fade = lookups.getFade(sector->floorpal); // fog is per sector. visibility = sectorVisibility(sector); diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index ee87ead81..0bdd09493 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -822,7 +822,7 @@ void HWWall::DoLowerTexture(HWDrawInfo* di, walltype* wal, sectortype* frontsect auto refwall = (wal->cstat & CSTAT_WALL_BOTTOM_SWAP) ? &wall[wal->nextwall] : wal; refheight = (refwall->cstat & CSTAT_WALL_ALIGN_BOTTOM) ? frontsector->ceilingz : backsector->floorz; - shade = refwall->shade; + shade = clamp(refwall->shade, 0, numshades - 1); palette = refwall->pal; type = RENDERWALL_BOTTOM; DoTexture(di, wal, refwall, refheight, topleft, topright, bottomleft, bottomright); @@ -922,7 +922,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec glseg.fracright = 1; flags = 0; dynlightindex = -1; - shade = wal->shade; + shade = clamp(wal->shade, 0, numshades - 1); palette = wal->pal; fade = lookups.getFade(frontsector->floorpal); // fog is per sector. visibility = sectorVisibility(frontsector); @@ -1083,7 +1083,7 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect flags = 0; dynlightindex = -1; - shade = spr->shade; + shade = clamp(spr->shade, 0, numshades - 1); palette = spr->pal; fade = lookups.getFade(sector->floorpal); // fog is per sector. visibility = sectorVisibility(sector); diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 0b8ee5ca1..1b2527cce 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -350,14 +350,14 @@ DoShadows(tspriteptr_t tsp, int viewz, int camang) New->clipdist |= TSPR_FLAGS_MDHACK; New->cstat |= 512; } - else + else if (!testnewrenderer) { int const camang = mirror ? NORM_ANGLE(2048 - Player[screenpeek].siang) : Player[screenpeek].siang; - vec2_t const ofs = { bcos(camang, -11), bsin(camang, -11) }; - - New->x += ofs.x; - New->y += ofs.y; + New->x += bcos(camang, -11); + New->y += bsin(camang, -11); + } + else New->time = 1; // Check for voxel items and use a round generic pic if so //DoVoxelShadow(New); diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 2d18da39a..7408a7239 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -1192,7 +1192,7 @@ void CollectPortals() } } } - testnewrenderer = false; + testnewrenderer = t; }