# Frustum Calculations

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

## Recommended Posts

How do I determine the plane equations for the frustum created from the current camera position, direction vector, and my given field of view? Thanks for the help!

##### Share on other sites
You might start here. Or, you can construct the planes in camera space using trig and then transform them into world space.

Keep in mind that you'll also need a reference vector for your orientation (it's not uniquely defined by a position and direction), and an aspect ratio.

##### Share on other sites
the last post was mine, sorry about the lousy attempt at BBCode.

##### Share on other sites
Quote:
 http://www2.ravensoft.com/users/ggribb/plane%20extraction.pdf
Just to save the OP some time, that's the same paper that I linked to in my post.

##### Share on other sites
I am writing a portal renderer which is why I need this info. I am a newbie in this, so if someone could fill in some blanks, it would be helpful.

I was just imagining that I could compute the frustum plane equations from an arbitrary position, view vector, up vector, field of view, and aspect ratio. But the posted article seems to imply that it must be done through the projection matrix. So, I gather to compute an arbitrary frustum, I must use the modelview matrix to move to the arbitrary location and set up the view and up vectors?

Another thing, what is the difference between glFrustum and gluPerspective? gluPersepective specifies an aspect ratio but one isn't specified with glFrustum. Is it somehow determined with the values passed to glFrustum?

Thanks to everyone who helped out!

##### Share on other sites
Thinking about this some more, I think there are really two things I need to know how to do for a portal renderer. Anyone correct me if I'm wrong here. Please.

1) I need to compute the frustum for the camera location. This will require the projection matrix.

2) I need to know how to determine the plane equations for a frustum given a start point and a quad. I don't think the projection matrix needs to come into play for this. More generally, I need to know how to compute a plane equation given 3 points.

Thanks again!

##### Share on other sites
Quote:
 Another thing, what is the difference between glFrustum and gluPerspective? gluPersepective specifies an aspect ratio but one isn't specified with glFrustum. Is it somehow determined with the values passed to glFrustum?
glFrustum() takes six arguments: the distance to the near and far planes, and the left, right, bottom, and top coordinates of the viewing window at the near plane.

Note that left can be different from -right and bottom can be different from -top. This means that the frustum (although still a perspective projection) can be skewed off center if desired. Note that the aspect ratio is implicit in the function arguments.

gluPerspective() is a utility function that wraps glFrustum(). It takes a vertical field of view, an aspect ratio, and the near and far plane distances, converts the arguments to l,r,b,t,n,f form, and calls glFrustum(). Well, I don't actually know if it calls glFrustum() or computes the matrix in place, but in any case it does the same thing as glFrustum(), except that the frustum cannot be off-axis; it is always symmetrical across the xz and yz planes.

I'm at work now, but if no one's helped you with your other questions later I'll try to provide some more info.

##### Share on other sites
Home for lunch, so I'll try to provide a little more info.
Quote:
 I was just imagining that I could compute the frustum plane equations from an arbitrary position, view vector, up vector, field of view, and aspect ratio. But the posted article seems to imply that it must be done through the projection matrix. So, I gather to compute an arbitrary frustum, I must use the modelview matrix to move to the arbitrary location and set up the view and up vectors?
You can do it either way. An advantage of doing it through the gl matrix is that you have a uniform way of extracting the planes, regardless of what sort of projection you've set up (off-center or whatever).

However, unless you're constructing these matrices yourself and submitting them to OpenGL, the matrix extraction method requires querying the OpenGL matrices, which isn't always desirable.

As an alternative, you can construct it yourself from the information you listed - position, view, up, fov, and aspect. There are a few things you need to know, such as how to express fov as a zoom factor and/or how to convert between horizontal and vertical fov. If you then draw a top-down or side-on view of the frustum, it will probably start to become clear how to compute the plane normals using trig. It's probably easiest to compute the planes in camera space based on fov, aspect, near and far, and then transform to world space using position, view, and up. Don't forget to account for OpenGL's -z forward if necessary.
Quote:
 I need to know how to determine the plane equations for a frustum given a start point and a quad. I don't think the projection matrix needs to come into play for this. More generally, I need to know how to compute a plane equation given 3 points.
This is another way to approach the problem. The near plane corners in camera space are [l,b,n], [r,b,n], [r,t,n], and [l,t,n]. Transform these by the camera coordinate system to find the corners of the quad you mention. Then create the planes using the camera position and the quad corners. Google 'plane from points' if you're not sure how to do that.

'Hope some of this will be helpful to you.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 13
• 14
• 10
• 11
• 13
• ### Forum Statistics

• Total Topics
634096
• Total Posts
3015488
×

## Important Information

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!