texture vd_srctexture;
float4 vd_texsize;

sampler src = sampler_state {
	Texture = <vd_srctexture>;
	AddressU = clamp;
	AddressV = clamp;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = None;
};

void VS(
	float4 pos : POSITION,
	float2 t0 : TEXCOORD0,
	out float4 oPos : POSITION,
	out float2 oT0 : TEXCOORD0,
	out float2 oT1 : TEXCOORD1,
	out float2 oT2 : TEXCOORD2,
	out float2 oT3 : TEXCOORD3
)
{
	oPos = pos;
	oT0 = t0 + float2(-0.5, -0.5) * vd_texsize.wz;
	oT1 = t0 + float2(0.5, -0.5) * vd_texsize.wz;
	oT2 = t0 + float2(-0.5, 0.5) * vd_texsize.wz;
	oT3 = t0 + float2(0.5, 0.5) * vd_texsize.wz;
}

float4 PS(
	float2 t0 : TEXCOORD0,
	float2 t1 : TEXCOORD1,
	float2 t2 : TEXCOORD2,
	float2 t3 : TEXCOORD3
) : COLOR0
{
	float4 p0 = tex2D(src, t0);
	float4 p1 = tex2D(src, t1);
	float4 p2 = tex2D(src, t2);
	float4 p3 = tex2D(src, t3);

	return    p0 * 0.25f
		+ p1 * 0.25f
		+ p2 * 0.25f
		+ p3 * 0.25f;
}

technique {
	pass {
		VertexShader = compile vs_1_1 VS();
		PixelShader = compile ps_1_1 PS();
	}
}
