-
Notifications
You must be signed in to change notification settings - Fork 2
/
radialBlur.glsl
37 lines (30 loc) · 999 Bytes
/
radialBlur.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* Radial Blur
*/
#pragma shaderfilter set density__description Density
#pragma shaderfilter set density__step 0.01
#pragma shaderfilter set density__default 0.2
#pragma shaderfilter set density__min 0.0
#pragma shaderfilter set density__max 0.5
#pragma shaderfilter set density__slider true
#pragma shaderfilter set zoom__description Zoom
#pragma shaderfilter set zoom__step 0.01
#pragma shaderfilter set zoom__default 1.0
#pragma shaderfilter set zoom__min 1.0
#pragma shaderfilter set zoom__max 2.0
#pragma shaderfilter set zoom__slider true
uniform float density;
uniform float zoom;
vec4 render(vec2 uv) {
int samples = 30;
vec2 deltaTexCoord = uv - vec2(0.5,0.5);
float zoom2 = zoom * -0.5 + 1.5;
vec2 texCoo = (uv - 0.5) * zoom2 + 0.5;
deltaTexCoord *= 1.0 / float(samples) * density;
vec4 sample = vec4(1.0);
float decay = 1.0;
for(int i=0; i < samples ; i++) {
texCoo -= deltaTexCoord;
sample += texture2D(image, texCoo);
}
return vec4(sample/float(samples));
}