From 2273bd2ea46c1d53a775d0f11bf902e1b3bb125b Mon Sep 17 00:00:00 2001 From: StapleButter Date: Fri, 28 Apr 2017 17:35:57 +0200 Subject: [PATCH] fix texcoord-from-vertex mode. it works like for normals (1.0 = 1/16 texel) --- src/GPU3D.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index fd1b98f5..a63193f1 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -849,6 +849,7 @@ void SubmitPolygon() if (FlushAttributes & 0x2) z = w << wshift; else + //z = vtx->Position[2]+0x7FFFFF;//((vtx->Position[2] + (w<Position[2] * 0x800000) / (w << wshift)) + 0x7FFEFF; // checkme @@ -884,8 +885,8 @@ void SubmitVertex() if ((TexParam >> 30) == 3) { - vertextrans->TexCoords[0] = (vertex[0]*TexMatrix[0] + vertex[1]*TexMatrix[4] + vertex[2]*TexMatrix[8] + vertex[3]*(RawTexCoords[0]<<8)) >> 20; - vertextrans->TexCoords[1] = (vertex[0]*TexMatrix[1] + vertex[1]*TexMatrix[5] + vertex[2]*TexMatrix[9] + vertex[3]*(RawTexCoords[1]<<8)) >> 20; + vertextrans->TexCoords[0] = ((vertex[0]*TexMatrix[0] + vertex[1]*TexMatrix[4] + vertex[2]*TexMatrix[8]) >> 24) + RawTexCoords[0]; + vertextrans->TexCoords[1] = ((vertex[0]*TexMatrix[1] + vertex[1]*TexMatrix[5] + vertex[2]*TexMatrix[9]) >> 24) + RawTexCoords[1]; } else { @@ -963,6 +964,8 @@ void SubmitVertex() s32 CalculateLighting() { // TODO: this requires matrix mode 2, apparently + // hardware seems to read garbage when matrix mode isn't 2 + // also, non-normal normals seem to be treated as zero? or overflow to negative? if ((TexParam >> 30) == 2) {