]> git.sesse.net Git - movit/blob - vignette_effect.frag
Parametrize BM_DeinterlaceEffect so that we have both grayscale and BGRA.
[movit] / vignette_effect.frag
1 // A simple, circular vignette, with a cosĀ² falloff.
2
3 // Implicit uniforms:
4 // uniform float PREFIX(pihalf_div_radius);
5 //
6 // uniform vec2 PREFIX(aspect_correction);
7 // uniform vec2 PREFIX(flipped_center);
8
9 vec4 FUNCNAME(vec2 tc) {
10         vec4 x = INPUT(tc);
11
12         const float pihalf = 0.5 * 3.14159265358979324;
13
14         vec2 normalized_pos = (tc - PREFIX(flipped_center)) * PREFIX(aspect_correction);
15         float dist = (length(normalized_pos) - PREFIX(inner_radius)) * PREFIX(pihalf_div_radius);
16         float linear_falloff = clamp(dist, 0.0, pihalf);
17         float falloff = cos(linear_falloff) * cos(linear_falloff);
18         x.rgb *= vec3(falloff);
19
20         return x;
21 }