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:
- The projection transformation in OpenGL is not actually a projection matrix, but rather transforms a point into clip space (which is still part of the R3 domain) and the actual projection onto a 2D plane happens later as a fixed function of the pipeline.
- The projection matrix doesn't apply the perspective divide; however it does need to set the w coordinate so that when the perspective divide happens later (as a fixed function of the pipeline) points are correctly placed either inside or outside of NDC.
- Clip space is a box between (-1,+1) on the x,y axis, and (n,f) on the z-axis while NDC is a box betwen (-1,+1) on all axis.
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.