View Full Version : Converting World Values to Depth Buffer Values
10-21-2004, 07:10 AM
I need a way to convert world coordinates to depth buffer coordinates without just drawing something and reading the depth buffer. For some reason that doesn't seem to be working for me. Is there some kind of formula?
10-22-2004, 01:04 AM
There is even a function to help you: gluProject.
If you need the depth value as integer, take the resulting windows z-coordinate which should be in the 0.0 to 1.0 range (I think), and scale it with (2^number of depth bits)-1.
This will not be invariant with what implementations calculate internally due to different algorithms and precisions, but should come close.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.