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


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

float FocalLength = 0.2f;
float FocalAperture =  -0.1f;


//-----------------------------------------------------------------------------
// Pixel Shader: DOFCombine
// Desc: Combines the source image with the original image based on pixel depths
//-----------------------------------------------------------------------------
float4 DOFCombine(float2 Tex : TEXCOORD0, float2 Tex2 : TEXCOORD1) : COLOR0
{
	float3 ColorOrig = tex2D(g_samSceneColor, Tex2);
    float3 ColorBlur = tex2D(g_samSrcColor, Tex);
    float Blur = dot(tex2D(g_samScenePosition, Tex2).ba, float2(FocalLength, FocalAperture));
    
    return float4(lerp( ColorOrig, ColorBlur, saturate(abs(Blur)) ), 1.0f);
}


//-----------------------------------------------------------------------------
// Technique: PostProcess
// Desc: Performs post-processing effect that down-filters.
//-----------------------------------------------------------------------------
technique PostProcess
<
    string Parameter0 = "FocalLength";
    string Parameter0Desc = "(float)";
    int Parameter0Size = 1;
    float Parameter0Def = 0.2f;
    
    string Parameter1 = "FocalAperture";
    string Parameter1Desc = "(float)";
    int Parameter1Size = 1;
    float Parameter1Def = -0.1f;
    
>
{
    pass p0
    {
		ZEnable = false;
		
        VertexShader = null;
        PixelShader = compile ps_2_0 DOFCombine();        
    }
}
