glsl: use rounding in convert 4 shader

It will avoid texture rouding error with negative number
This commit is contained in:
Gregory Hainaut 2015-07-24 21:56:15 +02:00
parent 7b9fa8fbe5
commit d191ae4aba
2 changed files with 4 additions and 12 deletions

View File

@ -77,7 +77,7 @@ layout(std140, binding = 15) uniform cb15
vec4 sample_c() vec4 sample_c()
{ {
return texture(TextureSampler, PSin_t ); return texture(TextureSampler, PSin_t);
} }
vec4 ps_crt(uint i) vec4 ps_crt(uint i)
@ -372,11 +372,7 @@ void ps_main3()
#ifdef ps_main4 #ifdef ps_main4
void ps_main4() void ps_main4()
{ {
// FIXME mod and fmod are different when value are negative SV_Target0 = mod(round(sample_c() * 255.0f), 256.0f) / 255.0f;
// output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255;
vec4 c = mod(sample_c() * 255.0f + 0.5f, 256.0f) / 255.0f;
SV_Target0 = c;
} }
#endif #endif

View File

@ -102,7 +102,7 @@ static const char* convert_glsl =
"\n" "\n"
"vec4 sample_c()\n" "vec4 sample_c()\n"
"{\n" "{\n"
" return texture(TextureSampler, PSin_t );\n" " return texture(TextureSampler, PSin_t);\n"
"}\n" "}\n"
"\n" "\n"
"vec4 ps_crt(uint i)\n" "vec4 ps_crt(uint i)\n"
@ -397,11 +397,7 @@ static const char* convert_glsl =
"#ifdef ps_main4\n" "#ifdef ps_main4\n"
"void ps_main4()\n" "void ps_main4()\n"
"{\n" "{\n"
" // FIXME mod and fmod are different when value are negative\n" " SV_Target0 = mod(round(sample_c() * 255.0f), 256.0f) / 255.0f;\n"
" // output.c = fmod(sample_c(input.t) * 255 + 0.5f, 256) / 255;\n"
" vec4 c = mod(sample_c() * 255.0f + 0.5f, 256.0f) / 255.0f;\n"
"\n"
" SV_Target0 = c;\n"
"}\n" "}\n"
"#endif\n" "#endif\n"
"\n" "\n"