1
0
Fork 0
mirror of https://github.com/yshui/picom.git synced 2024-10-27 05:24:17 -04:00

backend: gl: don't add dither where it's not needed

If a pixel is perfectly representable as an 8-bit number, don't add
dither. Reduce artifacts where dither is unnecessary.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2022-11-30 12:13:09 +00:00
parent 1271839baf
commit d704e0f80e
No known key found for this signature in database
GPG key ID: D3A4405BE6CC17F4

View file

@ -201,7 +201,9 @@ const char dither_glsl[] = GLSL(330,
return bayer32; return bayer32;
} }
vec4 dither(vec4 c, vec2 coord) { vec4 dither(vec4 c, vec2 coord) {
return vec4(c + bayer(coord) / 255.0); vec4 residual = mod(c, 1.0 / 255.0);
vec4 dithered = vec4(greaterThan(residual, vec4(1e-4)));
return vec4(c + dithered * bayer(coord) / 255.0);
} }
); );
const char shadow_colorization_frag[] = GLSL(330, const char shadow_colorization_frag[] = GLSL(330,