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

vec2 rotate(highp vec2 pv, highp vec2 ov, float a) {
    vec2 p;
    p.x = (pv.x - ov.x)*cos(a) - (pv.y - ov.y)*sin(a) + ov.x;
    p.y = (pv.x - ov.x)*sin(a) + (pv.y - ov.y)*cos(a) + ov.y;
    return p;
}

void main()
{
    vec2 uv = textureCoordinate;
    uv -= 0.5;
    uv *= 1.1;

    uv = rotate(uv * iResolution.xy, vec2(0.0), -0.3) / iResolution.xy;

    float i = floor(uv.x) + floor(uv.y);
    i = 1.0 - mod(i, 2.0) ;

    uv = rotate(uv * iResolution.xy, vec2(0.0), 3.14159 * 0.5 * i) / iResolution.xy;

    fragColor = texture2D(iChannel0, fract(uv));
}
