Jump to content
  • Advertisement
Sign in to follow this  
Dragon_Strike

getting ortho depth? *solved

This topic is 4074 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!