The purpose of Model View Projection Matrix

前端 未结 2 494
日久生厌
日久生厌 2020-11-28 01:23

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

2条回答
  •  伪装坚强ぢ
    2020-11-28 01:34

    Because matrices are convenient. Matrices help to convert locations/directions with respect to different spaces (A space can be defined by 3 perpendicular axes and an origin).

    Here is an example from a book specified by @legends2k in comments.

    The residents of Cartesia use a map of their city with the origin centered quite sensibly at the center of town and axes directed along the cardinal points of the compass. The residents of Dyslexia use a map of their city with the coordinates centered at an arbitrary point and the axes running in some arbitrary directions that probably seemed a good idea at the time. The citizens of both cities are quite happy with their respective maps, but the State Transportation Engineer assigned a task of running up a budget for the first highway between Cartesia and Dyslexia needs a map showing the details of both cities, which therefore introduces a third coordinate system that is superior to him, though not necessarily to anybody else.

    Here is another example,

    Assume that you have created a car object in a game with it's vertex positions using world's co-ordinates. Suppose you have to use this same car in some other game in an entirely different world, you have to define the positions again and the calculations will go complex. This is because you again have to calculate the positions of window, hood, headlight, wheels etc., in the car with respect to new world.

    See this video to understand the concepts of model, view and projection. (highly recommended)

    Then see this to understand how the vertices in the world are represented as Matrices and how they are transformed.

提交回复
热议问题