Jump to content
  • Advertisement
Sign in to follow this  
Phineas

OpenGL Extend Far Clipping Plane

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

Is there any way to extend the far clipping plane of the frustum without changing anything else about the projection matrix? I'm using OpenGL, however I ask in this forum since there may be an API-independent solution.

Share this post


Link to post
Share on other sites
Advertisement
I don't understand what you want, or why you want it.

A 0 0 0
0 B 0 0
0 0 C D
0 0 E 0

That's the generic projection matrix commonly used for OpenGL (it is the form generated by gluPerspective). The fourth (zFar) parameter to gluPerspective is the distance to the fact clip plane. What's wrong with just changing that? That value only alters C and D in the matrix above (both of which use zFar in some form).

Are you saying you want to use a projection matrix that only includes zFar once? Why? Although many forms of project matrix exist (there are tons of ways to project geometry), it will likely not give you the results you expect, as the reason the GL projection matrix looks the way it does is to appropriate project the geometry based on the information the pipeline has.

Share this post


Link to post
Share on other sites
Thanks for your reply. I have an object inside of a rendering library. When the render function for my object is called, the projection matrix is already set up to render. However, for only my object I want to change the far clip plane. I tried using gluPerspective() to do so while at the same time guessing the other parameters. This would affect the scene negatively by making things look distorted.

How do I change C and D in the matrix to change the far clip plane?

Share this post


Link to post
Share on other sites
Quote:

How do I change C and D in the matrix to change the far clip plane?

If you assume that the matrix was generated with gluPerspective (this is probably reasonable, and if its wrong there is still a good chance you'll be okay, but this is not assured), then C and D are

C = (far + near) / (near - far)
D = (2 * far * near) / (near - far)


You can obtain the actual values of C and D by using glGetFloatv or glGetDoublev with the appropriate constant, then reading the appropriate elements of the resulting array. Some algebra can get you to the value of far, I guess. I suppose this should work, but it's hacky and makes some assumptions I'm not comfortable with. Can't you get the information you need elsewhere?

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!