chapter 5.3
- Derive the projection matrices used for standard OpenGL projections
- Introduce oblique projections
- Introduce projection normalization
Normalization
- Rather than derive a different projection matrix for each type of projection, we can convert all projections to orthogonal projections with the default view volume
- This strategy allows us to use standard transformations in the pipeline and makes for efficient clipping
Pipeline View
Notes
- We stay in four-dimensional homogeneous coordinates through
both the model-view and projection transformations
- Both these transformations are non-singular
- Default to identity matrices (orthogonal view)
- Normalization lets us clip against simple cube regardless of type of projection
- Delay final projection until end
- Important for hidden-surface removal to retain depth information as long as possible
Orthogonal Normalization
glOrtho(left,right,bottom,top,near,far)
Orthogonal Matrix
- Two steps
- Move center to origin
- Scale to have sides of length 2
S(2/(right-left),2/(top-bottom),-2/(far -near))
T(-(left+right)/2, -(bottom+top)/2,(near+far)/2))
Final Projection
- Set z =0
- Equivalent to the homogeneous coordinate transformation
- Hence, general orthogonal projection in 4D is
P = MorthST
Oblique Projections
- The OpenGL projection functions cannot produce general parallel projections such as
- However if we look at the example of the cube it appears that the cube has been sheared
- Oblique Projection = Shear + Orthogonal Projection
General Shear
Shear Matrix
- xy shear (z values unchanged)
- Projection matrix :
- General case :
Effect on Clipping
- The projection matrix P = MSTH transforms the original clipping volume to the default clipping volume
Simple Perspective
- Consider a simple perspective with the COP at the origin,
the near clipping plane at z = -1, and a 90 degree field of
view determined by the planes
- x = ąz, y = ąz
Perspective Matrices
- Simple projection matrix in homogeneous coordinates
- Note that this matrix is independent of the far clipping plane
Generalization
Picking alpha and beta
Normalization Transformation
Normalization and Hidden-Surface Removal
- Although our selection of the form of the perspective matrices may appear somewhat arbitrary, it was chosen so that if z1 > z2 in the original clipping volume then for the transformed points z1 > z2
- Thus hidden surface removal works if we first apply the normalization transformation
- However, the formula Z'= -(a+b/z) implies that the distances are distorted by the normalization which can cause numerical problems especially if the near distance is small
OpenGL Perspective
- glFrustum allows for an unsymmetric viewing frustum (although gluPerspective does not)
OpenGL Perspective Matrix
- The normalization in glFrustum requires an initial shear to
form a right viewing pyramid, followed by a scaling to get the
normalized perspective volume. Finally, the perspective matrix
results in needing only a final orthogonal transformation
Why do we do it this way?
- Normalization allows for a single pipeline for both perspective and orthogonal viewing
- We stay in four dimensional homogeneous coordinates as long as possible to retain three-dimensional information needed for hidden-surface removal and shading
- We simplify clipping