precision highp float;
#define iChannel0 inputImageTexture
#define texture(a,b) texture2D(a,fract(b))
#define fragColor gl_FragColor
varying highp vec2 textureCoordinate;
varying highp vec2 textureCoordinate2;

uniform sampler2D inputImageTexture;
uniform sampler2D inputImageTexture2;

uniform float iTime;

uniform highp vec2 iResolution;

float insideBox(vec2 v, vec2 bottomLeft, vec2 topRight, vec2 smoothv) {
    vec2 s = smoothstep(bottomLeft - smoothv * 0.5, bottomLeft + smoothv * 0.5, v) - smoothstep(topRight - smoothv * 0.5, topRight + smoothv * 0.5, v);
    return s.x * s.y;
}

void main()
{
    highp vec2 uv = textureCoordinate;

    vec2 vv = uv * 1.5 - 0.25;

    highp vec4 edgeColor = vec4(vec3(0.0), 1.0);

    lowp vec2 wv = vec2(0.02, 0.02 * iResolution.x / iResolution.y);
    highp vec4 color1 = mix(edgeColor, texture(iChannel0, vv), insideBox(vv, wv, vec2(1.0) - wv, wv * 0.8));

    lowp vec2 wv0 = wv / 4.0;
    lowp vec2 uv0 = uv;// mod(uv, 1.0 / 4.0) + vec2(3. / 4.);
    highp vec4 color0 = mix(edgeColor, texture(iChannel1, uv0), insideBox(mod(uv, 1.0 / 4.0), wv0, vec2(1.0) - wv0, wv0));

    fragColor = mix(color0, color1, insideBox(vv,vec2(0.0),vec2(1.0),vec2(0.01)));
}