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

//---------------------------------------------------------------------
// Filter data
static const int g_cKernelSize = 8;

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

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

//-----------------------------------------------------------------------------
// Pixel Shader: ColorDilation
// Desc: Performs post-processing effect that dilates the color source
//-----------------------------------------------------------------------------
float4 ColorDilation(float2 Tex : TEXCOORD0) : COLOR0
{
	// Simple dilate operation, find the maximum pixel in the neighborhood.
	float4 maxSamp = tex2D(g_samSrcColor, Tex);
	for(int i=0; i<8; i++)
		maxSamp = max(maxSamp, tex2D(g_samSrcColor, Tex+TexelKernel[i].xy));

   return maxSamp;
}


//-----------------------------------------------------------------------------
// Technique: PostProcess
// Desc: Performs post-processing effect that dilate the color source
//-----------------------------------------------------------------------------
technique PostProcess
{
    pass p0
    {
		ZEnable = false;
		
        VertexShader = null;
        PixelShader = compile ps_2_0 ColorDilation();
    }
}
