CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Where are we? Rendering Pipeline Modeling Transformation Display Illumination Rasterization Viewing Transformation Projection Clipping Pinhole Camera Ingredients • Box • Film • Hole Punch www.kodak.com Results www.debevec.org • Pictures! www.pinhole.org Pinhole Camera Non-zero sized hole Pinhole Film Plane Multiple rays of projection Pinhole Camera Theoretical Pinhole One ray of projection Pinhole Film Plane Pinhole Camera Field of View Focal Length Film Plane Pinhole Field of View Pinhole Camera Field of View Focal Length Film Plane Pinhole Field of View Moving the Film Plane Varying distance to film plane What does this do? Pinhole d1 Field of View d2 Film Plane Adding a Lens • Pinhole camera has small aperture (lens opening) – It’s hard to get enough light to expose the film • Lens permits larger apertures • Lens permits changing distance to film plane without actually moving the film plane Computer Graphic Camera We use • Center of Projection (COP) • Projection Plane COP Projection Plane Moving the COP Perspective vs. Orthographic Views Perspective When COP at infinity, Orthographic View Multi-point Perspective One-point Perpective • One Vanishing Point Two-point Perspective • Two Vanishing Points http://www.sanford-artedventures.com/create/tech_2pt_perspective.html Perspective Projection Our camera must model perspective Perspective Projection Projection Plane How tall should this bunny be? COP Perspective Projection The geometry of the situation is that of similar triangles. View from above: View plane X x’ = ? (0,0,0) Z d What is x’ ? P (x, y, z) Perspective Projection Desired result for a point [x, y, z, 1]T projected onto the view plane: x' x , d z dx x x' , z z d y' y d z dy y y' , z z d What could a matrix look like to do this? zd A Perspective Projection Matrix Answer: 1 0 Mperspective 0 0 0 1 0 0 0 1 0 1d 0 0 0 0 A Perspective Projection Matrix Example: x 1 y 0 z 0 z d 0 0 1 0 0 0 1 0 1d Or, in 3-D coordinates: 0 x 0 y 0 z 0 1 x , z d y , z d d Homogeneous Coordinates The role of w in (x, y, z, w) • All 3-D points are described with a four vector • All 3-D tranformations are represented with 4x4 matrix • When projected to screen coordinates (rasterization) – x, y, and z are divided by point’s w value • This allows us to perform perspective foreshortening while preserving the reversibility of the mapping – We can retrieve x, y, and z by multiplying by w Perspective Projection • Perspective projection matrix is not affine – Parallel lines not preserved • Perspective projection is irreversible – Many 3-D points can be mapped to same (x, y, d) on the projection plane – No way to retrieve the unique z values Orthographic Camera Projection • Camera’s back plane parallel to lens xp x y p y z p 0 • Infinite focal length • No perspective convergence x p 1 y 0 p z p 0 1 0 0 0 0 x 1 0 0 y 0 0 0 z 0 0 1 1 Pipeline Modelview Projection Perspective Division Clip Rasterize OpenGL Pipeline • Projection matrix is stored in GL_PROJECTION stack – This controls ‘type’ of camera – All vertices are multiplied by this matrix • GL_MODELVIEW controls camera location – All vertices are multiplied by this matrix Making GL_PROJECTION glFrustum – for perspective projections • xmin • xmax • Camera looks along –z • ymin • min/max need not be symmetric about any axis • ymax • near • far • near and far planes are parallel to plane z=0 Making GL_PROJECTION gluPerspective – for perspective projections • fovy • aspect • near • far • fovy is the angle between top and bottom of viewing volume • aspect is ratio of width over height • This volume is symmetrical • View plane is parallel to camera Making GL_PROJECTION glOrtho – for orthographic projections • left • bottom • (left, bottom) and (right, top) define dimensions of projection plane • top • near and far used to clip • right • near • far Making GL_PROJECTION It’s like any other matrix • These OpenGL commands just build a matrix for you • You could build the matrix yourself • You can multiply the GL_PROJECTION matrix by any affine transformation you wish – Not typically needed