1
0
Fork 0
This repository has been archived on 2025-09-12. You can view files and clone it, but cannot push or open issues or pull requests.
honest-jam-2/fx/menu_vignette.shader
2021-08-07 06:55:58 +02:00

24 lines
590 B
GLSL

shader_type canvas_item;
uniform vec4 color: hint_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform float scale: hint_range(0.0, 10.0) = 0.5;
float noise(vec2 co) {
return fract(sin(dot(co, vec2(12.9898,78.233))) * 43758.5453);
}
void fragment() {
vec2 dvec = abs(vec2(0.5, 0.5) - SCREEN_UV);
float d = max(dvec.x, dvec.y);
float l = length(dvec);
d = mix(d, l, smoothstep(-0.15, 0.25, l - d));
float fade = smoothstep(0.25, 0.9, d) * 4.0;
float vignette = fade * scale;
float dithered = vignette + (noise(SCREEN_UV) * 0.05);
COLOR = color;
COLOR.a *= clamp(dithered, 0.0, 1.0);
}