#if (RFX_DisplayDepth == 1)

NAMESPACE_ENTER(RFX)

void DisplayDepth(in float4 position : SV_Position, in float2 texcoord : TEXCOORD0, out float3 color : SV_Target)
{
	// Depth buffer access
	float depth = tex2D(RFX_depthColor, texcoord).x;

	// Linearize depth
	depth = (2.0 * RFX_Depth_z_near) / ( -(RFX_Depth_z_far - RFX_Depth_z_near) * depth + (RFX_Depth_z_far + RFX_Depth_z_near) );	

	color.rgb = float3(depth.xxx);
}

technique Depth_Tech < bool enabled = false; int toggle = RFX_DepthToggleKey;>
{
	pass
	{
		VertexShader = RFX_VS_PostProcess;
		PixelShader = DisplayDepth;
	}
}

NAMESPACE_LEAVE()

#endif