fuzzy: Fog is distance based. The farther away your model is, the more it will be fogged.
If you set the near fog value to be in front of your object, and the far fog value to be in back of it, and you set the object to be fullbright and white, then the pixels in the object's polygons will be darker the farther away from the camera they are.
Fog is linear as well, so if the color ends up being grey than you are halfway between the near and far fog planes.
The limitation of this is that if you are in 32bit color mode, you will only get 256 different levels of distance. You could however render several passes and improve the accuracy but how that works is for you to figure out. :-)
Fog may not give you a perfect depth map though. It may work like goraud shading, so the depth would be interpolated between the vertices, which might not result in true depth. But if you do not need a highly precise depth map it may be good enough.
|