#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;

const highp vec3 W = vec3(0.2125, 0.7154, 0.0721);

void main()
{
    highp vec2 uv = textureCoordinate;

    highp vec2 center = vec2(0.5);

    float l = length(uv - center);

    float c = (l - 0.2) * 120.0;
    c = max(c, 0.0);

    //highp vec4 result0 = vec4(0.);
    highp vec4 result1 = vec4(0.);
    //highp vec4 result2 = vec4(0.);
    int samples = 20;
    for (int i = 0; i < samples; i++)
    {
        float q = float(i)/float(samples) * c;
        highp vec2 offset = (center - uv) * q * 0.004;
        //result0 += texture2D(iChannel0, uv - offset * 0.5) / float(samples);
        result1 += texture2D(iChannel0, uv + offset * 0.5) / float(samples);
        //result2 += texture2D(iChannel0, uv + offset * 1.2) / float(samples);
    }

    //fragColor.r = dot(result0.rgb, W);

    //fragColor.g = dot(result1.rgb, W);

    //fragColor.b = dot(result2.rgb, W);

    fragColor.rgb = vec3(dot(result1.rgb, W));

    fragColor.a = 1.0;
}
