From aa34cd3bd75d8ee9acaa994484d4d89e10bbe1d0 Mon Sep 17 00:00:00 2001 From: Stefanos Kornilios Mitsis Poiitidis Date: Sat, 15 Mar 2025 01:32:00 +0200 Subject: [PATCH] Fix sprite depths for text that got broken from the recip changes --- src/liberty/renderer/Sprite2d.cpp | 11 ++++++----- src/miami/renderer/Sprite2d.cpp | 10 +++++----- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/liberty/renderer/Sprite2d.cpp b/src/liberty/renderer/Sprite2d.cpp index 5214ef4e..c0976fdf 100644 --- a/src/liberty/renderer/Sprite2d.cpp +++ b/src/liberty/renderer/Sprite2d.cpp @@ -177,8 +177,8 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C z = RwCameraGetFarClipPlane(Scene.camera); }else{ screenz = RwIm2DGetNearScreenZ(); - z = 1.0f/RecipNearClip; RecipNearClip *= 1.1f; + z = 1.0f/RecipNearClip; } recipz = 1.0f/z; float offset = 1.0f/1024.0f; @@ -231,9 +231,9 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C float screenz, z, recipz; screenz = RwIm2DGetNearScreenZ(); + RecipNearClip *= 1.1f; z = 1.0f/RecipNearClip; recipz = 1.0f/z; - RecipNearClip *= 1.1f; // This is what we draw: // 0---1 @@ -286,6 +286,7 @@ CSprite2d::SetVertices(float x1, float y1, float x2, float y2, float x3, float y screenz = RwIm2DGetNearScreenZ(); recipz = RecipNearClip; RecipNearClip *= 1.1f; + z = 1/RecipNearClip; RwIm2DVertexSetScreenX(&maVertices[0], x3); RwIm2DVertexSetScreenY(&maVertices[0], y3); @@ -333,7 +334,7 @@ CSprite2d::SetVertices(int n, float *positions, float *uvs, const CRGBA &col) screenz = RwIm2DGetNearScreenZ(); recipz = RecipNearClip; RecipNearClip *= 1.1f; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game + z = 1/RecipNearClip; for(i = 0; i < n; i++){ @@ -357,7 +358,7 @@ CSprite2d::SetMaskVertices(int n, float *positions) screenz = RwIm2DGetNearScreenZ(); recipz = RecipNearClip; RecipNearClip *= 1.1f; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game + z = 1/RecipNearClip; for(i = 0; i < n; i++){ RwIm2DVertexSetScreenX(&maVertices[i], positions[i*2 + 0]); @@ -382,7 +383,7 @@ CSprite2d::SetVertices(RwIm2DVertex *verts, const CRect &r, const CRGBA &c0, con screenz = RwIm2DGetNearScreenZ(); recipz = RecipNearClip; RecipNearClip *= 1.1f; - z = RwCameraGetNearClipPlane(Scene.camera); // not done by game + z = 1/RecipNearClip; RwIm2DVertexSetScreenX(&verts[0], r.left); RwIm2DVertexSetScreenY(&verts[0], r.top); diff --git a/src/miami/renderer/Sprite2d.cpp b/src/miami/renderer/Sprite2d.cpp index 9517d97f..6f20cdbb 100644 --- a/src/miami/renderer/Sprite2d.cpp +++ b/src/miami/renderer/Sprite2d.cpp @@ -130,7 +130,7 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C float offset = 1.0f/1024.0f; // Workaround for PVR Z-Equality not being exact - RecipNearClip *= 1.1f; + NearCamZ /= 1.1f; // This is what we draw: // 0---1 @@ -178,7 +178,7 @@ CSprite2d::SetVertices(const CRect &r, const CRGBA &c0, const CRGBA &c1, const C float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2) { // Workaround for PVR Z-Equality not being exact - RecipNearClip *= 1.1f; + NearCamZ /= 1.1f; // This is what we draw: // 0---1 @@ -227,7 +227,7 @@ CSprite2d::SetVertices(float x1, float y1, float x2, float y2, float x3, float y { // Workaround for PVR Z-Equality not being exact if (dt == DRAW_NEAR) { - RecipNearClip *= 1.1f; + NearCamZ /= 1.1f; } float screenZ = dt == DRAW_FAR ? FarScreenZ : NearScreenZ; @@ -275,7 +275,7 @@ void CSprite2d::SetVertices(int n, float *positions, float *uvs, const CRGBA &col) { // Workaround for PVR Z-Equality not being exact - RecipNearClip *= 1.1f; + NearCamZ /= 1.1f; int i; @@ -315,7 +315,7 @@ CSprite2d::SetVertices(RwIm2DVertex *verts, const CRect &r, const CRGBA &c0, con float u0, float v0, float u1, float v1, float u3, float v3, float u2, float v2) { // Workaround for PVR Z-Equality not being exact - RecipNearClip *= 1.1f; + NearCamZ /= 1.1f; RwIm2DVertexSetScreenX(&verts[0], r.left); RwIm2DVertexSetScreenY(&verts[0], r.top);