Foundations of Computer Graphics Online Lecture 5: Viewing Orthographic Projection Ravi Ramamoorthi Motivation We have seen transforms (between coord sstems) But all that is in 3D We still need to make a 2D picture Project 3D to 2D. How do we do this? This lecture is about viewing transformations Demo (Projection Tutorial) Nate Robbins OpenGL tutors Projection tutorial Download others What we ve seen so far Transforms (translation, rotation, scale) as 44 homogeneous matrices Last row alwas 0 0 0 1. Last w component alwas 1 For viewing (perspective), we will use that last row and w component no longer 1 (must divide b it) Projections To lower dimensional space (here 3D -> 2D) Preserve straight lines Trivial eample: Drop one coordinate (Orthographic) Brief discussion of nonlinear mapping in 1
Orthographic Projection Characteristic: Parallel lines remain parallel Simplest form: project onto - plane, drop coordinate Useful for technical drawings etc. In general We have a cuboid that we want to map to the normalied or square cube from [-1, +1] in all aes We have parameters of cuboid (l,r ; t,b; n,f) n l t r b f Translate Orthographic Perspective Orthographic Matri First center cuboid b translating Transformation Matri Then scale into unit cube n l t f r b Translate Transformation Matri Translation (centering) Orthographic Matri Looking down, f and n are negative (n > f) OpenGL convention: positive n, f, negate internall n l t f r b Translate 2
Final Result Foundations of Computer Graphics Online Lecture 5: Viewing Perspective Projection Ravi Ramamoorthi Brief discussion of nonlinear mapping in Perspective Projection Most common computer graphics, art, visual sstem Further objects are smaller (sie, inverse distance) Parallel lines not parallel; converge to single point A A Center of projection (camera/ee location) B B Slides inspired b Greg Humphres Overhead View of Our Screen In Matrices Note negation of coord (focal plane d) (Onl) last row affected (no longer 0 0 0 1) w coord will no longer = 1. Must divide at end Looks like we ve got some nice similar triangles here? 3
Verif Verif Foundations of Computer Graphics Online Lecture 5: Viewing Derivation of gluperspective Ravi Ramamoorthi Brief discussion of nonlinear mapping in Remember projection tutorial Viewing Frustum Far plane Near plane 4
Screen (Projection Plane) gluperspective Field of view (fov) width height gluperspective(fov, aspect, Near > 0, Far > 0) Fov, aspect control fov in, directions Near, Far control viewing frustum Aspect ratio = width / height Overhead View of Our Screen Overhead View of Our Screen Simplest form: In Matrices In Matrices Aspect ratio taken into account Homogeneous, simpler to multipl through b d Must map vals based on near, far planes (not et) A and B selected to map n and f to -1, +1 respectivel 5
Z mapping derivation Z mapping derivation Simultaneous equations? Z mapping derivation Z mapping derivation Simultaneous equations? Simultaneous equations? Mapping of Z is nonlinear Brief discussion of nonlinear mapping in Man mappings proposed: all have nonlinearities Advantage: handles range of depths (10cm 100m) Disadvantage: depth resolution not uniform More close to near plane, less further awa Common mistake: set near = 0, far = inft. Don t do this. Can t set near = 0; lose depth resolution. 6
Summar: The Whole Viewing Pipeline Model coordinates Model transformation World coordinates Camera Transformation (glulookat) Slide courtes Greg Humphres Ee coordinates Perspective Transformation (gluperspective) Screen coordinates Viewport transformation Window coordinates Raster transformation Device coordinates 7