#define iChannel0 inputImageTexture
#define texture(a,b) texture2D(a,fract(b))
#define fragColor gl_FragColor
precision highp float;

varying highp vec2 textureCoordinate;

uniform sampler2D inputImageTexture;

uniform highp float iTime;

uniform highp vec2 iResolution;

// highp vec2 fragCoord = textureCoordinate * iResolution;

#define Sample 5.
#define _2PI 6.2831853072

float rand(float id){
    return fract(sin(id*400.) * 4375.5453);
}

highp vec2 blur(highp vec2 u)
{
highp vec3 col = vec3(0.);
for (float i = 0.; i < Sample; ++i) {
float rad = i/Sample*_2PI;
highp vec2 offset = vec2(cos(rad),sin(rad)) ;
offset *= rand(u.x+u.y);
u -= offset*0.015;
}
return u;
//    if(iMouse.z>0.){
//        f = texture(iChannel1,u);
//    }
//    else{
//        f = texture(iChannel0,u);
//    }
}

void main() {
    highp vec2 uv = textureCoordinate;

    float time = (0.5 - abs(mod(iTime, 1.) - 0.5) - 0.1) * 30.;
    for (float i = 0.; i < time; ++i) {
        uv = blur(uv);
    }
    fragColor = texture(iChannel0,uv);
}