uniform sampler2D tex;

uniform float blurSize;
uniform float blurAmount;
 
void main(void)
{
	vec2 vTexCoord = gl_TexCoord[0].st;
	vec4 sum = vec4(0.0);

	float blur = blurAmount;
	sum = texture2D( tex, vec2( vTexCoord.x, vTexCoord.y ) ) * blur;
	float d = 0.0;
	float t = blur;
	for ( float i = 0.0; i <= blurAmount; i++ )
		{
		d += blurSize;
		blur -= 1.0;
		sum += texture2D( tex, vec2( max( vTexCoord.x - d, 0.0 ), vTexCoord.y ) ) * float( blur );
		sum += texture2D( tex, vec2( min( vTexCoord.x + d, 1.0 ), vTexCoord.y ) ) * float( blur );
		t += blur * 2.0;
		}
	sum /= t;

	gl_FragColor = sum;
}
