]> git.sesse.net Git - movit/blobdiff - blur_effect.frag
Factorize the code to compute sampling points for bilinear sampling into a shared...
[movit] / blur_effect.frag
index bfa1d16de06386ffd57297e9996668abea40bd1f..c6e4cf5465e7cbf62178edd8e231d8c962b8c1d2 100644 (file)
@@ -1,17 +1,14 @@
-// A simple, very stupid horizontal blur. Will be fixed soonish.
+// A simple unidirectional blur.
+
+#define NUM_TAPS 16
+
+uniform vec4 PREFIX(samples)[NUM_TAPS + 1];
 
 vec4 FUNCNAME(vec2 tc) {
-       vec4 x = LAST_INPUT(tc);
-       return
-               vec4(0.1) * LAST_INPUT(tc + vec2(-0.010f, 0.0)) +
-               vec4(0.1) * LAST_INPUT(tc + vec2(-0.008f, 0.0)) +
-               vec4(0.1) * LAST_INPUT(tc + vec2(-0.006f, 0.0)) +
-               vec4(0.1) * LAST_INPUT(tc + vec2(-0.004f, 0.0)) +
-               vec4(0.2) * LAST_INPUT(tc + vec2(-0.002f, 0.0)) +
-               vec4(0.3) * LAST_INPUT(tc + vec2(-0.000f, 0.0)) +
-               vec4(0.2) * LAST_INPUT(tc + vec2( 0.002f, 0.0)) +
-               vec4(0.1) * LAST_INPUT(tc + vec2( 0.004f, 0.0)) +
-               vec4(0.1) * LAST_INPUT(tc + vec2( 0.006f, 0.0)) +
-               vec4(0.1) * LAST_INPUT(tc + vec2( 0.008f, 0.0)) +
-               vec4(0.1) * LAST_INPUT(tc + vec2( 0.010f, 0.0));
+       vec4 sum = vec4(PREFIX(samples)[0].z) * INPUT(tc);
+       for (int i = 1; i < NUM_TAPS + 1; ++i) {
+               vec4 sample = PREFIX(samples)[i];
+               sum += vec4(sample.z) * (INPUT(tc - sample.xy) + INPUT(tc + sample.xy));
+       }
+       return sum;
 }