// Includes all post-process common data (textures & sampler)
#include "PPCommonData.fxh"

//---------------------------------------------------------------------
// Filter data

float3 LuminanceConv = { 0.3f, 0.59f, 0.11f };

float Threshold = 0.01f;


//-----------------------------------------------------------------------------
// Pixel Shader: ColorBinarisation
// Desc: Performs post-processing effect that binarise the picture
//-----------------------------------------------------------------------------
float4 ColorBinarisation(float2 Tex : TEXCOORD0) : COLOR0
{
	// compute the pixel luminance
	float fLuminance = dot((float3)tex2D(g_samSrcColor, Tex), LuminanceConv);
	
	// If the luminance is inferior to the threshold, then color it black
	if(fLuminance<Threshold)
		return 0;
	else
		return 1;
}


//-----------------------------------------------------------------------------
// Technique: PostProcess
// Desc: Performs post-processing effect that dilate the color source
//-----------------------------------------------------------------------------
technique PostProcess
<
	string Parameter0 = "Threshold";
	string Parameter0Desc = "(float)";
	int Parameter0Size = 1;
	float Parameter0Def = 0.01f;
>
{
    pass p0
    {
		ZEnable = false;
		
        VertexShader = null;
        PixelShader = compile ps_2_0 ColorBinarisation();
    }
}
