Jump to content
  • Advertisement
Sign in to follow this  
mikenavyseal

OpenGL Setting the near and far clipping planes

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

When setting the near and far clipping planes when creating the perspective matrix in either DirectX or OpenGL, I'm confused as to how these values should be chosen. I understand that both zNear and zFar must be positive, non-zero numbers. However, most tutorials give values such as 0.1 or 1 to zNear and a much larger value for zFar. Are these values conditional on whatever your game is rendering, or is there a certain rule to follow when setting the planes? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Other than clipping, the most important consideration is the affect on the resolution of the depth buffer. Ideally, the near and far planes should be as close together as possible. However, the distance to the near plane is usually much more important than the distance to far plane because it affects the resolution of the depth buffer the most.

In absolute terms, the distances are irrelevant -- i.e. 1 is no better than 0.1 or 100. A good rule of thumb is to place the near plane no closer than 1/1000 of the distance to the farthest displayed object. You should set the distance to the far plane far enough away so that it doesn't clip objects that you want rendered. Setting it to infinity is possible and for certain techniques it is required.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!