///FOR BLURRING A WHOLE BITMAP IN TWO STAGES

#ifdef GL_ES
precision mediump float;
#endif
uniform sampler2D al_tex;
uniform bool al_use_tex;
varying vec4 varying_color;
varying vec2 varying_texcoord;


uniform bool vertical;
//float alpha;


vec4 blur5(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
  vec4 color = vec4(0.0);
  vec2 off1 = vec2(1.3333333333333333) * direction;
  color += texture2D(image, uv) * 0.29411764705882354;
  color += texture2D(image, uv + (off1 / resolution)) * 0.35294117647058826;
  color += texture2D(image, uv - (off1 / resolution)) * 0.35294117647058826;
  return color; 
}
vec4 blur13(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
  vec4 color = vec4(0.0);
  vec2 off1 = vec2(1.411764705882353) * direction;
  vec2 off2 = vec2(3.2941176470588234) * direction;
  vec2 off3 = vec2(5.176470588235294) * direction;
  color += texture2D(image, uv) * 0.1964825501511404;
  color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344;
  color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344;
  color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732;
  color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732;
  color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057;
  color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057;
  return color;
}
void main()
{

//    gl_FragColor = varying_color * texture2D(al_tex, varying_texcoord);
//    gl_FragColor.g =0;
//    gl_FragColor.b =0;
    

	    if (vertical) {
		  gl_FragColor = varying_color * blur5(al_tex, varying_texcoord, vec2(1280,720), vec2(0,1));
		} else {
		  gl_FragColor = varying_color * blur5(al_tex, varying_texcoord, vec2(1280,720), vec2(1,0));
		}   

		//gl_FragColor.a = alpha;
    

}

