
//uniform vec2 TexelSize;
uniform sampler2D u_texture;

/// Gets the Gaussian value in the first dimension.

/// param name="x">Distance from origin on the x-axis.
/// param name="deviation">Standard deviation.
/// returns>The gaussian value on the x-axis.


void main ()
{
	int Orientation = 1.0f;
	int BlurAmount = 5.0f;
	float BlurScale = 1.0f;
	float BlurStrength = 1.0f;
	vec2 TexelSize = vec(500,500);

	float vUv = 1.0f;
	// Locals
	float halfBlur = float(BlurAmount) * 0.5;
	vec4 colour = vec4(0.0);
	vec4 texColour = vec4(0.0);
	
	// Gaussian deviation
	float deviation = halfBlur * 0.35;
	deviation *= deviation;
	float strength = 1.0 - BlurStrength;
	
	if ( Orientation == 0 )
	{
		// Horizontal blur
		for (int i = 0; i < 10; ++i)
		{
			if ( i >= BlurAmount )
				break;
			
			float offset = float(i) - halfBlur;
			texColour = texture2D(u_texture, vUv + vec2(offset * TexelSize.x * BlurScale, 0.0)) * Gaussian(offset * strength, deviation);
			colour += texColour;
		}
	}
	else
	{
		// Vertical blur
		for (int i = 0; i < 10; ++i)
		{
			if ( i >= BlurAmount )
				break;
			
			float offset = float(i) - halfBlur;
			texColour = texture2D(u_texture, vUv + vec2(0.0, offset * TexelSize.y * BlurScale)) * Gaussian(offset * strength, deviation);
			colour += texColour;
		}
	}
	
	// Apply colour
	gl_FragColor = clamp(colour, 0.0, 1.0);
	gl_FragColor.w = 1.0;
}