how to access cg fragment z value

How do you access the z value of an incoming pixel in CG?

Bind an input float4 variable to WPOS and access the z portion.

Here’s an example:

float4 main(in float4 wpos : WPOS) : COLOR
{
    return wpos.z;
}