glsl: use signed integer when working with substraction...

It mostly fixes rendering of GoW with ultra blending

Color is still a bit wrong but rounding is likely incorrect
This commit is contained in:
Gregory Hainaut 2015-07-18 14:37:08 +02:00
parent c701ab4368
commit c4e165067d
2 changed files with 10 additions and 4 deletions

View File

@ -462,15 +462,18 @@ void ps_blend(inout vec4 Color, float As)
Color.rgb = clamp(Color.rgb, vec3(0.0f), vec3(255.0f));
#endif
// FIXME rouding of negative float?
// compiler uses trunc but it might need floor
// Warning: normally blending equation is mult(A, B) = A * B >> 7. GPU have the full accuracy
// GS: Color = 1, Alpha = 255 => output 1
// GPU: Color = 1/255, Alpha = 255/255 * 255/128 => output 1.9921875
#if PS_DFMT == FMT_16
// In 16 bits format, only 5 bits of colors are used. It impacts shadows computation of Castlevania
Color.rgb = vec3(uvec3(Color.rgb) & uvec3(0xF8));
Color.rgb = vec3(ivec3(Color.rgb) & ivec3(0xF8));
#elif PS_COLCLIP == 3
Color.rgb = vec3(uvec3(Color.rgb) & uvec3(0xFF));
Color.rgb = vec3(ivec3(Color.rgb) & ivec3(0xFF));
#endif
#endif

View File

@ -1325,15 +1325,18 @@ static const char* tfx_fs_all_glsl =
" Color.rgb = clamp(Color.rgb, vec3(0.0f), vec3(255.0f));\n"
"#endif\n"
"\n"
" // FIXME rouding of negative float?\n"
" // compiler uses trunc but it might need floor\n"
"\n"
" // Warning: normally blending equation is mult(A, B) = A * B >> 7. GPU have the full accuracy\n"
" // GS: Color = 1, Alpha = 255 => output 1\n"
" // GPU: Color = 1/255, Alpha = 255/255 * 255/128 => output 1.9921875\n"
"#if PS_DFMT == FMT_16\n"
" // In 16 bits format, only 5 bits of colors are used. It impacts shadows computation of Castlevania\n"
"\n"
" Color.rgb = vec3(uvec3(Color.rgb) & uvec3(0xF8));\n"
" Color.rgb = vec3(ivec3(Color.rgb) & ivec3(0xF8));\n"
"#elif PS_COLCLIP == 3\n"
" Color.rgb = vec3(uvec3(Color.rgb) & uvec3(0xFF));\n"
" Color.rgb = vec3(ivec3(Color.rgb) & ivec3(0xFF));\n"
"#endif\n"
"\n"
"#endif\n"