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


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

float2 PixelKernel[4] =
{
    { 0,  1},
    { 1,  0},
    { 0, -1},
    {-1,  0}
};

float2 TexelKernel[4]
<
	string ConvertPixelsToTexels = "PixelKernel";
>;


//-----------------------------------------------------------------------------
// Pixel Shader: ColorEdgeDetect
// Desc: Performs post-processing effect that detects and highlights edges.
//-----------------------------------------------------------------------------
float3 LuminanceConv = { 0.2125f, 0.7154f, 0.0721f };

float4 ColorEdgeDetect(float2 Tex : TEXCOORD0) : COLOR0
{
    float4 Orig = tex2D(g_samSrcColor, Tex);
    float4 Sum = 0;
    for(int i=0; i<4; i++)
        Sum += (abs(Orig - tex2D(g_samSrcColor, Tex+TexelKernel[i]))-0.5f) * 1.2 + 0.5f;

    return saturate(dot(LuminanceConv, Sum))*5;
}


//-----------------------------------------------------------------------------
// Technique: PostProcess
// Desc: Performs post-processing effect that detects and highlights edges.
//-----------------------------------------------------------------------------
technique PostProcess
{
    pass p0
    {
		ZEnable = false;
		
        VertexShader = null;
        PixelShader = compile ps_2_0 ColorEdgeDetect();
    }
}
