Sign in to follow this  
Dragon_Strike

getting ortho depth? *solved

Recommended Posts

im havin some problems with getting depth when using ortho projection.. with regular perspective projection this code works fine... vec4 Pos = ModelViewProjectionMatrix * Vertex; Depth = Pos.z/Far; but when i use ortho projection this doesn't work properly.. EDIT:: seems depth is converted to 0.0-1.0 [Edited by - Dragon_Strike on May 26, 2007 5:09:30 PM]

Share this post


Link to post
Share on other sites
If you can, it's easier to just get the depth from the View without projection, but if for whatever reason you need to calculate it after the projection matrix is applied, I think it should be this:

Depth = (Pos.z * (Far - Near)) + Near;

Since Pos.z is 0.0 at the near plane and 1.0 at the far plane, you multiply by the distance between those and then add the near plane.

Share this post


Link to post
Share on other sites
im using this for shadow mapping.. i found that since im using the same projection for calculating the shadowmap depth and the object depth i dont need to get the actual depth, only the difference between the two... i simply set depth = pos.z i both cases... is there any reason not to do it like this?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this