precision highp float;
uniform sampler2D u_image;
uniform float u_scale;
uniform vec2 u_texSize;
varying vec2 v_texCoord;

void main() {
  vec2 textureSize = 1. / u_texSize;
  vec2 f = fract(v_texCoord * textureSize + .5);
  vec2 uv = (floor(v_texCoord * textureSize - .5) + .5) / textureSize;

  vec4 tl = texture2D(u_image, uv);
  vec4 tr = texture2D(u_image, uv + vec2(u_texSize.x, 0.0));
  vec4 bl = texture2D(u_image, uv + vec2(0.0, u_texSize.y));
  vec4 br = texture2D(u_image, uv + vec2(u_texSize.x, u_texSize.y));
  vec4 tA = mix(tl, tr, f.x);
  vec4 tB = mix(bl, br, f.x);
  vec4 result = mix(tA, tB, f.y);
  gl_FragColor = result;
}