lightbox: Fix banding issues with the vignette shader

Just as https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/352
did for the MetaBackgroundActor in mutter, let's fix the vignette shader
in gnome-shell, too.

Based on a patch originally propsed by Nikita Churaev, see
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/59.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3942
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2133>
This commit is contained in:
Jonas Dreßler 2022-01-27 17:48:20 +01:00
parent f9037f5889
commit 81f62e9df8

View File

@ -11,16 +11,20 @@ var VIGNETTE_SHARPNESS = 0.7;
const VIGNETTE_DECLARATIONS = ' \ const VIGNETTE_DECLARATIONS = ' \
uniform float brightness; \n\ uniform float brightness; \n\
uniform float vignette_sharpness;\n'; uniform float vignette_sharpness; \n\
float rand(vec2 p) { \n\
return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453123); \n\
} \n';
const VIGNETTE_CODE = ' \ const VIGNETTE_CODE = ' \
cogl_color_out.a = cogl_color_in.a; \n\ cogl_color_out.a = cogl_color_in.a; \n\
cogl_color_out.rgb = vec3(0.0, 0.0, 0.0); \n\ cogl_color_out.rgb = vec3(0.0, 0.0, 0.0); \n\
vec2 position = cogl_tex_coord_in[0].xy - 0.5; \n\ vec2 position = cogl_tex_coord_in[0].xy - 0.5; \n\
float t = length(2.0 * position);\n\ float t = clamp(length(1.41421 * position), 0.0, 1.0); \n\
t = clamp(t, 0.0, 1.0);\n\
float pixel_brightness = mix(1.0, 1.0 - vignette_sharpness, t); \n\ float pixel_brightness = mix(1.0, 1.0 - vignette_sharpness, t); \n\
cogl_color_out.a = cogl_color_out.a * (1.0 - pixel_brightness * brightness);'; cogl_color_out.a *= 1.0 - pixel_brightness * brightness; \n\
cogl_color_out.a += (rand(position) - 0.5) / 100.0; \n';
var RadialShaderEffect = GObject.registerClass({ var RadialShaderEffect = GObject.registerClass({
Properties: { Properties: {