fixed A2C by making sure we use the absolute values of the derivatives

This commit is contained in:
myT 2019-12-26 16:26:12 +01:00
parent 9cb02a32bf
commit e16804a0cb
2 changed files with 5 additions and 5 deletions

View file

@ -101,8 +101,8 @@ float CorrectAlpha(float threshold, float alpha, float2 tc)
{
float w, h;
texture0.GetDimensions(w, h);
float dx = max(ddx(tc.x * w), 0.001);
float dy = max(ddy(tc.y * h), 0.001);
float dx = max(abs(ddx(tc.x * w)), 0.001);
float dy = max(abs(ddy(tc.y * h)), 0.001);
float dxy = max(dx, dy); // apply the smallest boost
float scale = max(1.0 / dxy, 1.0);
float ac = threshold + (alpha - threshold) * scale;

View file

@ -342,9 +342,9 @@ static const char* generic_fs =
"#if CNQ3_A2C\n"
"float CorrectAlpha(float threshold, float alpha, vec2 tc)\n"
"{\n"
" ivec2 size = textureSize(texture1, 0);\n"
" float dx = max(dFdx(tc.x * float(size.x)), 0.001);\n"
" float dy = max(dFdy(tc.y * float(size.y)), 0.001);\n"
" vec2 size = vec2(textureSize(texture1, 0));\n"
" float dx = max(abs(dFdx(tc.x * size.x)), 0.001);\n"
" float dy = max(abs(dFdy(tc.y * size.y)), 0.001);\n"
" float dxy = max(dx, dy); // apply the smallest boost\n"
" float scale = max(1.0 / dxy, 1.0);\n"
" float ac = threshold + (alpha - threshold) * scale;\n"