#version 300 es
precision highp float;

uniform sampler2D uMainTex;

in vec4 uv01;
in vec4 uv23;
in vec2 vUV;

out vec4 fragColor;

void main() {

    float edgeMin = 0.001;
    float edgeMax = 0.999;

    vec4 uv011 = clamp(uv01, edgeMin, edgeMax);
    vec4 uv231 = clamp(uv23, edgeMin, edgeMax);

    vec4 sum = texture(uMainTex, vUV) * 4.0;
    sum += texture(uMainTex, uv011.xy);
    sum += texture(uMainTex, uv011.zw);
    sum += texture(uMainTex, uv231.xy);
    sum += texture(uMainTex, uv231.zw);

    fragColor = sum * 0.125;
    //fragColor = texture(uMainTex, vUV);
}