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

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

1 Computer Graphics Chapter 8 3D Transformations.
1 View Shandong University Software College Instructor: Zhou Yuanfeng
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Projection Matrices modified by Ray Wisman Ed Angel Professor of Computer.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Projection Matrices Ed Angel
Objectives Derive the perspective projection matrices used for standard OpenGL projections Derive the perspective projection matrices used for standard.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
Representation CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping.
CS 480/680 Computer Graphics Representation Dr. Frederick C Harris, Jr. Fall 2012.
Computer Graphics (fall 2009)
1 Projection Matrices. 2 Objectives Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
1 E. Angel and D. Shreiner : Interactive Computer Graphics 6E © Addison-Wesley 2012 Classical Viewing Sai-Keung Wong ( 黃世強 ) Computer Science National.
Chapter 5 Viewing.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 67 Computer Graphics Three-Dimensional Graphics III.
Computer Graphics Bing-Yu Chen National Taiwan University.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
Demetriou/Loizidou – ACSC330 – Chapter 5 Viewing Dr. Giorgos A. Demetriou Computer Science Frederick Institute of Technology.
Computer Graphics I, Fall 2010 Computer Viewing.
Viewing and Projection. 2 3 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009  Introduce the classical views  Compare and contrast image.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing Hearn & Baker Chapter 7
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Viewing and Projection
Viewing and Projection
CS5500 Computer Graphics April 23, Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct.
CS552: Computer Graphics Lecture 11: Orthographic Projection.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Viewing.
Computer Viewing.
Isaac Gang University of Mary Hardin-Baylor
3D Computer Graphics (3080/GV10) Week 5-6 Tutorial 3
CSC461: Lecture 20 Parallel Projections in OpenGL
Projections and Normalization
Introduction to Computer Graphics with WebGL
CSC461: Lecture 19 Computer Viewing
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Isaac Gang University of Mary Hardin-Baylor
Projections and Hidden Surface Removal
Last Time Canonical view pipeline Projection Local Coordinate Space
Introduction to Computer Graphics with WebGL
Chap 3 Viewing Pipeline Reading:
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Viewing (Projections)
University of New Mexico
Viewing (Projections)
Computer Graphics Computer Viewing
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Viewing and Projection
Viewing and Projection
Presentation transcript:

Projection Matrices CS4395: Computer Graphics 1 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. CS4395: Computer Graphics 2

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 3

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 4

Pictorial Representation CS4395: Computer Graphics 5

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

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

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)) CS4395: Computer Graphics 8 P = ST =

Final Projection Set z =0 Equivalent to the homogeneous coordinate transformation: General orthogonal projection in 4D: CS4395: Computer Graphics 9 M orth = P = M orth ST

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 10

General Shear side view CS4395: Computer Graphics 11 top view

Shear Matrix For x-y shear ( z values unchanged): Projection matrix: General case: See Section 5.8. CS4395: Computer Graphics 12 H( ,  ) = P = M orth H( ,  ) P = M orth STH( ,  )

Equivalency CS4395: Computer Graphics 13

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

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

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

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

Picking  and  CS4395: Computer Graphics 18  =  = If we pick: The near plane is mapped to z = -1 The far plane is mapped to z =1 The sides are mapped to x =  1, y =  1 The new clipping volume is the default volume.

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

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

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

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 CS4395: Computer Graphics 22 P = NSH previously defined perspective matrix shear and scale N =

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 23