Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Void

View Frustum plane calculation

This topic is 6108 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, can anyone explain the idea behind calculating the 6 view frustum planes? I read Mark Morley tutorial. He combines the view matrix with projection matrix, and does some calculation to extract the plane''s equation. What is the formula/rationale he used to do the extraction calculation? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I have no idea, but I''d like to know...

As we all do, don''t we?

Qatal

die or be died...i think

Share this post


Link to post
Share on other sites
I''m not sure how he came up with it. As for why it works you have to lookup how the matrix is built in the documentation for glFrustrum. You can ignore the model view matrix by just making it the identity matrix. He is subtracting one of the first three rows from the fourth row.

Now ignoring what he did the normal for the right plane is (top,right,near) x (bottom,right,near) or (near*(top-bottom), 0, right*(bottom-top)). If you divide through by (top-bottom) you get (near, 0, -right). Now taking what he did you get (-2*near/(right-left), 0, -1-(right+left)/(right-left), 0) which simplifies to (near, 0, right, 0). You might notice that is not (near, 0, -right). I suspect that is actually the left hand plane since normally the z-axis goes straight through the center of the viewport so -right is left. None of his examples do anything where it matters which is left and which is right. Overall I don''t think it is some mathematical property as much as it is simply an encoding. It allows them to store the values in a manner that can be retrieved/used without affecting the projection operation.

I''m a bit confused on the model view part. That would seem to me to be projecting the model tranform which seems backwards to me. So my best guess is that I have it backwards and it is putting the projection matrix into model space. It seems like that would have to be the inverse of the model view, but apparently it works and apparently I''m wrong.

Share this post


Link to post
Share on other sites
The model view part is correct because the planes calculated are to be in global world coordinates. (meaning the planes are calculated when the view matrix is identity, then transformed by the model view)

I can understand calculating the planes by crossproduct of the ray projections. What I cannot see is the maths behind extracting the rows of the matrix and subtracting/adding (and it works!)

The first 3 columns of a matrix in opengl defines the orientation of the x,y,z axis of that coordinate frame. What does the rows mean then?

As I understand, the projection matrix turns the view frustum into a canonical view volume ( a 3d cube ) through a translation and a kind of z shear (which is not homogenous). So how he extracts the planes from that matrix is still a mystery to me.

Share this post


Link to post
Share on other sites
The projection matrix used by OpenGL is not:

  
1 0 0 0
0 1 0 0
0 0 1 1/focus
0 0 -1 0


How the matrix is built is documented here. The actual matrix used by OpenGL is apparently the transpose of that matrix. If you work through the calculations he gave you get a scaled version of the cross product.

Share this post


Link to post
Share on other sites

  • 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!