uniform vec2 resolution;

uniform sampler2D u_texture;
uniform sampler2D blur_texture;

uniform float blur_alpha;

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;

void main()
{

	vec4 color = vec4(0);

	vec2 inverted_coordinate = vec2(v_texCoord.x, 1.0 - v_texCoord.y);
	vec4 color_in_hud_texture = texture2D(blur_texture, inverted_coordinate);
	if(color_in_hud_texture.a > 0)
	{
		color = texture2D(u_texture, v_texCoord);
	}

	 gl_FragColor = color * blur_alpha;

		//Blur target texture if framgent contains color;
	//ie. this place has some gui element in it
/*	 vec4 color = texture2D(u_texture, v_texCoord);
	
	 if(color.a > 0)
	 {*/
/*		float pixel_size = 1.0/resolution.y;

		vec4 sum = vec4(0);
		
		sum += texture2D(blur_texture, vec2(blur_texture.x, v_texCoord.y - 4.0*pixel_size)) * 0.06;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y - 3.0*pixel_size)) * 0.09;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y - 2.0*pixel_size)) * 0.12;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y - pixel_size))* 0.15;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y)) * 0.16;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y + pixel_size)) * 0.15;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y + 2.0*pixel_size)) * 0.12;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y + 3.0*pixel_size)) * 0.09;
		sum += texture2D(blur_texture, vec2(v_texCoord.x, v_texCoord.y + 4.0*pixel_size)) * 0.06;
		
		//sum.a = 1.0;
		gl_FragColor = sum;*/
/*	 }
	 else
	 {
		 gl_FragColor = vec4(0);
	 }*/


}