precision highp float;

uniform sampler2D u_Texture; // input (unblurred) image
varying vec2 v_TexCoords;
varying vec2 v_Offset;

uniform mat4 u_STMatrix;

vec4 sampleTex2d(sampler2D tex, mat4 tr, vec2 uv) {
  return texture2D(tex, (tr*vec4(uv,0,1)).xy);
}

void main() {
  vec2 offset = v_Offset;
  vec4 color = vec4(0.);
  vec2 off1 = vec2(1.411764705882353) * offset;
  vec2 off2 = vec2(3.2941176470588234) * offset;
  vec2 off3 = vec2(5.176470588235294) * offset;
  color += sampleTex2d(u_Texture, u_STMatrix, v_TexCoords) * .1964825501511404;
  color += sampleTex2d(u_Texture, u_STMatrix, v_TexCoords + (off1)) * .2969069646728344;
  color += sampleTex2d(u_Texture, u_STMatrix, v_TexCoords - (off1)) * .2969069646728344;
  color += sampleTex2d(u_Texture, u_STMatrix, v_TexCoords + (off2)) * .09447039785044732;
  color += sampleTex2d(u_Texture, u_STMatrix, v_TexCoords - (off2)) * .09447039785044732;
  color += sampleTex2d(u_Texture, u_STMatrix, v_TexCoords + (off3)) * .010381362401148057;
  color += sampleTex2d(u_Texture, u_STMatrix, v_TexCoords - (off3)) * .010381362401148057;

  gl_FragColor = color;
}
