/* COMPATIBILITY 
   - HLSL compilers
   - Cg   compilers
*/

#pragma parameter BLUR_FACTOR "Blur Factor"           0.025 0.001 0.050 0.001

#ifdef PARAMETER_UNIFORM
uniform float BLUR_FACTOR;
#else
#define BLUR_FACTOR 0.0025
#endif

const float2 samples[12]
=	{
		-0.326212, -0.405805,
		-0.840144, -0.073580,
		-0.695914,  0.457137,
		-0.203345,  0.620716,
		 0.962340, -0.194983,
		 0.473434, -0.480026,
		 0.519456,  0.767022,
		 0.185461, -0.893124,
		 0.507431,  0.064425,
		 0.896420,  0.412458,
		-0.321940, -0.932615,
		-0.791559, -0.597705
	};

struct out_vertex {
	float4 position : POSITION;
	float4 texCoord : TEXCOORD0;
	float4 t1 : TEXCOORD1;
	float4 t2 : TEXCOORD2;
	float4 t3 : TEXCOORD3;
	float4 t4 : TEXCOORD4;
	float4 t5 : TEXCOORD5;
	float4 t6 : TEXCOORD6;
};

struct input
{
  float2 video_size;
  float2 texture_size;
  float2 output_size;
  float frame_count;
  float frame_direction;
  float frame_rotation;
};


/*    VERTEX_SHADER    */
out_vertex main_vertex
(
	float4 position	: POSITION,
	float2 tex      : TEXCOORD0,

   	uniform float4x4 modelViewProj
)
{
	out_vertex OUT = {
		mul(modelViewProj, position),
		float4(tex,0.0,0.0),
		float4(tex,tex) + float4(BLUR_FACTOR * samples[ 0], BLUR_FACTOR * samples[ 1]),
		float4(tex,tex) + float4(BLUR_FACTOR * samples[ 2], BLUR_FACTOR * samples[ 3]),
		float4(tex,tex) + float4(BLUR_FACTOR * samples[ 4], BLUR_FACTOR * samples[ 5]),
		float4(tex,tex) + float4(BLUR_FACTOR * samples[ 6], BLUR_FACTOR * samples[ 7]),
		float4(tex,tex) + float4(BLUR_FACTOR * samples[ 8], BLUR_FACTOR * samples[ 9]),
		float4(tex,tex) + float4(BLUR_FACTOR * samples[10], BLUR_FACTOR * samples[11]),
	};

	return OUT;
}

float4 main_fragment(in out_vertex VAR, uniform input IN, uniform sampler2D s0 : TEXUNIT0) : COLOR
{
	float4 color = tex2D( s0, VAR.texCoord.xy);

	color += tex2D(s0, VAR.t1.xy);
	color += tex2D(s0, VAR.t1.zw);
	color += tex2D(s0, VAR.t2.xy);
	color += tex2D(s0, VAR.t2.zw);
	color += tex2D(s0, VAR.t3.xy);
	color += tex2D(s0, VAR.t3.zw);
	color += tex2D(s0, VAR.t4.xy);
	color += tex2D(s0, VAR.t4.zw);
	color += tex2D(s0, VAR.t5.xy);
	color += tex2D(s0, VAR.t5.zw);
	color += tex2D(s0, VAR.t6.xy);
	color += tex2D(s0, VAR.t6.zw);
	
	return color / 13;
}

