1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

rsx: Implement Z value snapping to account for precision errors

This commit is contained in:
kd-11 2022-04-11 23:31:40 +03:00 committed by kd-11
parent b04bd5fa74
commit 2db68acab9

View File

@ -634,7 +634,9 @@ namespace glsl
" const float real_f = max(far_plane, near_plane);\n"
" const double depth_range = double(real_f - real_n);\n"
" const double inv_range = (depth_range > 0.000001) ? (1.0 / (depth_range * pos.w)) : 0.0;\n"
" const double d = (double(pos.z) - double(real_n * pos.w)) * inv_range;\n"
" const double actual_d = (double(pos.z) - double(real_n * pos.w)) * inv_range;\n"
" const double nearest_d = floor(actual_d + 0.5);\n"
" const double d = _select(actual_d, nearest_d, abs(actual_d - nearest_d) < 0.000002);\n" // Epsilon value settled on empirically
" return vec4(pos.xy, float(d * pos.w), pos.w);\n"
" }\n"
" else\n"