mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-09 00:11:24 +12:00
rsx: Remove zclip hackery
- Calculates precise Z value as requested by the game - Works properly if the underlying Z format matches the PS3 1:1 but may cause minor problems otherwise
This commit is contained in:
parent
dcd011048d
commit
1ce5349199
1 changed files with 8 additions and 16 deletions
|
@ -603,27 +603,19 @@ namespace glsl
|
||||||
{
|
{
|
||||||
if (props.emulate_depth_clip_only)
|
if (props.emulate_depth_clip_only)
|
||||||
{
|
{
|
||||||
// Declare rcp_precise. Requires f64 support in the drivers.
|
|
||||||
// This is required to handle precision drift during division for extended depth range.
|
|
||||||
OS <<
|
|
||||||
"double rcp_precise(double x)\n"
|
|
||||||
"{\n"
|
|
||||||
" double scaled = x * 0.0009765625;\n"
|
|
||||||
" double inv = 1.0 / scaled;\n"
|
|
||||||
" return inv * 0.0009765625;\n"
|
|
||||||
"}\n"
|
|
||||||
"\n"
|
|
||||||
// Technically the depth value here is the 'final' depth that should be stored in the Z buffer.
|
// Technically the depth value here is the 'final' depth that should be stored in the Z buffer.
|
||||||
// Forward mapping eqn is d' = d * (f - n) + n, where d' is the stored Z value (this) and d is the normalized API value.
|
// Forward mapping eqn is d' = d * (f - n) + n, where d' is the stored Z value (this) and d is the normalized API value.
|
||||||
|
OS <<
|
||||||
"vec4 apply_zclip_xform(const in vec4 pos, const in float near_plane, const in float far_plane)\n"
|
"vec4 apply_zclip_xform(const in vec4 pos, const in float near_plane, const in float far_plane)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" if (far_plane != 0.0 && pos.w != 0.0)\n"
|
" if (pos.w != 0.0)\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
" double z_range = (far_plane > near_plane)? (far_plane - near_plane) : far_plane;\n"
|
" const float real_n = min(far_plane, near_plane);\n"
|
||||||
" double inv_range = rcp_precise(z_range);\n"
|
" const float real_f = max(far_plane, near_plane);\n"
|
||||||
" float d = float(pos.z * rcp_precise(pos.w));\n"
|
" const double depth_range = double(real_f - real_n);\n"
|
||||||
" float new_d = (d - near_plane) * float(inv_range);\n"
|
" const double inv_range = (depth_range > 0.0) ? (1.0 / (depth_range * pos.w)) : 0.0;\n"
|
||||||
" return vec4(pos.x, pos.y, (new_d * pos.w), pos.w);\n"
|
" const double d = (double(pos.z) - real_n) * inv_range;\n"
|
||||||
|
" return vec4(pos.xy, float(d * pos.w), pos.w);\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" else\n"
|
" else\n"
|
||||||
" {\n"
|
" {\n"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue