
// ------- UNIFORMS (SHADER CONSTS) -------
uniform sampler2D	hu_sSceneTexture0;
uniform sampler2D	u_sTexture1; // mask

// ------- INTERPOLATORS (SHADER INPUTS) -------
varying vec2		v_vTex[9];

// ------- FUNCTIONS -------

void main(void)
{
	vec4 result;
	float mask = texture2D(u_sTexture1, v_vTex[4]).x;

	if (mask == 0.0)
	{
		result = texture2D(hu_sSceneTexture0, v_vTex[4]);
	}
	else
	{
		// take nine samples
		vec4 sum = texture2D(hu_sSceneTexture0, v_vTex[0]) * 0.05;
		sum += texture2D(hu_sSceneTexture0, v_vTex[1]) * 0.09;
		sum += texture2D(hu_sSceneTexture0, v_vTex[2]) * 0.12;
		sum += texture2D(hu_sSceneTexture0, v_vTex[3]) * 0.15;
		sum += texture2D(hu_sSceneTexture0, v_vTex[4]) * 0.16;
		sum += texture2D(hu_sSceneTexture0, v_vTex[5]) * 0.15;
		sum += texture2D(hu_sSceneTexture0, v_vTex[6]) * 0.12;
		sum += texture2D(hu_sSceneTexture0, v_vTex[7]) * 0.09;
		sum += texture2D(hu_sSceneTexture0, v_vTex[8]) * 0.05;

		result = sum;
	}
	
	gl_FragColor = result;
}
