290 likes | 514 Views
GR2 Advanced Computer Graphics AGR. Lecture 3 Viewing - Projections. 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)
E N D
GR2Advanced Computer GraphicsAGR Lecture 3 Viewing - Projections
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
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
Parallel Projection • In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallel P1 P2 view plane
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
Perspective and Parallel Projection parallel perspective
yV xV zV 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 Camera is positioned at: (0 , 0, zC)
yv xv zv View Plane • We assume the view plane is perpendicular to the viewing direction The view plane is positioned at: (0, 0, zVP) Let d = zC - zVP be the distance between the camera and the plane
yv Q xv yV camera zv zV view plane Perspective Projection Calculation zQ zVP zC looking along x-axis
Q yV camera zV view plane Perspective Projection Calculation 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
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
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 ) ie xP = xQ / ( (zC - zQ) / d ) yP likewise
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
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
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
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 Parallel Projection - Two types P1 P1 P2 P2 view plane view plane We shall only consider orthographic projection
yv Q xv yV zv zV view plane Parallel Projection Calculation zQ zVP looking along x-axis
Q yV zV view plane Parallel Projection Calculation P yP = yQ and similarly xP = xQ
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
yv xv zv 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
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
View Frustum - Perspective Projection back plane view frustum view window camera front plane zV
View Volume - Parallel Projection back plane view volume view window front plane zV
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