Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The purpose of Model View Projection Matrix

Tags:

opengl

directx

3d

For what purposes are we using Model View Projection Matrix? Why do shaders require Model View Projection Matrix?

like image 800
Yuriy Vikulov Avatar asked Apr 05 '11 10:04

Yuriy Vikulov


People also ask

What is the point of the projection matrix?

First projection matrices are used to transform vertices or 3D points, not vectors. Using a projection matrix to transform vector doesn't make any sense. These matrices are used to project vertices of 3D objects onto the screen in order to create images of these objects that follow the rules of perspective.

What is model view matrix in OpenGL?

The matrix M, that contains every translations, rotations or scaling, applied to an object is named the model matrix in OpenGL. Basically, instead of sending down the OpenGL pipeline two, or more, geometrical transformation matrices we'll send a single matrix for efficiency.

What is the difference between the model view matrix and projection matrix in OpenGL?

View Matrix defines the position(location and orientation) of the camera, while model matrix defines the frame's position of the primitives you are going to draw. Projection matrix defines the characteristics of your camera, such as clip planes, field of view, projection method etc.


1 Answers

The model, view and projection matrices are three separate matrices. Model maps from an object's local coordinate space into world space, view from world space to camera space, projection from camera to screen.

If you compose all three, you can use the one result to map all the way from object space to screen space, making you able to work out what you need to pass on to the next stage of a programmable pipeline from the incoming vertex positions.

In the fixed functionality pipelines of old, you'd apply model and view together, then work out lighting using another result derived from them (with some fixes so that e.g. normals are still unit length even if you've applied some scaling to the object), then apply projection. You can see that reflected in OpenGL, which never separates the model and view matrices — keeping them as a single modelview matrix stack. You therefore also sometimes see that reflected in shaders.

So: the composed model view projection matrix is often used by shaders to map from the vertices you loaded for each model to the screen. It's not required, there are lots of ways of achieving the same thing, it's just usual because it allows all possible linear transforms. Because of that, a lesser composed version of it was also the norm in ye olde fixed pipeline world.

like image 95
Tommy Avatar answered Oct 02 '22 21:10

Tommy