//uniform float iTime;
uniform sampler2D colorMap;

uniform float angle;
uniform float amount; // 0.0-1920.0
uniform float width; // 0.0-0.5

vec2 rotateVector (vec2 vec, float ang)
{
    vec2 res = vec2(
        vec.x * cos(ang) - vec.y * sin(ang),
        vec.x * sin(ang) + vec.y * cos(ang)
    );
    return res;
}

//void mainImage( out vec4 fragColor, in vec2 fragCoord )
void main ()
{
    // Normalized pixel coordinates (from 0 to 1)
    //vec2 uv = fragCoord/iResolution.y;
    vec2 uv = gl_FragCoord.xy/1080.0;

    vec2 uv2=uv;
    uv2.x/=(1920.0/1080.0);
    
    uv-=vec2(0.5,0.5);
    //float angle=iTime/2.0;
    //angle=3.14/4.0;
    uv=rotateVector(uv,angle);
    uv-=vec2(0.5,0.5);
    
    vec2 move=vec2(1.0/1920.0,0.0);
    //float amount=sin(iTime*1.5)*250.0;
    move=rotateVector(move,-(angle+3.14/2.0));
    move.x/=(1920.0/1080.0);

    //float c = uv.x; c = mod(c, 0.2); c = step(c, 0.1);
    float c = uv.x; c = mod(c, width*2.0); c = step(c, width);

    if (c<1.0) move=-move;
    uv2+=move*amount;
    vec4 c2=texture2D(colorMap,uv2);

    if (uv2.x<0.0) c2=vec4(0.0);
    if (uv2.x>1.0) c2=vec4(0.0);
    if (uv2.y<0.0) c2=vec4(0.0);
    if (uv2.y>1.0) c2=vec4(0.0);

    //fragColor=vec4(c,0.0,0.0,1.0)/2.0+c2;
    //fragColor=c2;
	gl_FragColor=c2;
}