// 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: PostProcessPS
// Desc: Performs post-processing effect that detects and highlights edges.
//-----------------------------------------------------------------------------
float4 NormalEdgeDetect(float2 Tex : TEXCOORD0) : COLOR0
{
    float4 Orig = tex2D(g_samSrcNormal, Tex);

    float4 Sum = 0;
    for(int i=0; i<4; i++)
        Sum += ( 1 - dot(Orig.xyz, tex2D(g_samSrcNormal, Tex+TexelKernel[i]).xyz) );    
    return saturate(Sum);
}



//-----------------------------------------------------------------------------
// 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 NormalEdgeDetect();
    }
}
