Debian Codegraph @

shaders/src/vignette.fs

raw
1 //------------------------------------------------------------------------------
2 // Vignette
3 //------------------------------------------------------------------------------
4
5 // Applies a vignette effect
6 // color: source color to apply the vignette on top of
7 // uv: viewport coordinates
8 // vignette: pre-computed parameters midPoint, radius, aspect and feather
9 // vignetteColor: color of the vignette effect
10 vec3 vignette(const vec3 color, const highp vec2 uv, const vec4 vignette, const vec4 vignetteColor) {
11 float midPoint = vignette.x;
12 float radius = vignette.y;
13 float aspect = vignette.z;
14 float feather = vignette.w;
15
16 vec2 distance = abs(uv - 0.5) * midPoint;
17 distance.x *= aspect;
18 distance = pow(saturate(distance), vec2(radius));
19
20 float amount = pow(saturate(1.0 - dot(distance, distance)), feather * 5.0);
21 return color * mix(vignetteColor.rgb, vec3(1.0), amount);
22 }