mirror of https://github.com/PCSX2/pcsx2.git
glsl: improve the logz handling
This way only 0 and 1 will conflict
This commit is contained in:
parent
768ae342c3
commit
301fe869c7
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue