From 743928b3794a53668ccf5ac2a347ffd027af22e0 Mon Sep 17 00:00:00 2001 From: kd-11 Date: Fri, 19 Jan 2018 12:19:59 +0300 Subject: [PATCH] vk/gl: Preserve clamped z precision to some extent - Use edges of depth range to map clamped stuff Disable range compression on regular draws vs extended range draws - Some applications require full 0-1 usage without compromises. -- TODO: This leaves the extended range z values to fight with regular draws in the .99 - 1.0 range --- rpcs3/Emu/RSX/Common/GLSLCommon.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/GLSLCommon.h b/rpcs3/Emu/RSX/Common/GLSLCommon.h index 82e4136df4..58464933ad 100644 --- a/rpcs3/Emu/RSX/Common/GLSLCommon.h +++ b/rpcs3/Emu/RSX/Common/GLSLCommon.h @@ -345,11 +345,11 @@ namespace glsl OS << "{\n"; OS << " float d = pos.z / pos.w;\n"; OS << " if (d < 0.f && d >= near_plane)\n"; - OS << " d = 0.f;\n"; + OS << " d = 0.f;\n"; //force clamp negative values OS << " else if (d > 1.f && d <= far_plane)\n"; - OS << " d = 1.f;\n"; + OS << " d = min(1., 0.99 + (0.01 * (pos.z - near_plane) / (far_plane - near_plane)));\n"; OS << " else\n"; - OS << " return pos;\n"; + OS << " return pos; //d = (0.99 * d);\n"; //range compression for normal values is disabled until a solution to ops comparing z is found OS << "\n"; OS << " pos.z = d * pos.w;\n"; OS << " return pos;\n";