How does the projection matrix work?

I need to write a document for my A-Levels about 3D programming. But I had a serious problem with understanding the matrix of the perspective projection of the Matrix , and I need to explain the Matrix in detail. I searched a lot of YouTube websites and videos on this topic, but very few even tried to answer the question why the Matrix has these meanings in this place. Based on this http://www.songho.ca/opengl/gl_projectionmatrix.html , I was able to find out how the w-series works, but I do not understand the other three.

I decided to use the โ€œsimplerโ€ version only for symmetric viewports (right coordinate):

! [<code> r + l = 0, </code> rl = 2r <code> (width); </code> t + b = 0 <code>, </code> tb = 2t <code> (height ); </code> [n / r 0 0 0; 0 n / t 0 0; 0 0 - (f + n) / (f-n) - (2fn) โ€‹โ€‹/ (f-n); 0 0 -1 0] `[1]

I am very grateful for every attempt to explain the first three lines to me!

+6
source share
1 answer

The main reason for the matrix is โ€‹โ€‹the mapping of three-dimensional coordinates into a two-dimensional plane and smaller distant objects.

A much simpler matrix is โ€‹โ€‹enough for this (if your camera is at the origin and looks at the Z axis):

1 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 

After multiplying by this matrix and then renormalizing the w coordinate, you have exactly that. Each point x,y,z,1 becomes x/z,y/z,0,1 .

However, there is no depth information (Z - 0 for all points), so the depth buffer / filter will not work. To do this, we can use the parameter a for the matrix so that the depth information remains available:

 1 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0 

Now the resulting point contains the reciprocal depth in the Z-coordinate. Each point x,y,z,1 becomes x/z,y/z,1/z,1 .

Additional parameters are the result of comparing the coordinates in the device field (-1,-1,-1) - (1,1,1) (a bounding box in which, if you are outside of it, the point will not be drawn), using the scale and transfer.

+8
source

Source: https://habr.com/ru/post/974806/


All Articles