// All content © 2010-2011 DigiPen (USA) Corporation, all rights reserved.

//Fragment shader to perform horizontal Gaussian blur

#version 150

// ---------------------------------------------------------------------------
// consts

float WEIGHTS[7]; 
const float NORM_INV = 1.316129; //1.0/WEIGHTS

// ---------------------------------------------------------------------------
//uniforms

uniform sampler2D	uTexture; //texture to be sampled

// ---------------------------------------------------------------------------
// from vs

in float			vStep;
in vec2				vTexCoord;

// ---------------------------------------------------------------------------

out vec4			out_Color;

void main()
{
	// Gaussian blur function with standard deviation of 3
	WEIGHTS[0] = 0.080929; //G(-3)
	WEIGHTS[1] = 0.106642; //G(-2)
	WEIGHTS[2] = 0.125841; //G(-1)
	WEIGHTS[3] = 0.13298; //G(0)
	WEIGHTS[4] = 0.125841; //G(1)
	WEIGHTS[5] = 0.106642; //G(2)
	WEIGHTS[6] = 0.080929; //G(3)

	vec4 color = vec4( 0.0, 0.0, 0.0, 0.0 );

	vec2 texCoord = vec2( vTexCoord.s - vStep * 3, vTexCoord.t );
	color += texture( uTexture, texCoord ) * WEIGHTS[0];

	texCoord.x = vTexCoord.s - vStep * 2;
	color += texture( uTexture, texCoord ) * WEIGHTS[1];

	texCoord.x = vTexCoord.s - vStep;
	color += texture( uTexture, texCoord ) * WEIGHTS[2];

	texCoord.x = vTexCoord.s;
	color += texture( uTexture, texCoord ) * WEIGHTS[3];

	texCoord.x = vTexCoord.s + vStep;
	color += texture( uTexture, texCoord ) * WEIGHTS[4];

	texCoord.x = vTexCoord.s + vStep * 2;
	color += texture( uTexture, texCoord ) * WEIGHTS[5];

	texCoord.x = vTexCoord.s + vStep * 3;
	color += texture( uTexture, texCoord ) * WEIGHTS[6];

	//normalize to prevent darkening/brightening
	out_Color = color * NORM_INV;
}





