// Basic HLSL shader
// Author : BlooV
// Date : 15.08.2011
//

float4x4 VPM    : register(c0);

// Vertex shader code
struct appdata {
       float4 Position : POSITION;
       float2 UV       : TEXCOORD0;
       float3 Normal   : NORMAL;
       float3 Tangent  : TANGENT;
       float3 Binormal : BINORMAL;
};

struct vertexOutput {
  float4	Position : POSITION;
  float2	TexCoord : TEXCOORD0;
};

vertexOutput std_VS(appdata Input){
  vertexOutput Output = (vertexOutput)0;
  Output.Position = mul(VPM, Input.Position);
  Output.TexCoord = Input.UV;
  return Output;
}

// Pixel shader code
sampler2D DiffuseMap : register(s0);

static const float offset [ 3 ] = {
	-0.014,
	 0.00,
	 0.014
};	

float4 std_PS(vertexOutput Input) : COLOR {
	float4 blurSample = 0.0;
	
	for ( int i = 0; i < 3; ++i ) {
		for ( int j = 0; j < 3; ++j ) {
			blurSample += tex2D( DiffuseMap, Input.TexCoord + float2( offset[ i ], offset[ j ] ) );
		}
	}

	return tex2D( DiffuseMap, Input.TexCoord ) + blurSample * 0.04;
}

// Compiler directives
technique main
{
  pass Pass0
  {
    VertexShader = compile vs_2_0 std_VS();
    PixelShader = compile ps_2_0 std_PS();
  }
};
