]> git.sesse.net Git - movit/blob - fft_pass_effect.frag
Add some asserts to EffectChain::execute_phase, so that we do not inadvertedly insert...
[movit] / fft_pass_effect.frag
1 // DIRECTION_VERTICAL will be #defined to 1 if we are doing a vertical FFT,
2 // and 0 otherwise.
3
4 // Implicit uniforms:
5 // uniform float PREFIX(num_repeats);
6 // uniform sampler2D PREFIX(support_tex);
7
8 vec4 FUNCNAME(vec2 tc) {
9 #if DIRECTION_VERTICAL
10         vec4 support = tex2D(PREFIX(support_tex), vec2(tc.y * PREFIX(num_repeats), 0.0));
11         vec4 c1 = INPUT(vec2(tc.x, tc.y + support.x));
12         vec4 c2 = INPUT(vec2(tc.x, tc.y + support.y));
13 #else
14         vec4 support = tex2D(PREFIX(support_tex), vec2(tc.x * PREFIX(num_repeats), 0.0));
15         vec4 c1 = INPUT(vec2(tc.x + support.x, tc.y));
16         vec4 c2 = INPUT(vec2(tc.x + support.y, tc.y));
17 #endif
18         // Two complex additions and multiplications in parallel; essentially
19         //
20         //   result.xy = c1.xy + twiddle * c2.xy
21         //   result.zw = c1.zw + twiddle * c2.zw
22         //
23         // where * is complex multiplication.
24         return c1 + support.z * c2 + support.w * vec4(-c2.y, c2.x, -c2.w, c2.z);
25 }
26
27 #undef DIRECTION_VERTICAL