PDA

View Full Version : Projection matrix, arbitrary projection plane



omdown
04-01-2010, 06:26 AM
So I know the matrix for projecting onto a projection plane z=D is


1 0 0 0
0 1 0 0
0 0 1 0
0 0 1/D 0


and every homogeneous point multiplied through there will be on the plane z=D after re dividing the vector back out so that w=1. But what about for if the projection plane is something else? I've figured out that if it's something like x=D or y=D, I can just move the 1/D to the first or second column instead of the third and it seems to hold up on paper, but I've had trouble making it work in my opengl app (which is probably a coding mistake I think..) If I try to use something like a projection plane of (80,0,0) with a COP of (100,0,0) I just get a vertical line instead of a cube (the cube is at (-50,0,0).

But what about situations such as if the projection plane is (Px, Py, Pz). Would the matrix simply be:



1 0 0 0
0 1 0 0
0 0 1 0
1/px 1/py 1/pz 0


This goes even more wonky than the other one I mentioned. Am I on the right track at all or waywayway off?