X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=blur_effect.frag;h=df0aa4649608c9f67f684350a3b8f7248a472f5e;hp=bfa1d16de06386ffd57297e9996668abea40bd1f;hb=47b4160062cdaa53b7d49d7f99ce2c686f02cff8;hpb=b5e3174594efe9a920621a68d3b28f5e44676d03 diff --git a/blur_effect.frag b/blur_effect.frag index bfa1d16..df0aa46 100644 --- a/blur_effect.frag +++ b/blur_effect.frag @@ -1,17 +1,26 @@ -// A simple, very stupid horizontal blur. Will be fixed soonish. +// A simple un.directional blur. +// DIRECTION_VERTICAL will be #defined to 1 if we are doing a vertical blur, +// 0 otherwise. + +#define NUM_TAPS 16 + +uniform vec2 PREFIX(samples)[NUM_TAPS / 2 + 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].y) * INPUT(tc); + for (int i = 1; i < NUM_TAPS / 2 + 1; ++i) { + vec2 sample = PREFIX(samples)[i]; + vec2 sample1_tc = tc, sample2_tc = tc; +#if DIRECTION_VERTICAL + sample1_tc.y -= sample.x; + sample2_tc.y += sample.x; +#else + sample1_tc.x -= sample.x; + sample2_tc.x += sample.x; +#endif + sum += vec4(sample.y) * (INPUT(sample1_tc) + INPUT(sample2_tc)); + } + return sum; } + +#undef DIRECTION_VERTICAL