From 3aed5599c3f73cbfa53b0249795e76ab07cf9ecd Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 8 May 2023 14:58:20 +0100 Subject: [PATCH] glx: calculate residual in both directions We only considered residual in the positive direction, i.e. we would set dithering to zero if the color is (whole number + 0.0001). But we should also set dithering to zero if color is (whole number - 0.0001). Fixes #1064 --- src/backend/gl/shaders.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backend/gl/shaders.c b/src/backend/gl/shaders.c index 90f636b7..96e385b1 100644 --- a/src/backend/gl/shaders.c +++ b/src/backend/gl/shaders.c @@ -202,7 +202,8 @@ const char dither_glsl[] = GLSL(330, } vec4 dither(vec4 c, vec2 coord) { vec4 residual = mod(c, 1.0 / 255.0); - vec4 dithered = vec4(greaterThan(residual, vec4(1e-4))); + residual = min(residual, vec4(1.0 / 255.0) - residual); + vec4 dithered = vec4(greaterThan(residual, vec4(1.0 / 65535.0))); return vec4(c + dithered * bayer(coord) / 255.0); } );