
uniform sampler2D u_texture;
uniform float size;
varying vec2 v_texCoord;
varying vec4 v_fragmentColor;	
 
 // I've chosen this size because this will result in that every step will be one pixel wide if the u_texture texture is of size 512x512
 
void main(void){
	
	//gl_FragColor  = texture2D(u_texture,v_texCoord);
	float blurSize = 1.0/500;//1.0/400;
    vec4 sum = vec4(0.0);
 
   // blur in y (vertical)
   // take nine samples, with the distance blurSize between them
   sum += texture2D(u_texture, vec2(v_texCoord.x - 4.0*blurSize, v_texCoord.y)) * 0.05;
   sum += texture2D(u_texture, vec2(v_texCoord.x - 3.0*blurSize, v_texCoord.y)) * 0.09;
   sum += texture2D(u_texture, vec2(v_texCoord.x - 2.0*blurSize, v_texCoord.y)) * 0.12;
   sum += texture2D(u_texture, vec2(v_texCoord.x - blurSize, v_texCoord.y)) * 0.15;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y)) * 0.16;
   sum += texture2D(u_texture, vec2(v_texCoord.x + blurSize, v_texCoord.y)) * 0.15;
   sum += texture2D(u_texture, vec2(v_texCoord.x + 2.0*blurSize, v_texCoord.y)) * 0.12;
   sum += texture2D(u_texture, vec2(v_texCoord.x + 3.0*blurSize, v_texCoord.y)) * 0.09;
   sum += texture2D(u_texture, vec2(v_texCoord.x + 4.0*blurSize, v_texCoord.y)) * 0.05;
   
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y - 4.0*blurSize)) * 0.05;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y - 3.0*blurSize)) * 0.09;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y - 2.0*blurSize)) * 0.12;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y - blurSize)) * 0.15;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y)) * 0.16;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y + blurSize)) * 0.15;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y + 2.0*blurSize)) * 0.12;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y + 3.0*blurSize)) * 0.09;
   sum += texture2D(u_texture, vec2(v_texCoord.x, v_texCoord.y + 4.0*blurSize)) * 0.05;
  
	if(sum.a > 0.45){
		sum.a = 0.45;
	}
  
   gl_FragColor = sum;
 
 
 }