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

View File

@@ -201,7 +201,9 @@ const char dither_glsl[] = GLSL(330,
return bayer32;
}
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,