From e16804a0cb54aaf95444051805d5a8818fda172e Mon Sep 17 00:00:00 2001 From: myT Date: Thu, 26 Dec 2019 16:26:12 +0100 Subject: [PATCH] fixed A2C by making sure we use the absolute values of the derivatives --- code/renderer/hlsl/generic.hlsl | 4 ++-- code/renderer/tr_backend_gl3.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/code/renderer/hlsl/generic.hlsl b/code/renderer/hlsl/generic.hlsl index 5cf0824..8f89a66 100644 --- a/code/renderer/hlsl/generic.hlsl +++ b/code/renderer/hlsl/generic.hlsl @@ -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; diff --git a/code/renderer/tr_backend_gl3.cpp b/code/renderer/tr_backend_gl3.cpp index 91c7b23..4fcf4cc 100644 --- a/code/renderer/tr_backend_gl3.cpp +++ b/code/renderer/tr_backend_gl3.cpp @@ -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"