The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Perspective projection (outline) 1 The graphics pipeline: part I 2 Windowing transforms 3 Perspective transform 4 Camera transformation 5 Wrap-up Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Projecting from arbitrary camera positions Camera transformation Orthographic projection and the canonical view volume Windowing transform The graphics pipeline: part I Given an arbitrary camera position, we want to display the objects in the model in an image The projection should be perspective projection. Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Projecting from arbitrary camera positions Camera transformation Orthographic projection and the canonical view volume Windowing transform Camera transformation We simplify by moving the camera viewpoint to the origin, such that we look into the direction of the negative z-axis. −Z Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Projecting from arbitrary camera positions Camera transformation Orthographic projection and the canonical view volume Windowing transform Orthographic projection Orthographic projection is a lot simpler than perspective projection, so we transform the clipped view frustum to an axis-parallel box −Z Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Projecting from arbitrary camera positions Camera transformation Orthographic projection and the canonical view volume Windowing transform The canonical view volume To simplify our calculations, we transform to the canonical view volume (1, 1) (−1, −1) Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Projecting from arbitrary camera positions Camera transformation Orthographic projection and the canonical view volume Windowing transform Windowing transform We apply a windowing transform to display the square [−1, 1] × [−1, 1] onto an m × n image. Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Projecting from arbitrary camera positions Camera transformation Orthographic projection and the canonical view volume Windowing transform The graphics pipeline: part I Every step in the sequence can be represented by a matrix operation, so the whole process can be applied by performing a single matrix operation! (Well: almost.) Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up The canonical view volume The orthographic view volume The orthographic projection matrix The canonical view volume The canonical view volume is a 2 × 2 × 2 box, centered at the origin. Vertices in the canonical view volume are orthographically projected onto an m × n image. Graphics, 1st period 2006/2007 (1, 1, −1) y The clipped view frustum is transformed to this box (and the objects within the view frustum undergo the same transformation). −z x (1, −1, −1) (−1, −1, 1) Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up The canonical view volume The orthographic view volume The orthographic projection matrix Mapping the canonical view volume (1, 1) We need to map the square [−1, 1]2 onto a rectangle [− 12 , m − 21 ] × [− 12 , n − 12 ]. (−1, −1) The following matrix takes care of that: m 1 0 m 2 2 − 2 0 n n − 1 2 2 2 0 0 1 n m Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up The canonical view volume The orthographic view volume The orthographic projection matrix The orthographic view volume (r, t, f ) The orthographic view volume is an axis-aligned box [l, r] × [b, t] × [n, f ]. (l, b, n) Transforming it to the canonical view volume is done by 2 r−l 0 0 0 0 2 t−b 0 0 0 0 2 n−f 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 (1, 1, −1) y − l+r 2 − b+t 2 n+f − 2 1 −z x (1, −1, −1) (−1, −1, 1) Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up The canonical view volume The orthographic view volume The orthographic projection matrix The orthographic projection matrix We can combine the matrices into one: M om= 2 0 0 0 0 0 0 n 2 m 2 n 2 0 0 1 0 2 − 21 r−l 0 − 21 0 0 1 0 0 2 t−b 0 0 0 0 2 n−f 0 0 1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 − l+r 2 − b+t 2 n+f − 2 1 Given a point p in the orthographic view volume, we map it to a pixel [i, j] as follows: xp yp zcanonical = Mo zp 1 1 i j Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Transforming the view frustum Perspective transform matrix Homogeneous coordinates Transforming the view frustum We have to transform the view frustum into the orthographic view volume. The transformation needs to Map lines through the origin to lines parallel to the z axis Map points on the viewing plane to themselves. Map points on the far plane to (other) points on the far plane. Preserve the near-to-far order of points on a line. Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Transforming the view frustum Perspective transform matrix Homogeneous coordinates Transforming the view frustum (cf. book, fig. 7.12) Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Transforming the view frustum Perspective transform matrix Homogeneous coordinates Transforming the view frustum (cf. book, fig. 7.10) Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Transforming the view frustum Perspective transform matrix Homogeneous coordinates Perspective transform matrix The following matrix does the trick: 1 0 Mp = 0 0 0 1 0 0 0 0 n+f n 1 n 0 0 −f 0 x x y = n+fy We have Mp z z − f n z 1 n Hmmmm. . . is that what we want. . . ? Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Transforming the view frustum Perspective transform matrix Homogeneous coordinates Homogeneous coordinates We have seen homogeneous coordinates before, but so far, the fourth coordinate of a 3D point has alway been 1. In general, however, the homogeneous representation of a point (x, y, z) in 3D is (hx, hy, hz, h). Choosing h = 1 has just been a convenience. So we have: nx x x z ny y y z Mp z = z n+f − f homogenize −−−−−−−−→ n + f − n z 1 1 n Graphics, 1st period 2006/2007 fn z Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Transforming the view frustum Perspective transform matrix Homogeneous coordinates Transforming the view frustum (cf. book, fig. 7.9) Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Transforming the view frustum Perspective transform matrix Homogeneous coordinates Homogeneous coordinates Note: moving and scaling still work properly For example: translation 1 0 0 0 0 1 0 0 x + tx hx hx + htx 0 tx 0 ty hy = hy + hty homogenize y + ty hz hz + htz −−−−−−−−→ z + tz 1 tz 1 0 1 h h Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Aligning coordinate systems Transformation matrix Aligning coordinate systems Given a camera coordinate system with origin e and orthonormal base (u, v, w), we need to tranform objects in world space coordinates into objects in camera coordinates. This can alternatively be considered as aligning the canonical coordinate system with the camera coordinate system. Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Aligning coordinate systems Transformation matrix Camera transformation The required transformation is taken care of by Mv = xu xv xw 0 yu yv yw 0 zu zv zw 0 0 1 0 0 −xe 0 1 0 −ye 0 0 0 0 1 −ze 1 0 0 0 1 Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection The graphics pipeline: part I Windowing transforms Perspective transform Camera transformation Wrap-up Wrap-up If we combine all steps, we get: compute Mo compute Mv compute Mp M = Mo Mp Mv for each line segment (ai , bi ) do p = Mai q = Mbi drawline(xp /hp , yp /hp , xq /hq , yq /hq ) Graphics, 1st period 2006/2007 Lecture 6: Orthographic and perspective projection
© Copyright 2026 Paperzz