Sign in to follow this  
Suen

View Frustum

Recommended Posts

I'm slightly confused about the theory here after looking through several sources on the net. My confusion lies in when exactly you define/create the view frustum (for perspective projection). From my understanding this is how it works:

Model space -> World space -> camera space -> clip space -> NDC etc.

Some seem to mix the camera and view frustum together as if the view frustum is already defined/existing in camera space but as far as I know the view frustum is actually defined in the projection matrix thus shouldn't it be existing only when we've moved over to clip space?

The way I visualize it is that once we use a view matrix to transform frm world space to camera space we see the world from our camera but we don't have any boundaries here yet so essentially at this point we can see everything that exists in our scene. When we define a projection matrix then we define boundaries through planes (nearplane, far, top, bottom etc.). So once we use this projection matrix to transform all our vertices from camera space to clip space then we have a view frustum with some vertices lying within it and some outside. I'm not sure if this is the correct way of understanding this.

Regarding the boundaries of the left, right, top and bottom planes...I'm slightly lost where they exactly are defined. I've created a projection matrix (which works) where the field of view is used as an input in (row, column) = (1,1) and (2,2). The one in (1,1) is also dependant on the aspect ratio of my window. I assume these are supposed to represent the horizontal/vertical fov which perhaps define the boundaries in those directions but this is just a wild guess from my part.

And for one last question which is not entirely related to above...why exactly do you get a zoomed in effect when you have smaller fov? I assume this is because we would see less and less of the scene as the fov decreases and then eventually our focus would only lie...say on a particular object. This would give the feeling as if we've zoomed in(which we haven't really done through translations for ex.) on that object as it would be the only thing we would see. I could be wrong here as well.

Some clarifications for this would be really appreciated [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Share this post


Link to post
Share on other sites
[quote name='Suen' timestamp='1333337914' post='4927363']
Some seem to mix the camera and view frustum together as if the view frustum is already defined/existing in camera space but as far as I know the view frustum is actually defined in the projection matrix thus shouldn't it be existing only when we've moved over to clip space?
[/quote]
When you transform a vertex you multiply it with a transformation matrix. That is, instead of transforming a vertex by multipling it with every single matrix (world,camera,projection etc.), you pre-combine the matrices and transform the vertices only once with this matrix. An other fact is, that the world transformation (object -> world space) depends on the rendered object, whereas the camera and projection transformation depends on the camera. That is important, because the camera stays fix when rendering a single scene, therefore you can combine the camera and projection matrix once at the start of rendering a single scene.

[quote name='Suen' timestamp='1333337914' post='4927363']
The way I visualize it is that once we use a view matrix to transform frm world space to camera space we see the world from our camera but we don't have any boundaries here yet so essentially at this point we can see everything that exists in our scene. When we define a projection matrix then we define boundaries through planes (nearplane, far, top, bottom etc.). So once we use this projection matrix to transform all our vertices from camera space to clip space then we have a view frustum with some vertices lying within it and some outside. I'm not sure if this is the correct way of understanding this.
[/quote]
That's correct. Normaly a projection would project a 3d vertex to a 2d plane (in this case the screen), but in our case, the projectionmatrix transforms vertex [i]into [/i]a unit cube (side length of 1). Everything which is not inside 0..1 will be discarded or clipped. You don't need to do it this way, but it is very hardware friendly. The unit cube is the transformed view frustum.



[quote name='Suen' timestamp='1333337914' post='4927363']
And for one last question which is not entirely related to above...why exactly do you get a zoomed in effect when you have smaller fov? I assume this is because we would see less and less of the scene as the fov decreases and then eventually our focus would only lie...say on a particular object. This would give the feeling as if we've zoomed in(which we haven't really done through translations for ex.) on that object as it would be the only thing we would see. I could be wrong here as well.
[/quote]
You are right here again. It is only a fake-zoom, because we stretch a smaller part of the scene to the screen by decresing the fov.

Share this post


Link to post
Share on other sites
[quote name='Ashaman73' timestamp='1333366977' post='4927446']
[quote name='Suen' timestamp='1333337914' post='4927363']
Some seem to mix the camera and view frustum together as if the view frustum is already defined/existing in camera space but as far as I know the view frustum is actually defined in the projection matrix thus shouldn't it be existing only when we've moved over to clip space?
[/quote]
When you transform a vertex you multiply it with a transformation matrix. That is, instead of transforming a vertex by multipling it with every single matrix (world,camera,projection etc.), you pre-combine the matrices and transform the vertices only once with this matrix. An other fact is, that the world transformation (object -> world space) depends on the rendered object, whereas the camera and projection transformation depends on the camera. That is important, because the camera stays fix when rendering a single scene, therefore you can combine the camera and projection matrix once at the start of rendering a single scene.[/quote]

[quote]
[quote name='Suen' timestamp='1333337914' post='4927363']
The way I visualize it is that once we use a view matrix to transform frm world space to camera space we see the world from our camera but we don't have any boundaries here yet so essentially at this point we can see everything that exists in our scene. When we define a projection matrix then we define boundaries through planes (nearplane, far, top, bottom etc.). So once we use this projection matrix to transform all our vertices from camera space to clip space then we have a view frustum with some vertices lying within it and some outside. I'm not sure if this is the correct way of understanding this.
[/quote]
That's correct. Normaly a projection would project a 3d vertex to a 2d plane (in this case the screen), but in our case, the projectionmatrix transforms vertex [i]into [/i]a unit cube (side length of 1). Everything which is not inside 0..1 will be discarded or clipped. You don't need to do it this way, but it is very hardware friendly. The unit cube is the transformed view frustum[/quote]

So it is as I thought, the view frustum itself is not defined yet when you are in camera space, but is rather defined once you've transformed everything to clip space. When reading some of the countless of explanations on the net I sometimes thought that the boundaries were already defined in camera space before we applied any projection matrix which didn't make sense to me since the projection matrix then would be pointless.But if we combine the view matrix with the projection matrix then I guess it makes sense to visualize the camera and view frustum together as one (well including the model matrix as well of course so one has the whole modelview-projection matrix, at least in OpenGL due to "lack of" a world space)

So basically:

-> Transform to camera space with the view matrix
Camera space = See the whole world from the camera
->Transform to clip space with projection matrix
Clip space = See a part of the world contained by the view frustum from the camera

Combine the view and projection matrix together and you have the camera and view frustum combined into one.

One thing with regard to what you said. Projection would merely mean to remove one dimension so in my case from 4D homogeneous coordinates to 3D space. This is not really done by the projection matrix (despite the name). But you said that the projection matrix transforms the vertices into a unit cube. I thought this was what perspective division did. Simply put it's done in two steps: the projection matrix transforms vertices so that some are in the view frustum while some might be not. Then a perspective division is carried out to get it in NDC space (unit cube that you mentioned). Unless you meant to say that since we store the z-value of a vertice (in camera space) in the projection matrix it basically does the whole thing to get an unit cube in the end.

I'm also slightly curious...at what point is the actual projection (removing one dimension) done exactly? Isn't it right after perspective division when I move to 3D space?

Thanks for the help!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this