Sunday, September 27, 2015

opengl - What is the purpose of the canonical view volume?


I'm currently learning OpenGL and haven't been able to find an answer to this question.


After the projection matrix is applied to the view space, the view space is "normalized" so that all the points lie within the range [-1, 1]. This is generally referred to as the "canonical view volume" or "normalized device coordinates".


While I've found plenty of resources telling me about how this happens, I haven't seen anything about why it happens.


What is the purpose of this step?



Answer



The most important is that it converts yours points(vertices) from 3D world space to 2D screen space.


That means that after vertex is multiplied with this matrix X and Y coords are position on the screen (between [-1, 1]) and Z is the depth. Z is used for depth-buffer and identifies how far is vertex (or fragment) from your cameras near plane.


Projection means that vertices which are more near from near plane are more far from middle of the screen -> triangle more near to camera appears to be bigger that one that is far. And this is based on yours field of view - you are entering it in some createProjectionMatrix function or createFrustum. It works that it shears and scales yours camera frustum and vertices in it into unit cube. Values that are greater than 1 and smaller than -1 are not displayed.


Also keeps pixel aspect ratio, so pixel can be sqaure. That is simple. It just shears camera frustum like this: more wider screen -> more vertical shear and vice versa.



Simple answer:
It defines yours camera frustum and is good to:



  • make objects which are near to you look bigger than objects that are far from you.

  • keep pixel aspect ratio - Everybody likes square pixel right? :)


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...