From 0ae93318e320a54fb094b4dd45f3586063ae65d9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 28 Mar 2021 21:00:24 +0200 Subject: [PATCH] - flip camera textures to have the correct orientation. --- source/core/rendering/scene/hw_flats.cpp | 6 ++++-- source/core/rendering/scene/hw_sprites.cpp | 1 + source/core/rendering/scene/hw_walls.cpp | 10 ++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index e69a1a4e4..9ef8de751 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -98,6 +98,7 @@ void HWFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light void HWFlat::MakeVertices() { if (vertcount > 0) return; + bool canvas = texture->isHardwareCanvas(); if (sprite == nullptr) { auto mesh = sectorGeometry.get(sec - sector, plane); @@ -109,7 +110,7 @@ void HWFlat::MakeVertices() auto& pt = mesh->vertices[i]; auto& uv = mesh->texcoords[i]; vp->SetVertex(pt.X, pt.Z, pt.Y); - vp->SetTexCoord(uv.X, uv.Y); + vp->SetTexCoord(uv.X, canvas? 1.f - uv.Y : uv.Y); vp++; } vertindex = ret.second; @@ -129,7 +130,8 @@ void HWFlat::MakeVertices() const static unsigned indices[] = { 0, 1, 2, 0, 2, 3 }; int j = indices[i]; vp->SetVertex(pos[j].x * (1 / 16.f), z, pos[j].y * (1 / -16.f)); - vp->SetTexCoord(j == 1 || j == 2 ? 1.f - x : x, j == 2 || j == 3 ? 1.f - x : x); + if (!canvas) vp->SetTexCoord(j == 1 || j == 2 ? 1.f - x : x, j == 2 || j == 3 ? 1.f - y : y); + else vp->SetTexCoord(j == 1 || j == 2 ? 1.f - x : x, j == 2 || j == 3 ? y : 1.f - y); vp++; } vertindex = ret.second; diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index f3b95cfcd..ebe9202c9 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -391,6 +391,7 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int ur = (spr->cstat & CSTAT_SPRITE_XFLIP) ? 1.f : 0.f; vt = (spr->cstat & CSTAT_SPRITE_YFLIP) ? 0.f : 1.f; vb = (spr->cstat & CSTAT_SPRITE_YFLIP) ? 1.f : 0.f; + if (tex->isHardwareCanvas()) std::swap(vt, vb); float viewvecX = vp.ViewVector.X; float viewvecY = vp.ViewVector.Y; diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index c582fd6ff..ee87ead81 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -401,6 +401,15 @@ void HWWall::PutWall(HWDrawInfo *di, bool translucent) flags |= HWF_TRANSLUCENT; ViewDistance = (di->Viewpoint.Pos.XY() - DVector2((glseg.x1 + glseg.x2) * 0.5f, (glseg.y1 + glseg.y2) * 0.5f)).LengthSquared(); } + + if (texture->isHardwareCanvas()) + { + tcs[UPLFT].v = 1.f - tcs[UPLFT].v; + tcs[LOLFT].v = 1.f - tcs[LOLFT].v; + tcs[UPRGT].v = 1.f - tcs[UPRGT].v; + tcs[LORGT].v = 1.f - tcs[LORGT].v; + } + if (!screen->BuffersArePersistent()) { @@ -1127,6 +1136,7 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect tcs[LORGT].u = tcs[UPRGT].u = (spr->cstat & CSTAT_SPRITE_XFLIP) ? 0.f : 1.f; tcs[UPLFT].v = tcs[UPRGT].v = (spr->cstat & CSTAT_SPRITE_YFLIP) ? 1.f : 0.f; tcs[LOLFT].v = tcs[LORGT].v = (spr->cstat & CSTAT_SPRITE_YFLIP) ? 0.f : 1.f; + zbottom[0] = zbottom[1] = (sprz) * (1 / -256.); ztop[0] = ztop[1] = (sprz - ((height * spr->yrepeat) << 2)) * (1 / -256.);