diff --git a/plugins/GSdx/res/glsl/tfx_vgs.glsl b/plugins/GSdx/res/glsl/tfx_vgs.glsl index 3a92a20165..13c6f7deed 100644 --- a/plugins/GSdx/res/glsl/tfx_vgs.glsl +++ b/plugins/GSdx/res/glsl/tfx_vgs.glsl @@ -116,13 +116,6 @@ void vs_main() else z = i_z; - if(VS_LOGZ == 1) { - // FIXME some games (FFX12 intro) uses MAX_INT as depth parameter. So I replace the +1 with an OR - // Initially a +1 was done to avoid log2(0) (If I'm correct) - // The or mask won't create any overflow - z |= 1u; - } - // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go) // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty // input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel @@ -134,13 +127,13 @@ void vs_main() p.w = 1.0f; #ifdef ZERO_TO_ONE_DEPTH if(VS_LOGZ == 1) { - p.z = log2(float(z)) / 32.0f; + p.z = max(0.0f, log2(float(z))) / 32.0f; } else { p.z = float(z) * exp_min32; } #else if(VS_LOGZ == 1) { - p.z = log2(float(z)) / 31.0f - 1.0f; + p.z = max(0.0f, log2(float(z))) / 31.0f - 1.0f; } else { p.z = float(z) * exp_min31 - 1.0f; } diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 45284af96a..401c324cde 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -567,13 +567,6 @@ static const char* tfx_vgs_glsl = " else\n" " z = i_z;\n" "\n" - " if(VS_LOGZ == 1) {\n" - " // FIXME some games (FFX12 intro) uses MAX_INT as depth parameter. So I replace the +1 with an OR\n" - " // Initially a +1 was done to avoid log2(0) (If I'm correct)\n" - " // The or mask won't create any overflow\n" - " z |= 1u;\n" - " }\n" - "\n" " // pos -= 0.05 (1/320 pixel) helps avoiding rounding problems (integral part of pos is usually 5 digits, 0.05 is about as low as we can go)\n" " // example: ceil(afterseveralvertextransformations(y = 133)) => 134 => line 133 stays empty\n" " // input granularity is 1/16 pixel, anything smaller than that won't step drawing up/left by one pixel\n" @@ -585,13 +578,13 @@ static const char* tfx_vgs_glsl = " p.w = 1.0f;\n" "#ifdef ZERO_TO_ONE_DEPTH\n" " if(VS_LOGZ == 1) {\n" - " p.z = log2(float(z)) / 32.0f;\n" + " p.z = max(0.0f, log2(float(z))) / 32.0f;\n" " } else {\n" " p.z = float(z) * exp_min32;\n" " }\n" "#else\n" " if(VS_LOGZ == 1) {\n" - " p.z = log2(float(z)) / 31.0f - 1.0f;\n" + " p.z = max(0.0f, log2(float(z))) / 31.0f - 1.0f;\n" " } else {\n" " p.z = float(z) * exp_min31 - 1.0f;\n" " }\n"