This should be a value in range [min
, max
] where min
is either -1.0
or 0.0
and max
is 1.0
though what you get from the texture might simply be an integer value which might need to be transformed (from 24-bit to 32-bit). If none confirms any of these you will need to test it yourself.
Anyway, these values min
and max
should represent the clipping planes so min = near
and max = far
due to the depth buffer optimisation. To get the true Z
value from texture coordinate ZT
then:
Z = near + ((far-near) * ((ZT-min)/(max-min)))
This Z
then represents the distance from (0,0,0)
from the user perspective this is the distance between object and the camera position.
Try looking for some literature.