vector rcpres;

texture lastshader;
texture lastpass;
texture thisframe;
//sampler s0 = sampler_state { texture=<lastshader>; minfilter = linear; magfilter = linear; mipfilter = linear; addressu=clamp; addressv = clamp; };
sampler s0 = sampler_state { texture=<thisframe>; minfilter = linear; magfilter = linear; mipfilter = linear; addressu=clamp; addressv = clamp; };
sampler s1 = sampler_state { texture=<lastpass>; minfilter = linear; magfilter = linear; mipfilter = linear; addressu=clamp; addressv = clamp; };

float4 brightPass(in float2 Tex : TEXCOORD) : COLOR0
{
	float4 Color = tex2D(s0, Tex);
	Color = smoothstep(0.6, 1.6, Color);
	Color.r = Color.r + Color.g + Color.b;
	Color.g = Color.b = 0;
	return Color;
}

float4 vampVision(in float2 Tex : TEXCOORD) : COLOR0
{
	float4 Color = tex2D(s0, Tex);
	float4 highlight = tex2D(s1, Tex);
	highlight.g = highlight.b = -highlight.r;
	Color.rgb = ( Color.r * 0.3 ) + ( Color.g * 0.6 ) + ( Color.b * 0.1 );
	Color = Color + highlight;
	Color.a = 1;
	return Color;
}

float4 blurH(in float2 Tex : TEXCOORD) : COLOR0
{ // a simple 7-sample horizontal blur pass   
	float4 Color = tex2D(s1, Tex);

	Color += tex2D(s1, float2(Tex.x-(rcpres.x*1), Tex.y)) * 0.8;
	Color += tex2D(s1, float2(Tex.x+(rcpres.x*1), Tex.y)) * 0.8;

	Color += tex2D(s1, float2(Tex.x-(rcpres.x*2), Tex.y)) * 0.65;
	Color += tex2D(s1, float2(Tex.x+(rcpres.x*2), Tex.y)) * 0.65;

	Color += tex2D(s1, float2(Tex.x-(rcpres.x*3), Tex.y)) * 0.4;
	Color += tex2D(s1, float2(Tex.x+(rcpres.x*3), Tex.y)) * 0.4;

	Color += tex2D(s1, float2(Tex.x-(rcpres.x*4), Tex.y)) * 0.25;
	Color += tex2D(s1, float2(Tex.x+(rcpres.x*4), Tex.y)) * 0.25;

	Color /= 5;

	return Color;
}

float4 blurV(in float2 Tex : TEXCOORD) : COLOR0
{ // a simple 7-sample vertical blur pass
	float4 Color = tex2D(s1, Tex);

	Color += tex2D(s1, float2(Tex.x, Tex.y-(rcpres.y*1))) * 0.8;
	Color += tex2D(s1, float2(Tex.x, Tex.y+(rcpres.y*1))) * 0.8;

	Color += tex2D(s1, float2(Tex.x, Tex.y-(rcpres.y*2))) * 0.65;
	Color += tex2D(s1, float2(Tex.x, Tex.y+(rcpres.y*2))) * 0.65;

	Color += tex2D(s1, float2(Tex.x, Tex.y-(rcpres.y*3))) * 0.4;
	Color += tex2D(s1, float2(Tex.x, Tex.y+(rcpres.y*3))) * 0.4;

	Color += tex2D(s1, float2(Tex.x, Tex.y-(rcpres.y*4))) * 0.25;
	Color += tex2D(s1, float2(Tex.x, Tex.y+(rcpres.y*4))) * 0.25;

	Color /= 5;

	return Color;
}

technique T0
{
	pass p0
	{
		PixelShader = compile ps_2_0 brightPass();
	}
	pass p1
	{
		PixelShader = compile ps_2_0 blurH();
	}
	pass p2
	{
		PixelShader = compile ps_2_0 blurV();
	}
	pass p3
	{
		PixelShader = compile ps_2_0 vampVision();
	}
}
