Today Projecting 3 D to 2 D How is it that we see the world Observation Reflection Illumination Absorption 1 Modeling the Flow of Light in the World Light has a dual nature a form of EM radiation waves propagate from light source stream of particles called photons move along straight rays tracing straight rays is computationally more convenient Light is emitted from light sources and interacts with surfaces on impact with an object some is reflected and some is absorbed distribution of reflected light determines finish matte glossy composition of light reflected into eye determines color we see Incident light Some reaches eye Reflected light Some light is absorbed The Simplest Camera Pinhole Camera Mount a piece of film in a lightproof box with a single pinhole in it Pinhole focuses light on the film only select light rays make it through the hole note that image on film is flipped everything will be in perfect focus infinite depth of field You can try this at home film plate pinhole opaque box 2 Camera Model Will typically use pinhole camera model much easier to simulate than lenses simpler geometry of light rays But reverse the sense of image plane real pinholes cameras place pinhole between object and film plate we ll place the image plane in front of the focal point instead generally easier to deal with doesn t flip the image ray geometry is equivalent Physical Pinhole Model d Graphics Pinhole Model d Projection Mapping 3 D to 2 D Our scene models are in 3 D space and images are 2 D so we need some way of projecting 3 D to 2 D The fundamental approach planar projection first we define a plane in 3 D space this is the image plane or film plane then project scene onto this plane and map to the window viewport Need to address two basic issues how to define plane how to define mapping onto plane 3 Orthographic Projection Arguably the simplest projection image plane is perpendicular to one of the coordinate axes project onto plane by dropping that coordinate x y z x y or x z or y z OpenGL glOrtho left right bottom top near far assumes image plane perpendicular to z axis in other words it s the xy plane projects points x y z x y top also defines viewport mapping defines rectangle on xy plane left this gets mapped to window right bottom Perspective Projection But we naturally see things in perspective objects appear smaller the farther away they are lenses bend and hence focus incoming light in orthographic projection all rays are parallel We ve been using pinhole camera models draw rays thru focal point and points on object some of these lines will intersect the image plane this defines our projection into 2 D all points along a ray project to same point can project lines by projecting endpoints d 4 The Canonical Camera Configuration Want to derive perspective transformation in particular a matrix representation y x focal point image plane d First we fix a canonical camera focal point at origin looking along z axis image plane parallel to xy plane located distance d from origin called the focal length z Effect of Perspective Projection on Points We project points thru the line connecting them to the focal point given a point we want to know where this line hits the image plane y focal point 0 0 0 image plane z d object point x y z z 5 Effect of Perspective Projection on Points We project points thru the line connecting them to the focal point given a point we want to know where this line hits the image plane Can easily compute this using similar triangles y object point x y z image point d z x d z y d focal point 0 0 0 z Perspective Projection as a Transformation This homogeneous matrix performs perspective projection 1 0 P 0 0 0 1 0 0 0 0 1 1 d 0 0 0 0 It s operation on any given point is 1 0 0 0 0 1 0 0 0 0 1 1 d 0 x x 0 y y 0 z z 0 1 z d 6 Perspective Projection as a Transformation This homogeneous matrix performs perspective projection 1 0 P 0 0 0 1 0 0 0 0 1 1 d 0 0 0 0 And when we do the homogeneous division d x we get exactly the point we want x z y only keep x and y coordinates d y z z z d d 1 Completing the Projection The image plane itself is infinite must map a rectangular region of it to the viewport defined by left right top bottom coordinates We also customarily define near far clipping planes these are expressed as distances from the viewpoint they should always be positive nothing nearer than near will be drawn don t want to draw things behind the image plane nothing further than far will be drawn distance far near should be small use fixed precision numbers to represent depth between them OpenGL glFrustum left right bottom top near far 7 More Convenient Perspective Specification Could always use glFrustum left right bottom top near far this is certainly sufficient but it s inconvenient Generally want to use gluPerspective fovy aspect near far viewport is always centered about z axis specifies the field of view along the y axis y the angle made by the sides of the frustum and the aspect ratio of the viewport this is just width height z Viewing Volumes The sides of the viewport define an infinite pyramid focal point at apex extending outward through space Adding in the clipping planes we get a truncated pyramid this is called a frustum Can think of this as the viewing volume nothing outside of it is visible projection warps this to a rectangular prism 8 Example gluPerspective in Action cot 2 0 P 0 0 Y 0 0 cot 2 0 0 z1 z0 z0 z1 0 1 z0 0 2 z1 z0 z0 z1 0 0 z1 z0 z1 field of view fovy aspect ratio zNear and zFar 1 1 Z We Need More General Cameras So far we ve assumed a canonical camera configuration focal point at the origin image plane parallel to xy plane This is pretty limited we want greater flexibility deriving general projection matrices is painful but we can transform world so camera is canonical typically called the viewing transformation Naturally there are several ways of setting this up we ll focus on the OpenGL supported mechanism the one in the book is gratuitously complex 9 Specifying General Camera Configurations First we want to allow focal point to be anywhere in space call this position lookFrom or just from Next we need to specify the orientation of the camera define what it s pointing at lookAt lookAt lookFrom will define the axis of projection define vertical axis of image vUp essentially a twist parameter about the lookAt axis Converting Camera to Canonical Form Our camera is parameterized by three vectors lookFrom lookAt and …
View Full Document
Unlocking...