1 / 23

Projection Matrices

Projection Matrices. Mohan Sridharan Based on slides created by Edward Angel. Objectives. Derive the projection matrices used for standard OpenGL projections. Introduce oblique projections. Introduce projection normalization. Projection Normalization.

chynna
Download Presentation

Projection Matrices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Projection Matrices Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics

  2. Objectives • Derive the projection matrices used for standard OpenGL projections. • Introduce oblique projections. • Introduce projection normalization. CS4395: Computer Graphics

  3. Projection Normalization • Convert all projections to orthogonal projections with the default view volume. • The same pipeline of operations for all types of projections  • Clip against simple cube regardless of type of projection. • Simplifies clipping because sides of the object are aligned with coordinate axes. • Delay final projection until end: important for hidden-surface removal. CS4395: Computer Graphics

  4. Projection Normalization • Work in 4D using homogeneous coordinates. • Convert all projections into orthogonal projections: • Distort objects such that the orthogonal projection of distorted objects is the same as desired projection of original objects. • Concatenation of normalization matrix (for distortion) and orthogonal projection matrix yields desired homogeneous coordinate matrix. CS4395: Computer Graphics

  5. Pictorial Representation CS4395: Computer Graphics

  6. Pipeline View Stay in 4D coordinates for both the modelview and projection transformations (nonsingular transformations). modelview transformation projection transformation perspective division 4D  3D nonsingular clipping projection 3D  2D against default cube CS4395: Computer Graphics

  7. Orthogonal Normalization glOrtho(left,right,bottom,top,near,far) Normalization find transformation to convert specified clipping volume to default. CS4395: Computer Graphics

  8. Orthogonal Matrix • Two steps: • Move center to origin: T(-(left + right)/2, -(bottom + top)/2, (near + far)/2)) • Scale to have sides of length 2: S(2/(right-left), 2/(top-bottom), 2/(near-far)) P = ST = CS4395: Computer Graphics

  9. Final Projection • Set z =0 • Equivalent to the homogeneous coordinate transformation: • General orthogonal projection in 4D: Morth = P = MorthST CS4395: Computer Graphics

  10. Oblique Projections • The OpenGL projection functions cannot produce general parallel projections such as: • However the cube it appears to have been sheared. • Oblique Projection = Shear + Orthogonal Projection! CS4395: Computer Graphics

  11. General Shear side view top view CS4395: Computer Graphics

  12. Shear Matrix • For x-y shear (z values unchanged): • Projection matrix: • General case: • See Section 5.8. H(q,f) = P = MorthH(q,f) P = MorthSTH(q,f) CS4395: Computer Graphics

  13. Equivalency CS4395: Computer Graphics

  14. Effect on Clipping • Projection matrix P = STH transforms the original clipping volume to the default clipping volume. object top view z = 1 DOP DOP x = -1 x = 1 far plane z = -1 clipping volume distorted object (projects correctly) near plane CS4395: Computer Graphics

  15. Simple Perspective • Consider a simple perspective : COP at origin, the near clipping plane at z = -1, and a 90o field of view determined by planes: x =z, y = z. CS4395: Computer Graphics

  16. Perspective Matrices • Simple projection matrix in homogeneous coordinates: • This matrix is independent of the far clipping plane. M = CS4395: Computer Graphics

  17. Generalization (Section 5.9) • Perspective normalization matrix: • After perspective division, the point (x, y, z, 1) goes to: • Orthogonal projection to the desired point regardless of • and . N = CS4395: Computer Graphics

  18. Picking a and b • If we pick: • The near plane is mapped toz = -1 • The far plane is mapped toz =1 • The sides are mapped tox =  1, y =  1 • The new clipping volume is the default volume. a = b = CS4395: Computer Graphics

  19. Normalization Transformation original clipping volume distorted object projects correctly original object new clipping volume CS4395: Computer Graphics

  20. Normalization and Hidden-Surface Removal • The perspective projection matrices are chosen such that if z1 > z2 in the original clipping volume then for the transformed points: z1’ > z2’ • Thus hidden surface removal works if the normalization transformation is applied first. • However, the formula z’’ = -(a + b/z) implies that the distances are distorted by the normalization which can cause numerical problems if the near distance is small. CS4395: Computer Graphics

  21. OpenGL Perspective • Function glFrustum allows for an un-symmetric viewing frustum (although gluPerspective does not). CS4395: Computer Graphics

  22. 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 needs only a orthogonal transformation: • See Section 5.9.2. P = NSH N = previously defined perspective matrix shear and scale CS4395: Computer Graphics

  23. Recap: Why do we do it this way? • Normalization allows for a single pipeline for both perspective and orthogonal viewing. • Stay in 4D homogeneous coordinates as long as possible to retain three-dimensional information needed for hidden-surface removal and shading. • Simplifies clipping. CS4395: Computer Graphics

More Related