From c4e165067d4578b5e26123ea5d7b6c37be56e32d Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sat, 18 Jul 2015 14:37:08 +0200 Subject: [PATCH] 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 --- plugins/GSdx/res/glsl/tfx_fs.glsl | 7 +++++-- plugins/GSdx/res/glsl_source.h | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/GSdx/res/glsl/tfx_fs.glsl b/plugins/GSdx/res/glsl/tfx_fs.glsl index 4d2770403f..2c4a510fcf 100644 --- a/plugins/GSdx/res/glsl/tfx_fs.glsl +++ b/plugins/GSdx/res/glsl/tfx_fs.glsl @@ -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 diff --git a/plugins/GSdx/res/glsl_source.h b/plugins/GSdx/res/glsl_source.h index 0cbe96af57..dc67ca2bb5 100644 --- a/plugins/GSdx/res/glsl_source.h +++ b/plugins/GSdx/res/glsl_source.h @@ -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"