The
value stored by the hardware in the depth buffer is a non-linear mapping of the
actual depth from the camera based on the near and far clipping planes.
This
is done so that objects closer to the camera have more depth resolution.
The
mapping is of the form:
z_buffer_value
~ a - b / z
where
a = zFar / ( zFar - zNear )
b = zFar * zNear / ( zFar – zNear )
z = distance from camera to object
z-resolution
inversely proportional to distance
Tip: set zNear to a value > 0