A projection matrix projects a vector from a higher dimensional space onto a subspace. I would have expected the projection matrix in OpenGL to project a point in R3 onto a 2 dimensional plane. This seems to be supported by a lot of literature on the internet. Many sites imply that the projection matrix projects the 3D world onto a plane and this is what is drawn. However I get the feeling that most of these explanations are skipping several steps. Many of them seem to contradict each other so I'd like some clarification of the conclusions I have drawn from my own analysis.
Can someone please confirm (or correct if wrong) that:
I analysed the following projection matrix to come to the above conclusions:
[ 2n/(r-l) 0 (r+l)/(r-b) 0 ]
[ 0 2n/(t-b) (t+b)/(t-b) 0 ]
[ 0 0 -(f+n)/(f-n) -2fn/(f-n) ]
[ 0 0 -1 0 ]
From that analysis I concluded that any point that is within the frustum will be within the clip boundaries along the x,y axis; it may be outside the boundaries along the z axis, however once the perspective divide happens (with w now being the old -z) the point will fully inside clip space.
From this I have also concluded that for a point to be visible after the MVP transformation it's x,y and z/w coordinates must be between +/-1, and that the perspective divide and actual projection happen after the vertex shader.
If applicable answers specific to modern OpenGL (3.3 core or later) only please.
The projection matrix in OpenGL transforms points into clip space. But this is already a projection. The only thing that has to be done after the matrix multiplication is the perspective divide.
True
Clip space is the space from [-w to w] on each axis, since the only operation that happens between clip space and NDC is the perspective divide. NDC is from [-1 to 1] on each axis.
Additional notes:
A geometric projection in general is defined as a mapping p from one space (O) into another one (T). this would be written as
O --p--> T
In some cases such a mapping can be described by a tranformation matrix in euclidean space (a parallel projection, for example, would work), but in a lot of cases this is not possible (especially in cases where parallel lines in O are not parallel any more in T). This is why projective spaces are required.
I better stop here now since it gets more and more complicated from the mathematical point of view, but if you want to dig more into this topic, I suggest the following articles:
Wikipedia Projective Space
Wikipedia Projective Geometry
Video about projection in general (this, and the next one)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With