Viewing and Projection
Parallel Projection
Parallel Projections (known aliases): Orthographic or Isometric Projection
Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Oblique Projection Arbitrary relationship between projectors and projection plane Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Parallel Projections (known aliases): Oblique Projection L
Perspective Projection Projectors coverge at center of projection Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009
Perspective Projection foreshortening - the farther an object is from the camera , the smaller it appears in the final image
Perspective Projection The geometry of the situation is that of similar triangles. View from above: What is x’ ? P (x, y, z) X Z View plane (0,0,0) x’ = ? d
Perspective Projection Top View P=(xp,yp,zp) P’=(x’,y’,z’) CoP=(xc,yc,zc) xp x’ z’ zp
Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009 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 Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009 Perspective Matrices Simple projection matrix in homogeneous coordinates Note that this matrix is independent of the far clipping plane M = Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009 Generalization N = after perspective division, the point (x, y, z, 1) goes to x’’ = x/z y’’ = y/z Z’’ = -(a+b/z) which projects orthogonally to the desired point regardless of a and b Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
What the Perspective Matrix means Note: Normalized Device Coordinates are a LEFT-HANDED Coordinate system
Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009 Picking a and b If we pick a = b = the near plane is mapped to z = -1 the far plane is mapped to z =1 and the sides are mapped to x = 1, y = 1 Hence the new clipping volume is the default clipping volume Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
Normalization Transformation distorted object projects correctly new clipping volume original object original clipping volume Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009 OpenGL Perspective glFrustum allows for an unsymmetric viewing frustum (although gluPerspective does not) Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
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 P = NSH our previously defined perspective matrix shear and scale Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
glFrustum Matrix
Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009 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 Angel: Interactive Computer Graphics 5 © Addison-Wesley 2009
What the Perspective Matrix means Note: Normalized Device Coordinates are a LEFT-HANDED Coordinate system
Graphics Pipeline So Far Object Object Coordinates Transformation Object -> World World World Coordinates Projection Xform World -> Projection Camera Projection Coordinates Normalize Xform & Clipping Projection -> Normalized Viewport Normalized Coordinates Viewport Transform Normalized -> Device Screen Device Coordinates
What happens to an object... Transformation Object -> World Object Object Coordinates World World Coordinates
What happens to an object... Transformation - Modelview World -> Eye/Camera World World Coordinates Viewport Viewport Coordinates
What happens to an object... Transformation - Projection (Includes Perspective Divide) Eye/Camera ->View Plane Viewport Viewport Coordinates Rasterization Scan Converting Triangles