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

//Fragment shader to perform vertical 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
uniform float		uMultiplier; //multiplier to add to final value

// ---------------------------------------------------------------------------
// varyings

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, vTexCoord.t - vStep * 3 );
	color += texture( uTexture, texCoord ) * WEIGHTS[0];

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

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

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

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

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

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

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





