Move calculation of normalized position for the vignette into the vertex shader.
[movit] / vignette_effect.frag
1 // A simple, circular vignette, with a cosĀ² falloff.
2         
3 uniform float PREFIX(inv_radius);
4 varying vec2 PREFIX(normalized_pos);
5
6 vec4 FUNCNAME(vec2 tc) {
7         vec4 x = LAST_INPUT(tc);
8
9         const float pihalf = 0.5 * 3.14159265358979324;
10
11         float dist = (length(PREFIX(normalized_pos)) - PREFIX(inner_radius)) * PREFIX(inv_radius);
12         float linear_falloff = clamp(dist, 0.0, 1.0) * pihalf;
13         float falloff = cos(linear_falloff) * cos(linear_falloff);
14         x.rgb *= vec3(falloff);
15
16         return x;
17 }