Jump to content
  • Advertisement
Sign in to follow this  
Tree Penguin

OpenGL Stupid nearplane and depth buffer questions...

This topic is 4731 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

Hi, i know opengl pretty good but i got a few very basic and probably stupid questions, for some reason i am just not totally sure about them: 1. Is the nearplane: A. A plane of which the length of the vector from the camera eye to every point on the plane DOT the camera direction normal = nearplane distance (a straight plane). B. Or a 'plane' of which every point on it lies at the same distance from the camera. I guess A, as it's a plane. 2. Are the values stored in the depth buffer: A. The distance to the camera-eye. B. Or the length of the vector to the camera-eye DOT the camera direction normal. I got no idea. Thanks for any help.

Share this post


Link to post
Share on other sites
Advertisement
It's the distance of (point dot camera front) in both cases -- so, a flat plane, and a dot product.

And what's stored is actually the distance (after dot product, along camera front) divided by the homogenous w, and scaled/offset to be 0 at the near plane, and 1 at the far plane; quantized to depthbuffer bits (or other values for "0" and "1" as set by glDepthRange()).

Share this post


Link to post
Share on other sites
Also, I'll point out that due to how the depth buffer is done(as explained above), things closer to the camera are more accurately placed depthwise as there are more bits(I think it is logarthmic, sorry bad spelling), and using to high of a far plane to near plane ratio usually causes Z fighting between triangles. This is fixed usually by moving the near plane farther from the camera instead of the far plane since closer is more accurate.

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!