1 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Perspective & scan-conversion  How to draw perspective images.

Slides:



Advertisements
Similar presentations
Lecture 8 Transparency, Mirroring
Advertisements

3D reconstruction.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
1 Computer Graphics Chapter 8 3D Transformations.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
1 Projection. 2 Model Transform Viewing Transform Modelview Matrix world coordinates Pipeline Review Focus of this lecture.
Connection to previews lesson… Previously, we studied rigid transformations, in which the image and preimage of a figure are congruent. In this lesson,
Projection Matrix Tricks Eric Lengyel Outline  Projection Matrix Internals  Infinite Projection Matrix  Depth Modification  Oblique Near Clipping.
Viewing and Projections
Announcements. Projection Today’s Readings Nalwa 2.1.
Lecture 7: Image Alignment and Panoramas CS6670: Computer Vision Noah Snavely What’s inside your fridge?
CS485/685 Computer Vision Prof. George Bebis
Computer Vision - A Modern Approach
Lecture 12: Projection CS4670: Computer Vision Noah Snavely “The School of Athens,” Raphael.
The Pinhole Camera Model
Game Engine Design ITCS 4010/5010 Spring 2006 Kalpathi Subramanian Department of Computer Science UNC Charlotte.
MSU CSE 803 Fall 2008 Stockman1 CV: 3D sensing and calibration Coordinate system changes; perspective transformation; Stereo and structured light.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
Cameras, lenses, and calibration
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
COMP 175: Computer Graphics March 24, 2015
Viewing and Projections
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
1 SIC / CoC / Georgia Tech MAGIC Lab Rossignac Textures and shadows  Generation  Mipmap  Texture coordinates,
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
2 COEN Computer Graphics I Evening’s Goals n Discuss the mathematical transformations that are utilized for computer graphics projection viewing.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
CS-378: Game Technology Lecture #2.1: Projection Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
Shadows. Shadows is important in scenes, consolidating spatial relationships “Geometric shadows”: the shape of an area in shadow Early days, just pasted.
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 09: SEQUENCES Section 3.2 Jarek Rossignac CS1050: Understanding.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Computer Graphics Lecture 08 Fasih ur Rehman. Last Class Ray Tracing.
1 Chapter 2: Geometric Camera Models Objective: Formulate the geometrical relationships between image and scene measurements Scene: a 3-D function, g(x,y,z)
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Graphic pipeline  Scan-conversion algorithm (high level)  Pixels.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Two Point Perspective…. Turn your paper sideways or “landscape view.”
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Ta: Ryan Freedman Sushma Kini Chi Zhou.  Pipeline  Clipping  Transformation, homogeneous coordinates  Lighting  Perspective  Viewing.
Perspective Drawings Linear perspective is a geometric method of representing the apparent diminishing of scale as the distance from object to viewer increases.
Instructor: Mircea Nicolescu Lecture 9
OpenGL and You I Cast, Therefore I Am. Ray Casting Idea is simple, implementation takes some work –Cast rays as if you were the camera –Determine intersection.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Shadows & occlusion  Shadow - occlusion duality  Floor shadows.
4. Affine transformations. Reading Required:  Watt, Section 1.1. Further reading:  Foley, et al, Chapter  David F. Rogers and J. Alan Adams,
Outline 3D Viewing Required readings: HB 10-1 to 10-10
Computer Graphics Projections.
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Rendering Pipeline Fall, 2015.
- Introduction - Graphics Pipeline
University of North Carolina at Greensboro
Intro to 3D Graphics.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
CENG 477 Introduction to Computer Graphics
CS451Real-time Rendering Pipeline
CSL 859: Advanced Computer Graphics
Lecture 13: Cameras and geometry
Last Time Canonical view pipeline Projection Local Coordinate Space
Congruence Transformations
Presentation transcript:

1 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Perspective & scan-conversion  How to draw perspective images  Scan-conversion  Difference between perspective projection and transformation  Inverse perspective transform

2 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Puzzle  Is the projection of the moon on a window glass a disk?  Justify your answer.

3 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Lecture Objectives  Perspective projection equation  Why is the perspective projection of a triangle a triangle  How to draw a 3-point perspective view of a box  Why you can’t use perspective projection for scan-conversion  Conversion of points and vectors to screen coordinates  Perspective transformation and its equations  Geometric construction of the perspective transform  Incremental z computation during scan-conversion  What does perspective transform map {0<z} to  Definition and properties of the horizon plane  What does perspective transform map {n<z<f} to

4 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Additional Objectives  Proof that perspective transform maps triangles onto triangles  Why (x,y,z)  (dx/(d+z), dy/(d+y), z) is not an option  Computing the correct eye position for looking at a picture of a block  The inverse of a perspective transform  The pre-image of {z=k}  The distribution of z-buffer round-off error as a function of z

5 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Drawing a 3-point perspective of a box (A)  Pick corner and 3 vanishing points

6 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Drawing a 3-point perspective of a box (B)  Join vanishing points to ray-points

7 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Drawing a 3-point perspective of a box (C)  Highlight the edges of the box

8 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Looking at a 3-point perspective of a box (A)  Where should the eye be?

9 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Looking at a 3-point perspective of a box (E)  At the corner of a box positioned to fit in this hole.

10 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Perspective projection equation  M is a projection if M(M(x))=M(x)  y’/d = y/(z+d)  y’ = dy/(d+z)  (x,y,z)  (dx/(d+z), dy/(d+z), 0)  Projection flattens 3D shape –into a 2D area of the screen EO Q’ Q d z y y’

11 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac The perspective projection of a triangle is…  Is it a triangle? If so, why? The rays from E that hit a triangle T form a tetrahedron If the screen separates E and T, the intersection of that tetrahedron with the screen is a triangle.

12 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Why not use perspective projection?  You lose the depth information –Can’t compute the z for each pixel –Can’t establish visibility using z-buffer

13 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Can we leave z alone? Q’ EO Q d So why don’t we? Can we use (x,y,z)  (dx/(d+z), dy/(d+z), z) for scan-conversion? Sure: If a point Q is behind a point P, then Qz>Pz. So, this transformation preserves depth order. We would not always preserve depth order… when combined with linear depth interpolation

14 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Q’ Q Why we can’t leave z unchanged? EO d Q’ EO Q d We would not always preserve depth order!

15 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Perspective transformation  A perspective transform maps a 3D shape into a 3D shape  Homogeneous xform (x,y,z)  (dx/(d+z), dy/(d+z), dz/(d+z) )  Really a scaling: (x’,y’,z’) = ( d/(d+z) ) (x, y, z) EO Q’ Q d z y y’ EO Q’ Q d z y y’ z’ Perspective transform Perspective projection

16 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac y Comparison EO Q’ Q d z y y’ z’ Correct Perspective transform EO Q’ Q d z y’ z’ Wrong Perspective transform (x,y,z)  (dx/(d+z), dy/(d+y), z) is not an option …when combined with a rasterizer that assumes linearly interpolates transformed vertices. Hence, we need the homogeneous transform that maps triangles into triangles

17 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Geometric construction  Q’ = dQ/(d+z): Scaling towards O by d/(d+z)  Scaling sets the (x,y) coordinates of Q’ where the ray from E to Q hits the screen –Identifies 2D coordinatges for scan-conversion  Moves E to (0,0, – ∞) –Parallel projection –x’ and y’ are coordinates of screen projection EO Q’ Q d z y y’ z’ Perspective transform

18 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Perspective transform of {0<z}  The perspective transform maps the whole space behind the screen to? 0<z<d

19 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac The horizon plane  Plane z=d in the transformed space  That is where all vanishing points live horizon

20 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Perspective transform of {n<z<f}  Select z-buffer values to match near and far clipping planes nf n’ f’ n’=dn/(d+n) should be 0 f’=df/(d+f) should be 2 24 – 1 z’=zd/(d+z) Z[x,y]:=(z’–n’) 2 24 ⁄ (f’–n’) Perspective transform

21 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Standard matrix form of perspective  Origin at eye, not screen: change z to z–d (x’,y’,z’) = (dx/(d+z), dy/(d+z), dz/(d+z) ) (x’,y’,z’) = (dx/z, dy/z, d(z–d)/z )  Scale to the near-far interval (transformed) and to window n’= d(n–d)/n, f’= d(f–d)/f. z”=(z’–n’)/(f’–n’)=(d(z–d)/z–d(n–d)/n)/(d(f–d)/f–d(n–d)/n) = f(z–n)/((f–n)z) if 0≤z”≤1 as n≤z≤f = (z(f+n)–2fn)/(f–n) if -1≤z”≤1 as n≤z≤f

22 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac The pre-image of {z’=k}  Use the inverse of the perspective transform z’=k dz/(d+z)=k Replace z’ by dz/(d+z) in the equationSolve for z dz=kd+kz z=kd/(d–k) For example, k=d yields z=infinity For example, k=d/2 yields z=d For example, k=d/4 yields z=d/3

23 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac The inverse of a perspective transform  Q’ = dQ/(d+z)  Q = ? Q = dQ’/(d–z’)

24 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Maps planes to planes  Prove that perspective transform maps planes into planes Plane ax+by+cz+h=0 Inverse of perspective transform maps this equation to ax’d/(d-z’)+by’d/(d-z’)+cz’d/(d-z’)+h=0 Multiplying by (d-z’) yields ax’d+by’d+cz’d+(d-z’)h=0 Which is a plane: ax’d+by’d+(cd-h)z’+dh=0 Same for half-spaces: ax’+by’+cz’+h<0 maps to ax’d+by’d+(cd-h)z’+dh<0

25 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Map triangles onto triangles Triangle is the intersection of a plane with 3 linear half-spaces. Planes form a closed set under perspective transform.

26 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Where exactly should the viewer stand when looking at the image of a block?  Let A, B, C be the 3 vanishing points  Compute the viewpoint E A B C

27 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Computing E  EA,EB,EC must be mutually orthogonal A B C EAEB=0 EBEC=0 ECEA=0 Solve for E Let O be the screen projection of E EOOA=0, EOOB=0, EOOC=0 EABA=0 yields ||EO||=AOOB Thus O is the orthocenter of ABC Intersection of the altitudes E is the intersection of 3 spheres with diameters (A,B), (B,C), and (C,A) Hence also ||EO||=BOOC and ||EO||=COOA

28 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Adding shadows You are given the picture of two vertical poles with their shadows. You draw a third pole. Can you also draw its shadow?

29 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Practice exercises  Consider an object that spans the depth interval [f,n] in screen coordinates before perspective transformation –What interval does it span after perspective transformation?  Assume that z is stored (without shift or scaling) in a z-buffer as 24-bit integers –What is the range of maximum round-off errors between the actual z of a point before perspective transformation and the z that could be recovered from the rounded value stored in the z-buffer?  How much accuracy improvement does one get by shifting the z-buffer values so that the z of points (x,y,n) is mapped to 0?  How much additional accuracy improvements does one get by also scaling the z-buffer so that the z points (x,y,f) is mapped to the maximum value stored in the z-buffer?  Does perspective transform map quadrics to quadrics?

30 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Advanced questions on perspective  Why not use the perspective projection?  Why not leave z unchanged?  How to draw the result of perspective transform?  Where is the half-space z>0 mapped by perspective transform?  Where are points at infinity mapped to? (Horizon)  How is depth represented in the z-buffer?  How is this encoded as a 4x4 matrix?  What is the preimage of plane (z’=k)?  What is the inverse of the perspective transform?  Proof that perspective transform maps planes to planes?  Proof that perspective transform maps triangles to triangles?  Where should the viewer stand (given 3 vanishing points)?  How to add shadows without knowing where the light is?

31 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Additional practice question  Show the computation and the geometric construction of the result of transforming point (d,d,d) by a perspective transform for a viewpoint at distance d from the screen  Explain where the ray from point P with direction T is mapped by such a perspective transform

32 Georgia Tech, IIC, GVU, 2007 MAGIC Lab Rossignac Puzzle  Why is this figure impossible?