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

vec3 rainbow(float t){
    vec3 d= vec3(0.0,0.33,0.67);
    return 0.5+0.5*cos(6.28318*(t+d));
}

void main()
{
    float amount = 0.4;
    float offset = 0.5;
    //vec2 uv = fragCoord/iResolution.xy;
    highp vec2 uv = textureCoordinate;
    vec3 origCol = texture(iChannel0,uv).rgb;
    vec2 off = origCol.rg - 0.5;
    vec2 p = uv;
    p+=off + offset;
    vec3 rb = rainbow((p.x+p.y+iTime * 2.0)*0.5);
    vec3 col = mix(origCol,rb,amount);
    fragColor = vec4(col,1.0);
}