/* Start File Header -------------------------------------------------------
Copyright (C) 2010 DigiPen Institute of Technology.
Reproduction or disclosure of this file or its contents without the prior written consent of DigiPen Institute of Technology is prohibited.
File Name: HorizontalBlur.fx
Purpose: This shader does a horizontal gaussian blur pass.
Authors: Robert Francis - 100%
- End File Header --------------------------------------------------------*/

texture tex0;
float height;
float width;

sampler Samp
{
    Texture   = tex0;
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
    AddressU = BORDER;
    AddressV = BORDER;
    AddressW = BORDER; 
    BorderColor = 1.0f; 
};

struct VS_INPUT
{
	float3 position : POSITION;
	float2 tex0 : TEXCOORD0;
};

struct VS_OUTPUT
{
	float4 position : POSITION;
	float2 tex0 : TEXCOORD0;
};

const float BlurWeights[7] = 
{
    0.064759,
    0.120985,
    0.176033,
    0.199471,
    0.176033,
    0.120985,
    0.064759,
};

float4 Pixel (VS_INPUT IN) : COLOR
{
	float4 color = float4(0,0,0,0);
	float invw = 1.0f / width;
	
	for(int i = 0; i < 7; ++i)
	{
	  color += tex2D(Samp, float2(IN.tex0.x + (i - 3) * invw, IN.tex0.y)) * BlurWeights[i];
	}
	return color;
}

VS_OUTPUT Vertex(VS_INPUT IN) 
{
	VS_OUTPUT OUT;
	OUT.position = float4(IN.position, 1.0);
	OUT.tex0 = IN.tex0;
	return OUT;
}

technique Technique0
{
	pass Pass0
	{
		VertexShader = compile vs_2_0 Vertex();
		PixelShader = compile ps_2_0 Pixel();
		ZEnable = true;
		AlphaBlendEnable = false;
	}
}