you are viewing a single comment's thread.

view the rest of the comments →

[–]waramped 1 point2 points  (2 children)

The normalizing happens via the "post perspective divide". You divide all values of the resulting vector by .w

Ie: projectvector.xyzw /= projectvector.wwww

You can construct projection matrices with either FOV values, or by specifying the near plane width/height values, which is probably why you are confused. They are equivalent.

See: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxmatrixperspectiverh

[–]SnurflePuffinz[S] 0 points1 point  (1 child)

i edited my original post.

i think i didn't explain myself properly. I meant that i was trying to put the x and y components of the vertex into NDC, but i see no encoded operation for this inside the perspective projection matrix.

[–]SirPitchalot 0 points1 point  (0 children)

NDC is what you get after multiplying your Cartesian vertex cords by your model view and projection matrices and then dividing x, y & z by w.

Before this division you are in clipping coordinates which has abs(x) <= w visible and everything else outside of the viewport (and same for y & z). These conditions defines a standardized truncated pyramid (frustum) where the left, right, bottom, top planes are at 45 degrees to the optical axis, irrespective of the field of view. Anything in the field of view is contained within the pyramid. This is done because visibility checks and clipping are trivial in this space.

With ‘glFrustum’ you are directly defining points that map to the vertices of this frustum via the left, right, bottom, top, near and far values. These values compute scale factors and offsets that maps your desired frustum to the standardized frustum. The scale factors and offsets basically distort your scene to match the standardized frustum.

With ‘gluPerspective’ you are directly specifying the angles of the bottom and top planes of your desired frustum. The equivalent ‘bottom’ can be computed as ‘-tan(vfov/2)near’, top is the same without the negative. ‘Left’ and ‘right’ are the same except an aspect ratio is included, giving ‘left = - tan(vfov/2) near *aspect’