Saturday, June 25, 2016

frustum.culling.clipping.

Cited

OpenGL Projection Matrix

(http://www.songho.ca/)


...
[OverView]

Therefore, we have to keep in mind that both clipping (frustum culling) and NDC transformations are integrated into GL_PROJECTION matrix. The following sections describe how to build the projection matrix from 6 parameters: left, right, bottom, top, near, and far boundary values...

Node that the frustum culling (clipping) is performed in the clip coordinates, just before dividing by Wc.  The clip coordinates, Xc, Yc, and Zc are tested by comparing with Wc. If any clip coordinate is less than -Wc, OR greater than +Wc, then the VERTEX will be discarded.   [(-Wc) <   Xc, Yc, Zc  <  (+Wc)]
A triangle clipped by frustum


Then, OpenGL will reconstruct the edges of the polygon where clipping occurs..

...
[Perspective Projection]
Perspective Frustum and Normalized Device Coordinates (NDC)
In perspective projection, a 3D point in a truncated pyramid frustum (eye coordinates) is mapped to a cube (NDC); the range of x-coordinate from [Left, Right] to [-1, +1], the y-coordinate from [Bottom, Top] to [-1, +1], and the z-coordinate from [Near, Far] to [-1, +1]..

Node that the eye coordinates are defined in the Right-Handed coordinate system, but NDC uses the Left-Handed coordinate system. That is, the Camera at the origin is looking along (-Z axis in eye space), but it is looking along (+Z axis in NDC).. Since glFrustum() accepts only  positive values of -near- and -far- distances, we need to negate them during the construction of GL_PROJECTION matrix.....

....

























No comments:

Post a Comment