- flip camera textures to have the correct orientation.

This commit is contained in:
Christoph Oelckers 2021-03-28 21:00:24 +02:00
parent e8edb32e0d
commit 0ae93318e3
3 changed files with 15 additions and 2 deletions

View file

@ -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;

View file

@ -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;

View file

@ -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.);