Round off Z for the min/max tests. Gets both Test Drive map and Wipeout Pure shadows working at the same time..

This commit is contained in:
Henrik Rydgård committed 2026-05-30 19:07:59 +02:00
1 parent eaacbbc226
commit 9979d5544d
1 file changed
+8 -3
+8 -3
View File
@@ -1229,11 +1229,16 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
if (clipMinMax) {
// We use clipping, where available, to implement min/max Z.
// 1.0 is used to disable the clip plane (should we generate more shaders instead? how costly are they?)
// Note: outPos.z need to be multiplied by outPos.w to undo the division, which shouldn't be in effect here.
// We should probably store the undivided outPos in a variable.
// We apply a small offset here, it's needed to break some ties, like in the map in Test Drive Unlimited.
WRITE(p, " %sgl_ClipDistance%s = u_minZmaxZ.x > 0.0 ? (outPos.z + 0.5 - u_minZmaxZ.x) * outPos.w : 1.0;\n", compat.vsOutPrefix, minZClipPlaneSuffix);
WRITE(p, " %sgl_ClipDistance%s = u_minZmaxZ.y < 65535.0 ? (u_minZmaxZ.y - (outPos.z + 0.5)) * outPos.w : 1.0;\n", compat.vsOutPrefix, maxZClipPlaneSuffix);
// We round to nearest 15-bit value for the check - this seems to match some of [Unknown]'s test, and PSP GPU floats
// often have a 15-bit mantissa.
WRITE(p, " float clipZ = float(int(outPos.z + 1) & 0xFFFE);\n");
WRITE(p, " %sgl_ClipDistance%s = u_minZmaxZ.x > 0.0 ? (clipZ - u_minZmaxZ.x) * outPos.w : 1.0;\n", compat.vsOutPrefix, minZClipPlaneSuffix);
WRITE(p, " %sgl_ClipDistance%s = u_minZmaxZ.y < 65535.0 ? (u_minZmaxZ.y - clipZ) * outPos.w : 1.0;\n", compat.vsOutPrefix, maxZClipPlaneSuffix);
}
// Convert to NDC space, using the framebuffer offset and size stored in u_xywh.