GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections 1
Viewing Graphics display devices are 2D rectangular screens Hence we need to understand how to transform our 3D world to a 2D surface This involves: selecting the observer position (or camera position) selecting the view plane (or camera film plane) selecting the type of projection 2
Perspective Projections There are two types of projection: perspective and parallel In a perspective projection, object positions are projected onto the view plane along lines which converge at the observer P1 P1’ camera P2 P2’ view plane 3
Parallel Projection In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallel P1 P2 view plane 4
Perspective and Parallel Projection Parallel projection preserves the relative proportions of objects, but does not give a realistic view Perspective projection gives realistic views, but does not preserve proportions Projections of distant objects are smaller than projections of objects of the same size which are closer to the view plane 5
Perspective and Parallel Projection
Puzzle
Another Example
Viewing Coordinate System Viewing is easier if we work in a viewing co-ordinate system, where the observer or camera position is on the z-axis, looking along the negative z-direction xV yV zV Camera is positioned at: (0 , 0, zC) 6
View Plane We assume the view plane is perpendicular to the viewing direction xv yv zv The view plane is positioned at: (0, 0, zVP) Let d = zC - zVP be the distance between the camera and the plane 7
Perspective Projection Calculation xv yv zv zV view plane Q camera yV zQ zVP zC looking along x-axis 8
Perspective Projection Calculation zV view plane Q camera yV P zQ zVP zC By similar triangles, yP / yQ = (zC - zVP) / (zC - zQ) and so yP = yQ * (zC - zVP) / (zC - zQ) or yP = yQ * d / (zC - zQ) xP likewise 9
Using Matrices and Homogeneous Coordinates We can express the perspective transformation in matrix form Point Q in homogeneous coordinates is (xQ, yQ, zQ, 1) We shall generate a point H in homogeneous coordinates (xH, yH, zH, wH), where wH is not 1 But the point (xH/wH, yH/wH, zH/wH, 1) is the same as H in homogeneous space This gives us the point P in 3D space, ie xP = xH/wH, sim’ly for yP 10
Transformation Matrix for Perspective xQ yQ zQ 1 xH yH zH wH = 1 0 0 0 0 1 0 0 0 0 -zVP/d zVPzC/d 0 0 -1/d zC/d Then xP = xH / wH ie xP = xH / ( (zC - zQ) / d ) xP = xQ / ( (zC - zQ) / d ) yP likewise 11
Exercises There are two special cases which you can now derive: camera at the origin (zC = 0) view plane at the origin (zVP = 0) Follow through the operations just described for these two cases, and write down the transformation matrices 12
Note for Later The original z co-ordinate of points is retained we need relative depth in the scene in order to sort out which faces are visible to the camera
Vanishing Points When a 3D object is projected onto a view plane using perspective, parallel lines in object NOT parallel to the view plane converge to a vanishing point vanishing point one-point perspective projection of cube view plane 13
One- and Two-Point Perspective Drawing
One-point Perspective This is: Trinity with the Virgin, St John and Donors, by Mastaccio in 1427 Said to be the first painting in perspective
Two-point Perspective Edward Hopper Lighthouse at Two Lights -see www.postershop.com
Parallel Projection - Two types Orthographic parallel projection has view plane perpendicular to direction of projection Oblique parallel projection has view plane at an oblique angle to direction of projection P1 P1 P2 P2 view plane view plane We shall only consider orthographic projection 14
Parallel Projection Calculation xv yv zv zV view plane Q yV zQ zVP looking along x-axis 15
Parallel Projection Calculation zV view plane Q yV P yP = yQ and similarly xP = xQ 16
Parallel Projection Calculation So this is much easier than perspective! xP = xQ yP = yQ zP = zVP The transformation matrix is simply 1 0 0 0 0 1 0 0 0 0 zVP/zQ 0 0 0 0 1 17
View Volumes - View Window Type of lens in a camera is one factor which determines how much of the view is captured wide angle lens captures more than regular lens Analogy in computer graphics is the view window, a rectangle in the view plane view window xv yv zv 18
View Volume - Front and Back Planes We will also typically want to limit the view in the zV direction We define two planes, each parallel to the view plane, to achieve this front plane (or near plane) back plane (or far plane) zV back plane front plane 19
View Frustum - Perspective Projection back plane view frustum view window camera front plane zV 20
View Volume - Parallel Projection back plane view volume view window front plane zV 21
View Volume The front and back planes act as important clipping planes Can be used to select part of a scene we want to view Front plane important in perspective to remove near objects which will swamp picture 22