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
This commit is contained in:
Yuxuan Shui 2023-05-08 14:58:20 +01:00
parent 05ef18d78f
commit 3aed5599c3
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
1 changed files with 2 additions and 1 deletions

View File

@ -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);
}
);