]> git.sesse.net Git - movit/blob - vignette_effect.frag
Make the ResourcePool hold FBOs as a per-context resource.
[movit] / vignette_effect.frag
1 // A simple, circular vignette, with a cosĀ² falloff.
2         
3 uniform float PREFIX(pihalf_div_radius);
4 uniform vec2 PREFIX(aspect_correction);
5 uniform vec2 PREFIX(flipped_center);
6
7 vec4 FUNCNAME(vec2 tc) {
8         vec4 x = INPUT(tc);
9
10         const float pihalf = 0.5 * 3.14159265358979324;
11
12         vec2 normalized_pos = (tc - PREFIX(flipped_center)) * PREFIX(aspect_correction);
13         float dist = (length(normalized_pos) - PREFIX(inner_radius)) * PREFIX(pihalf_div_radius);
14         float linear_falloff = clamp(dist, 0.0, pihalf);
15         float falloff = cos(linear_falloff) * cos(linear_falloff);
16         x.rgb *= vec3(falloff);
17
18         return x;
19 }