View Full Version : History Question: After the Model View

07-18-2011, 12:39 PM
After the model and view transforms, why are the projection matrix and the viewport transforms separate? It seems like they should just be one matrix. The only guess I can come up with is that it is helpful to some hardware to have clip co-ordinates that are in the range of 0.0 to 1.0
Does anyone really know why these are separate?


Alfonse Reinheart
07-18-2011, 12:50 PM
There are two different reasons for the two separate transforms. Lighting is usually done in eye space (and by "usually", I mean the fixed-function pipeline defines it to happen there), so you need at least two matrices so that OpenGL can know what the eye-space position of things are. Other computations are done in eye-space too.

The viewport transform can't be used, simply because of the nature of projection. The coordinate system after the projection matrix is clip-space, which is a 4D homogeneous coordinate system. The next step (after clipping) is normalized device coordinate (NDC) space, which divides the first 3 components of the position by the W component. That division, often called the perspective divide, cannot be done with a matrix.

The viewport transform operates on NDC-space positions. So it can't be folded into the projection matrix. Also, clipping happens in the aptly named clip-space. Clipping can generate vertices, so you can't just fold that into a matrix transform.

07-21-2011, 12:24 PM
Thanks, that was good information, and the link you gave, points to an excellent book, one that explains what is _really_ going on, _instead_ of just saying do things this way because you are supposed to do it this way.

Dark Photon
07-22-2011, 02:22 PM
For more details, see:

* http://www.sjbaker.org/steve/omniv/projection_abuse.html

07-27-2011, 10:13 AM
Thanks that link is quite useful as well.