Depth threshold

Hi I have a somewhat stupid question.
I want to make textureFX that uses a depthbufer and according to the depth value creates a mask

This DepthThreshold texturefx should be used to mask the background and replace it with alpha.

My simple approach was just like this

float4 c = texture2d.Sample(linearSampler,input.uv);
if (c.r<0) c.rgba = float4(0.0,0.0,0.0,0.0);
return c;

so it should draw black for every pixel with depth smaller then 0 (the threshold).

I think I am missing something with the depth, eventually i have to map it, saturate it or something like this to get usable values?

cheers,
David.

thanks to vux i found what i wanted
it works with

float4 PS(psInput input) : SV_Target
{
float4 c = texture2d.Sample(linearSampler,input.uv);
float zdepth = bgl_DepthTexture.Sample(linearSampler,input.uv).x;
if (zdepth > 0.9999f) c.rgba = float4(0.0,0.0,0.0,0.0);
return c;
}

see attached help file

DepthThreshold.zip (5.5 kB)