//@author: bjoern
//@help: deinterlaces incoming texture
//@tags: texture
//@credits: https://github.com/zachsaw/RenderScripts/blob/master/RenderScripts/ImageProcessingShaders/MPC-HC/Deinterlace%20(blend).hlsl

Texture2D texture2d : PREVIOUS;
float2 R:TARGETSIZE; 

SamplerState linearSampler : IMMUTABLE
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
};

struct psInput
{
	float4 p : SV_Position;
	float2 uv : TEXCOORD0;
};


float4 PS(psInput input) : SV_Target
{
	float4 c = texture2d.Sample(linearSampler,input.uv);
	
	float2 h = float2(0, 1 / R.y);
	float4 c1 = texture2d.Sample(linearSampler,input.uv - h);
	float4 c2 = texture2d.Sample(linearSampler,input.uv + h);
	c = (c * 2 + c1 + c2) / 4;
	return c;
}

technique10 Process
{
	pass P0
	{
		SetPixelShader(CompileShader(ps_4_0,PS()));
	}
}



