270 likes | 446 Views
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 Results
E N D
CS 445 / 645Introduction to Computer Graphics Lecture 10 Camera Models
Where are we? • Rendering Pipeline ModelingTransformation Display Illumination Rasterization ViewingTransformation Projection Clipping
Pinhole Camera • Ingredients • Box • Film • Hole Punch • Results • Pictures! www.kodak.com www.debevec.org www.pinhole.org
Pinhole Camera • Non-zero sized hole Multiple rays of projection Pinhole Film Plane
Pinhole Camera • Theoretical Pinhole One ray of projection Pinhole Film Plane
Pinhole Camera • Field of View Pinhole Field of View FocalLength Film Plane
Pinhole Camera • Field of View Pinhole FocalLength Field of View Film Plane
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
How tall shouldthis bunny be? Perspective Projection ProjectionPlane COP
Perspective Projection • The geometry of the situation is that of similar triangles. View from above: • What is x’ ? Viewplane X P (x, y, z) x’ = ? (0,0,0) Z d
Perspective Projection • Desired result for a point [x, y, z, 1]T projected onto the view plane: • What could a matrix look like to do this?
A Perspective Projection Matrix • Answer:
A Perspective Projection Matrix • Example: • Or, in 3-D coordinates:
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 • Infinite focal length • No perspective convergence
Pipeline Modelview Projection PerspectiveDivision 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 • ymin • ymax • near • far • Camera looks along –z • min/max need not be symmetric about any axis • 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 • right • bottom • top • near • far • (left, bottom) and (right, top) define dimensions of projection plane • near and far used to clip
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