PDA

View Full Version : Computing depth buffer value



Noah
01-19-2002, 06:59 PM
Suppose I have a viewport looking down the -Z axis. I have the distance of the viewport from the Z axis, the Z value of a vertex, and the ZNear and ZFar clipping plane values.

Now how do I figure out what the depth buffer value is going to be under that vertex?

I'm currently doing:
1.0-(ObjectZ+CameraZ)/(ZFar-ZNear)

but that doesn't work quite right.