precision highp float;
#define iChannel0 inputImageTexture
#define texture(a,b) texture2D(a,fract(b))
#define fragColor gl_FragColor
varying highp vec2 textureCoordinate;
uniform sampler2D inputImageTexture;
uniform highp float scale;
float pattern(vec2 loc,float scale){
    float angle = 1.57;
    float s = sin(angle);
    float c = cos(angle);
    vec2 tex = loc*vec2(256.0,256.0)-vec2(0.5,0.5);
    vec2 point = vec2(c*tex.x - s*tex.y,s*tex.x+c*tex.y) * scale;
    return (sin(point.x)*sin(point.y) * 4.0);
}
void main(){
    highp vec2 uv = textureCoordinate;
    vec4 origCol = texture(iChannel0,uv);
    float average = (origCol.r+origCol.g+origCol.b)/3.0;
    fragColor = vec4( vec3(average * 10.0 - 5.0 + pattern(uv,scale)), origCol.a);
}
