Jump to content
  • Advertisement
Sign in to follow this  
all_names_taken

Is view matrix always invertible? How change base of plane equation?

This topic is 4389 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 a view matrix always invertible? I made a proof attempt but it failed, so I made a simpler proof sketch instead: since it represents a base change in the 3*3 upper left corner, and a translation in the bottom left corner, and the rightmost row is equal to identity, undoing the translation and rotation should be possible. Is that correct? My second question is how to change base of a plane equation? I manage to change base of the normal vector, but when I get to the d parameter, I obtain this expression:
sqrt( (d*nx-x)^2 + (d*ny-y)^2 + (d*nz-z)^2 )
where d is the old d parameter, nx,ny,nz are the old normal vector parameters, and x,y,z are the amounts of translation the new view matrix does compared to the old base. Is this expression correct, or are there simpler methods of changing base of a plane, such as multiplying the 4 vector by a 4*4 matrix? My final question is how to extract view frustum planes from a projection matrix and get the plane equations in world space, both for the case of a normal projection matrix, and for the case of an orthogonal projection.

Share this post


Link to post
Share on other sites
Advertisement
I can answer your first question.
A view matrix is a scale/rotation multiplied by a translation matrix.

Inverse(AB) = Inverse(B) * Inverse(A)

so if A and B are invertible then so is AB.

So the answer is yes.

Share this post


Link to post
Share on other sites
Quote:
Original post by all_names_taken
My final question is how to extract view frustum planes from a projection matrix and get the plane equations in world space, both for the case of a normal projection matrix, and for the case of an orthogonal projection.
Google 'Inequalities for the Homogeneous Clipping Space', and you'll find a good article on the subject.

[Edit: John provided a link (below) to the paper I had in mind.]

[Edited by - jyk on August 13, 2006 7:10:57 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by JohnBolton
Quote:
Original post by all_names_taken
My final question is how to extract view frustum planes from a projection matrix and get the plane equations in world space, both for the case of a normal projection matrix, and for the case of an orthogonal projection.

The standard reference: Fast Extraction of Viewing Frustum Planes from the World-View-Projection Matrix


the odd thing is that when I use that method, my far plane gets normal=(0,0,-1) and d=1, even though I created my projection matrix with the setting that far plane would be 20000.0 away. Logically, if the far plane is set to be 20000.0 units away, then the plane extraction of far plane, when positioned at 0,0,0 and looking at 0,0,1 should yield d=20000.0, but it doesn't...

So I've tried to think up an own method for plane extraction. The above method in my tests gets the normals right, but the d parameter wrong. In view space, all planes except far and near plane have d=0, so I could extract the planes from the projection matrix using above method, then manually setting d to 20000 for far plane and 1 for near plane, then finally transform the plane equations of all the planes using the inverse of the view matrix, to get them in world space.

Share this post


Link to post
Share on other sites
Quote:
Original post by all_names_taken
the odd thing is that when I use that method, my far plane gets normal=(0,0,-1) and d=1, even though I created my projection matrix with the setting that far plane would be 20000.0 away. Logically, if the far plane is set to be 20000.0 units away, then the plane extraction of far plane, when positioned at 0,0,0 and looking at 0,0,1 should yield d=20000.0, but it doesn't...

So I've tried to think up an own method for plane extraction. The above method in my tests gets the normals right, but the d parameter wrong. In view space, all planes except far and near plane have d=0, so I could extract the planes from the projection matrix using above method, then manually setting d to 20000 for far plane and 1 for near plane, then finally transform the plane equations of all the planes using the inverse of the view matrix, to get them in world space.
I wouldn't be so quick to implement your own method because you encountered problems with the algorithm as described in the paper. That paper has been around for a while and the algorithm has been used by many people. At this point I think it would be safe to say that it works. I can say that I've used it successfully myself, and have also worked through the derivation and confirmed that the algorithm is correct (just for my own edification).

IMO it's more likely that you've implemented the algorithm incorrectly or made an error elsewhere. Keep in mind that there are two versions of the algorithm presented in the paper: one for DirectX, and one for OpenGL. The two differ in terms of matrix indexing and calculations involving the near-z clipping range. If you get either of these wrong your results will be incorrect. Also, you may need to normalize the planes after extraction to get the results you're expecting. [Edit: It looks like you're getting unit-length normals, so that may not be the problem.]

I would suggest sticking with the algorithm (which is well established) and looking for an error in either your implementation or your use of the algorithm.

[Edit: IIRC, there may be a typo in one of the sections that describe how to concatenate the view and projection matrices, so make sure that you have the order correct for the vector convention you're using. Off the top of my head, it should be P*V for column vectors and V*P for row vectors.]

Share this post


Link to post
Share on other sites
1. it seems I keep getting errors, but I'll devote one more day to reviewing my implementation of it tommorrow. I'm currently using DirectX.
2. does the method from the paper also work for calculating the clipping planes of an orthogonal projection matrix?

Share this post


Link to post
Share on other sites
Quote:
Original post by all_names_taken
2. does the method from the paper also work for calculating the clipping planes of an orthogonal projection matrix?
Yes :)

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!