From 83760d4974b15d115ef79c7299523d0c568f3a7a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Mar 2021 13:09:26 +0200 Subject: [PATCH] - fixed a few wall sprite rendering issues. * masked walls were inserted into the sprite render list, causing sorting issues and depth fighting (see Duke's cameras and the 'closed' sign in Route66/Carnival.map) * vertical and horizontal wall sprites needed their sorting functions swapped. * plane clipping for wall sprites used bad coordinates. --- source/core/rendering/scene/hw_drawinfo.cpp | 4 ++-- source/core/rendering/scene/hw_drawlistadd.cpp | 2 +- source/core/rendering/scene/hw_walls.cpp | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index 29894bd50..650c7c0d7 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -437,8 +437,8 @@ void HWDrawInfo::RenderScene(FRenderState &state) // These lists must be drawn in two passes for color and depth to avoid depth fighting with overlapping entries drawlists[GLDL_MASKEDFLATS].SortFlats(this); - drawlists[GLDL_MASKEDWALLSV].SortWallsVert(this); - drawlists[GLDL_MASKEDWALLSH].SortWallsHorz(this); + drawlists[GLDL_MASKEDWALLSV].SortWallsHorz(this); + drawlists[GLDL_MASKEDWALLSH].SortWallsVert(this); state.SetDepthBias(-1, -128); diff --git a/source/core/rendering/scene/hw_drawlistadd.cpp b/source/core/rendering/scene/hw_drawlistadd.cpp index d7ef8a309..ac008075c 100644 --- a/source/core/rendering/scene/hw_drawlistadd.cpp +++ b/source/core/rendering/scene/hw_drawlistadd.cpp @@ -50,7 +50,7 @@ void HWDrawInfo::AddWall(HWWall *wall) int list; if (wall->type != RENDERWALL_M2S) list = GLDL_PLAINWALLS; - else if (sprite == nullptr) list = GLDL_MASKEDWALLS; + else if (wall->sprite == nullptr) list = GLDL_MASKEDWALLS; else if (wall->glseg.x1 == wall->glseg.x2) list = GLDL_MASKEDWALLSV; else if (wall->glseg.y1 == wall->glseg.y2) list = GLDL_MASKEDWALLSH; else list = GLDL_MASKEDWALLSS; diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 062145d53..4178f4082 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -898,6 +898,7 @@ void HWWall::Process(HWDrawInfo* di, walltype* wal, sectortype* frontsector, sec this->seg = wal; this->frontsector = frontsector; this->backsector = backsector; + sprite = nullptr; vertindex = 0; vertcount = 0; @@ -1135,7 +1136,7 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect float polyh = (zbottom[0] - origz); if (!(sector->ceilingstat & CSTAT_SECTOR_SKY)) { - float ceilingz = sector->ceilingz * (1 / 256.f); + float ceilingz = sector->ceilingz * (1 / -256.f); if (ceilingz < ztop[0] && ceilingz > zbottom[0]) { float newv = (ceilingz - origz) / polyh; @@ -1145,7 +1146,7 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect } if (!(sector->floorstat & CSTAT_SECTOR_SKY)) { - float floorz = sector->floorz * (1 / 256.f); + float floorz = sector->floorz * (1 / -256.f); if (floorz < ztop[0] && floorz > zbottom[0]) { float newv = (floorz - origz) / polyh;