Unformatted text preview:

118. Projections and Z-buffers2ReadingRequired: Watt, Section 5.2.2 – 5.2.4, 6.3, 6.6 (esp. intro and subsections 1, 4, and 8–10), Further reading: Foley, et al, Chapter 5.6 and Chapter 6 David F. Rogers and J. Alan Adams, Mathematical Elements for Computer Graphics, 2ndEd., McGraw-Hill, New York, 1990, Chapter 2.  I. E. Sutherland, R. F. Sproull, and R. A. Schumacker, A characterization of ten hidden surface algorithms, ACM Computing Surveys 6(1): 1-55, March 1974.33D Geometry PipelineBefore being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations...43D Geometry Pipeline (cont’d)5Projections transform points in n-space to m-space, where m<n.In 3-D, we map points from 3-space to the projection plane (PP) along projectorsemanating from the center of projection (COP): The center of projection is exactly the same as the pinhole in a pinhole camera.There are two basic types of projections: Perspective – distance from COP to PP finite Parallel – distance from COP to PP infiniteProjections6Parallel projectionsFor parallel projections, we specify a direction of projection (DOP) instead of a COP.There are two types of parallel projections: Orthographic projection –DOP perpendicular to PP Oblique projection – DOP not perpendicular to PPWe can write orthographic projection onto the z=0plane with a simple matrix.But normally, we do not drop the z value right away. Why not?'1000'0100100011xxyyz⎡⎤⎡⎤⎡⎤⎢⎥⎢⎥⎢⎥⎢⎥=⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥⎣⎦⎣⎦⎣⎦7Properties of parallel projectionProperties of parallel projection: Not realistic looking Good for exact measurements Are actually a kind of affine transformation• Parallel lines remain parallel• Angles not (in general) preserved Most often used in CAD, architectural drawings, etc., where taking exact measurement is important8Derivation of perspective projectionConsider the projection of a point onto the projection plane:By similar triangles, we can compute how much the x and y coordinates are scaled:[Note: Watt uses a left-handed coordinate system, and he looks down the +z axis, so his PP is at +d.]9Homogeneous coordinates revisitedRemember how we said that affine transformations work with the last coordinate always set to one.What happens if the coordinate is not one? We divide all the coordinates by w:If w = 1, then nothing changes.Sometimes we call this division step the “perspective divide.”///1xxwyywzzww⎡⎤ ⎡ ⎤⎢⎥ ⎢ ⎥⎢⎥ ⎢ ⎥→⎢⎥ ⎢ ⎥⎢⎥ ⎢ ⎥⎣⎦ ⎣ ⎦10Homogeneous coordinates and perspective projectionNow we can re-write the perspective projection as a matrix equation:After division by w, we get:Again, projection implies dropping the zcoordinate to give a 2D image, but we usually keep it around a little while longer.⎡⎤⎡⎤⎡ ⎤ ⎡ ⎤⎢⎥⎢⎥⎢ ⎥ ⎢ ⎥⎢⎥==⎢⎥⎢ ⎥ ⎢ ⎥⎢⎥⎢⎥⎢ ⎥ ⎢ ⎥−−⎢⎥⎣⎦⎣ ⎦ ⎣ ⎦⎣⎦' 1000'0100'001/0 /1xxxyyyzwdzd''11xdzxyydz⎡⎤−⎢⎥⎡⎤⎢⎥⎢⎥⎢⎥=−⎢⎥⎢⎥⎢⎥⎢⎥⎣⎦⎢⎥⎢⎥⎣⎦11Projective normalizationAfter applying the perspective transformation and dividing by w, we are free to do a simple parallel projection to get the 2D image.What does this imply about the shape of things after the perspective transformation + divide?12Vanishing pointsWhat happens to two parallel lines that are not parallel to the projection plane?Think of train tracks receding into the horizon...The equation for a line is:After perspective transformation we get:10xxyyzzpvpvttpv⎡⎤ ⎡⎤⎢⎥ ⎢⎥⎢⎥ ⎢⎥=+ = +⎢⎥ ⎢⎥⎢⎥ ⎢⎥⎣⎦ ⎣⎦lp v'''( )/xxyyzzxptvyptvwptvd+⎡⎤⎡ ⎤⎢⎥⎢ ⎥=+⎢⎥⎢ ⎥⎢⎥⎢ ⎥−+⎣⎦⎣ ⎦13Vanishing points (cont'd)Dividing by w:Letting t go to infinity:We get a point!What happens to the line l = q + tv?Each set of parallel lines intersect at a vanishing point on the PP. Q: How many vanishing points are there?'''1xxzzyyzzptvdptvxptvydptvw+⎡⎤−⎢⎥+⎢⎥⎡⎤+⎢⎥⎢⎥=−⎢⎥⎢⎥+⎢⎥⎢⎥⎣⎦⎢⎥⎢⎥⎢⎥⎣⎦14Properties of perspective projectionsThe perspective projection is an example of a projective transformation.Here are some properties of projective transformations: Lines map to lines Parallel lines do notnecessarily remain parallel Ratios are notpreservedOne of the advantages of perspective projection is that size varies inversely with distance – looks realistic.A disadvantage is that we can't judge distances as exactly as we can with parallel projections.Q: Why did nature give us eyes that perform perspective projections? Q: Do our eyes “see in 3D”?15Z-bufferWe can use projections for hidden surface elimination.The Z-buffer' or depth buffer algorithm [Catmull, 1974] is probably the simplest and most widely used of these techniques.Here is pseudocode for the Z-buffer hidden surface algorithm:for each pixel (i,j) doZ-buffer [i,j] ← FARFramebuffer[i,j] ← <background color>end forfor each polygon A dofor each pixel in A doCompute depth z and shade s of A at (i,j)if z > Z-buffer [i,j] thenZ-buffer [i,j] ←zFramebuffer[i,j] ←send ifend forend for16Z-buffer, cont'dThe process of filling in the pixels inside of a polygon is called rasterization.During rasterization, the z value and shade s can be computed incrementally (fast!).Curious fact: Described as the “brute-force image space algorithm” by [SSS] Mentioned only in Appendix B of [SSS] as a point of comparison for hugememories, but written off as totally impractical.Today, Z-buffers are commonly implemented in hardware.17Ray tracing vs. Z-BufferRay tracing:for each ray {for each object {test for intersection}}Z-Buffer:for each object {project_onto_screen;for each ray {test for intersection}}In both cases, optimizations are appliedto the inner loop.Biggest differences:- ray order vs. object order- Z-buffer does some work in screen space- Z-buffer restricted to rays from a singlecenter of projection!18Gouraud vs. Phong interpolationDoes Z-buffer graphics hardware do a full shading calculation at every point? Not in the past, but this has changed in the last three years!Smooth surfaces are often approximated by polygonal facets, because: Graphics hardware generally wants polygons (esp. triangles). Sometimes it easier to write ray-surface intersection algorithms for


View Full Document

UT CS 384G - Projections and Z-buffers

Documents in this Course
Shading

Shading

27 pages

Shading

Shading

27 pages

Load more
Download Projections and Z-buffers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Projections and Z-buffers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Projections and Z-buffers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?