3

I'm having trouble understanding why the model and view matrices are traditionally combined together. I know that the less matrix multiplying you do in the vertex shader the better, but it makes much more sense to me to combine the projection and view matrices.

This is because they are both intrinsically camera properties. It makes sense to me to first transform vertices into world space with the model matrix, perform lighting etc., then use your combined camera matrix to translate to normalised clip space.

I know that I can do it that way if I want in a programmable pipeline, but I want to know why historically people combined the model and view matrices.

Matt Randell
  • 374
  • 1
  • 3
  • 11
  • 1
    Have a look here: http://stackoverflow.com/questions/10617589/why-would-it-be-beneficial-to-have-a-separate-projection-matrix-yet-combine-mod. I thing the answer explains it realy nice – BDL Aug 27 '13 at 17:41
  • I still don't get why you don't do lighting in world space and then go to clip space in one jump (I'd already read that page) – Matt Randell Aug 27 '13 at 17:42
  • @ranmat11: That page has a link to an article that explains why in excruciating detail. – Nicol Bolas Aug 28 '13 at 00:10

1 Answers1

3

In graphics programming, camera doesn't exist. It's always fixed at (0,0,0) and looking towards (0,0,-1). Camera as everyone knows it is totally artificial and mimics the way we are used to observing objects, as humans, and by that I mean: moving around, pivoting our head and such. To mimic that, cg introduces the concept of camera. It is interesting and well known that it is the same thing whether will you move to camera to the right or to move all other objects in the scene to the left. That invariance is then transffered onto modelMatrix by combining all transformations on object in one matrix - MVMatrix.

View and Projection matrices are seperated because those matrices do very different transformations. One is very similar to modelMatrix and represents 3d, in-space transformations, and the other is used for calculating angles from which the objects are viewed.

Dragan Okanovic
  • 7,509
  • 3
  • 32
  • 48
  • Aah. That last paragraph is what I was looking for. – Matt Randell Aug 27 '13 at 17:47
  • Glad it helped. On www.scratchapixel.com you can find many interesting facts and concepts from cg. – Dragan Okanovic Aug 27 '13 at 17:48
  • Although I think I will keep model and view matrices separate in my projects so I don't have to use matrices on light positions to take them to camera space. – Matt Randell Aug 27 '13 at 17:48
  • That's why I love programmable pipelines! – Matt Randell Aug 27 '13 at 17:49
  • 3
    @ranmat11: A slightly different way to look at view and projection matrices is this: The projection defines your camera's lens. Just like you can do things like tilt and shift using a real lens (keeping the camera's body in place) you can do the same with the projection. The view matrix OTOH is your camera's body or the tripod it's mounted on. You use the view transform (="tripod") to move your camera in the scene and the projection transform (="lens' focal length, tilt and shift relative to the camera body"). It should be intuitively clear, that those are different things to do. – datenwolf Aug 27 '13 at 18:14