I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S CIS 736 Computer Graphics Lecture 5 of 42 Review of Basics 4 of 5: 3-D Viewing III and Intro.

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Defining the Viewing Coordinate System
Three Dimensional Viewing
1 Computer Graphics Chapter 8 3D Transformations.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
CS485/685 Computer Vision Prof. George Bebis
CS 376 Introduction to Computer Graphics 02 / 26 / 2007 Instructor: Michael Eckmann.
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
CS 450: Computer Graphics 2D TRANSFORMATIONS
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.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 23, D Viewing III 3D Viewing III.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 22, D Viewing III Kansas State University CIS 636 Fundamentals.
Computing & Information Sciences Kansas State University CG Basics 4 of 8: ViewingCIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S CIS 736 Computer Graphics Lecture 4 of 42 Review of Basics 3 of 5: Clipping and 3-D Viewing.
Viewing and Projections
C O M P U T E R G R A P H I C S Jian Chen January 15, D Viewing II 1/23 3D Viewing II By Andries van Dam.
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.
Advanced Computer Graphics Three Dimensional Viewing
Part II (The Synthetic Camera)
Computer Graphics World, View and Projection Matrices CO2409 Computer Graphics Week 8.
Geometric Models & Camera Calibration
Week 5 - Wednesday.  What did we talk about last time?  Project 2  Normal transforms  Euler angles  Quaternions.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
C O M P U T E R G R A P H I C S Jian Chen January 15, 2010 Viewing III 1/42 3D Viewing III By Andries van Dam.
Computer Graphics Bing-Yu Chen National Taiwan University.
3D Viewing ( From 3D to 2D) Some of the material in these slides have been adapted from the lecture notes of Prof. Tao Ju from Washington University in.
CIS 636/736Wed 30 Jan 20084/42 CIS 636/736: (Introduction to) Computer Graphics Lecture 4 of 42 Viewing 3: Graphics Pipeline Monday, 30 January 2008 Adapted.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 3 of 41 William H. Hsu Department of Computing.
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
Computing & Information Sciences Kansas State University CIS 536/636 Introduction to Computer Graphics Lecture 5 of 41 William H. Hsu Department of Computing.
CS 376 Introduction to Computer Graphics 02 / 23 / 2007 Instructor: Michael Eckmann.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam 3D Viewing I CIS 736 Computer Graphics Review of Basics 2 of 5: 3D Viewing.
10/7/04© University of Wisconsin, CS559 Fall 2004 Last Time Transformations Homogeneous coordinates Directions Rotation Geometry 101 – Points, edges, triangles/polygons.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection.
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)
Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0.
Three-Dimensional Viewing Hearn & Baker Chapter 7
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
2/19/04© University of Wisconsin, CS559 Spring 2004 Last Time Painterly rendering 2D Transformations –Transformations as coordinate system changes –Transformations.
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
David Luebke1/10/2016 CS 551 / 645: Introductory Computer Graphics David Luebke
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
A Photograph of two papers
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.
CS 376 Introduction to Computer Graphics 02 / 21 / 2007 Instructor: Michael Eckmann.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CIS 736 Computer Graphics Lecture 6 of 42 Viewing 4: Clipping and Culling Monday, 04 February 2008 Reading: Sections 2.4, 4.1, 4.5 Eberly 2e Adapted with.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
Outline 3D Viewing Required readings: HB 10-1 to 10-10
Viewing in 3D Lecture 11. Viewing in 3D2 u The 3D viewing process is inherently more complex than is the 2D viewing process. F In 2D, we simply specify.
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.
A Photograph of two papers The Model: 2 papers – 8cm x 8cm and 5cm x 5cm The Camera – Simple pinhole – No focusing capability The Scene – Arrangements.
Rendering Pipeline Fall, 2015.
Part II (The Synthetic Camera)
CSCE 441 Computer Graphics 3-D Viewing
CENG 477 Introduction to Computer Graphics
A Photograph of two papers
Three Dimensional Viewing
Computer Graphics Lecture 20
Andries van Dam September 18, D Viewing III
Last Time Canonical view pipeline Projection Local Coordinate Space
Viewing (Projections)
Viewing (Projections)
Presentation transcript:

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S CIS 736 Computer Graphics Lecture 5 of 42 Review of Basics 4 of 5: 3-D Viewing III and Intro to Projections Wednesday, 25 January 2006 (pages , ) Adapted with Permission W. H. Hsu Andries van Dam 2D Clipping 1/14

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 25, D Clipping 12/14 D = P 1 – P 0 = (x 1 – x 0, y 1 – y 0 ) Leave P E i as an arbitrary point on the clip edge; it’s a free variable and drops out Calculations for Parametric Line Clipping for Upright Clip Rectangle (1/2) Clip Edge i Normal N i PEiPEi P 0 -P E i left: x = x min (-1,0)(x min, y)(x 0 - x min,y 0 -y) right: x = x max (1,0)(x max,y)(x 0 - x max,y 0 -y) bottom: y = y min (0,-1)(x, y min )(x 0 -x,y 0 - y min ) top: y = y max (0,1)(x, y max )(x 0 -x,y 0 - y max ) Calculations for Parametric Line Clipping Algorithm

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 9/21 Analogous to the size of film used in a camera Determines proportion of width to height of image displayed on screen Square viewing window has aspect ratio of 1:1 Movie theater “letterbox” format has aspect ratio of 2:1 NTSC television has an aspect ratio of 4:3, and HDTV is 16:9 Aspect Ratio Kodak HDTV 16:9 NTSC 4:3

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 10/21 Determines amount of perspective distortion in picture, from none (parallel projection) to a lot (wide-angle lens) In a frustum, two viewing angles: width and height angles. We specify Height angle, and get the Width angle from (Aspect ratio * Height angle) Choosing View angle analogous to photographer choosing a specific type of lens (e.g., a wide-angle or telephoto lens) View Angle (1/2)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 11/21 Lenses made for distance shots often have a nearly parallel viewing angle and cause little perspective distortion, though they foreshorten depth Wide-angle lenses cause a lot of perspective distortion View Angle (2/2) Resulting pictures

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 12/21 Volume of space between Front and Back clipping planes defines what camera can see Position of planes defined by distance along Look vector Objects appearing outside of view volume don’t get drawn Objects intersecting view volume get clipped Front and Back Clipping Planes (1/3) Front clipping plane Back clipping plane

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 13/21 Reasons for Front (near) clipping plane: Don’t want to draw things too close to the camera –would block view of rest of scene –objects would be prone to distortion Don’t want to draw things behind camera –wouldn’t expect to see things behind the camera –in the case of the perspective camera, if we decided to draw things behind the camera, they would appear upside-down and inside-out because of perspective transformation Reasons for Back (far) clipping plane: Don’t want to draw objects too far away from camera –distant objects may appear too small to be visually significant, but still take long time to render –by discarding them we lose a small amount of detail but reclaim a lot of rendering time –alternately, the scene may be filled with many significant objects; for visual clarity, we may wish to declutter the scene by rendering those nearest the camera and discarding the rest Front and Back Clipping Planes (2/3)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 14/21 Front and Back Clipping Planes (3/3) Have you ever played a video game and all of the sudden some object pops up in the background (e.g. a tree in a racing game)? That’s the object coming inside the far clip plane. The old hack to keep you from noticing the pop-up is to add fog in the distance. A classic example of this is from Turok: Dinosaur Hunter Now all you notice is fog and how little you can actually see. This practically defeats the purpose of an outdoor environment! And you can still see pop-up from time to time. Thanks to fast hardware and level of detail algorithms, we can push the far plane back now and fog is much less prevalent Putting the near clip plane as far away as possible helps Z precision. Sometimes in a game you can position the camera in the right spot so that the front of an object gets clipped letting you see inside of it.

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 15/21 Some camera models take a Focal length Focal Length is a measure of ideal focusing range; approximates behavior of real camera lens Objects at distance of Focal length from camera are rendered in focus; objects closer or farther away than Focal length get blurred Focal length used in conjunction with clipping planes Only objects within view volume are rendered, whether blurred or not. Objects outside of view volume still get discarded Focal Length

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 16/21 It can create the following view volumes: –perspective: positive view angle –parallel: zero view angle Model cannot create oblique view volume Non-oblique vs. oblique view volumes: For example, view cameras with bellows are used to take pictures of (tall) buildings. The film plane is parallel to the façade, while the camera points up. This is an oblique view volume, with the façade undistorted What This Camera Model Can And Cannot Do Non-oblique view volume: Oblique view volume: Look vector is perpendicular to film plane Look vector is at an angle to the film plane

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 17/21 From Position, Look vector, Up vector, Aspect ratio, Height angle, Clipping planes, and (optionally) Focal length together specify a truncated view volume Truncated view volume is a specification of bounded space that camera can “see” 2D view of 3D scene can be computed from truncated view volume and projected onto film plane Truncated view volumes come in two flavors: parallel and perspective View Volume Specification

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 18/21 Limiting view volume useful for eliminating extraneous objects Orthographic parallel projection has width and height view angles of zero Truncated View Volume for Orthographic Parallel Projection Height Width Look vector Near distance Position Far distance Up vector

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 19/21 Removes objects too far from Position, which otherwise would merge into “blobs” Removes objects too close to Position (would be excessively distorted) Truncated View Volume (Frustum) for Perspective Projection Position Near distance Far distance Height angle Width angle = Look vector Up vector Height angle Aspect ratio

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 20/21 Real cameras have a roll of film that captures pictures Synthetic camera “film” is a rectangle on an infinite film plane that contains image of scene Why haven’t we talked about the “film” in our synthetic camera, other than mentioning its aspect ratio? How is the film plane positioned relative to the other parts of the camera? Does it lie between the near and far clipping planes? Behind them? Turns out that fine positioning of Film plane doesn’t matter. Here’s why: –for a parallel view volume, as long as the film plane lies in front of the scene, parallel projection onto film plane will look the same no matter how far away film plane is from scene –same is true for perspective view volumes, because the last step of computing the perspective projection is a transformation that stretches the perspective volume into a parallel volume To be explained in detail in the next lecture In general, it is convenient to think of the film plane as lying at the eye point (Position) Where’s My Film?

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 16, D Viewing II 21/21 Carlbom, Ingrid and Paciorek, Joseph, “Planar Geometric Projections and Viewing Transformations,” Computing Surveys, Vol. 10, No. 4 December 1978 Kemp, Martin, The Science of Art, Yale University Press, 1992 Mitchell, William J., The Reconfigured Eye, MIT Press, 1992 Foley, van Dam, et. al., Computer Graphics: Principles and Practice, Addison-Wesley, 1995 Wernecke, Josie, The Inventor Mentor, Addison-Wesley, 1994 Sources

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 2/42 Reduce degrees of freedom; five steps to specifying view volume –position the camera (and therefore its view/film plane) –point it at what you want to see, with the camera in the orientation you want –define the field of view (for a perspective view volume, aspect ratio of film and angle of view: somewhere between wide angle, normal, and zoom; for a parallel view volume, width and height) –choose perspective or parallel projection –determine the focal distance Stage One: Specifying a View Volume

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 3/42 Perspective Projection: Truncated Pyramid – Frustum Look vector is the center line of the pyramid, the vector that lines up with “the barrel of the lens” Note: For ease of specification, up vector need not to be perpendicular to Look vector, but they cannot be collinear Examples of a View Volume (1/2) Position Near distance Far distance Height angle Width angle = Look vector Up vector Height angle Aspect ratio x y z

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 4/42 Orthographic Parallel Projection: Truncated View Volume – Cuboid Orthographic parallel projection has no view angle parameter Examples of a View Volume (2/2) Height Width Look vector Near distance Position Far distance Up vector x y z

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 5/42 Placement of view volume (visible part of world) specified by camera’s position and orientation –Position (a point) –Look and Up vectors Shape of view volume specified by –horizontal and vertical view angles –front and back clipping planes Perspective projection: projectors intersect at Position Parallel projection: projectors parallel to Look vector, but never intersect (or intersect at infinity) Coordinate Systems –world coordinates – standard right-handed xyz 3-space –viewing reference coordinates – camera-space right handed coordinate system (u, v, n); origin at Position and axes rotated by orientation; used for transforming arbitrary view into canonical view Specifying Arbitrary 3D Views

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 6/42 We have now specified an arbitrary view using our viewing parameters Problem: map arbitrary view specification to 2D picture of scene. This is hard, both for clipping and for projection Solution: reduce to a simpler problem and solve Note: Look vector along negative, not positive, z-axis is arbitrary but makes math easier Arbitrary View Volume Too Complex – there is a view specification from which it is easy to take a picture. We’ll call it the canonical view: from the origin, looking down the negative z-axis – parallel projection – sits at origin: Position = (0, 0, 0) – looks along negative z-axis: Look vector = (0, 0, –1) – oriented upright: Up vector = (0, 1, 0) – film plane extending from –1 to 1 in x and y – think of the scene as lying behind a window and we’re looking through the window up n v u

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 7/42 Our goal is to transform our arbitrary view and the world to the canonical view volume, maintaining the relationship between view volume and world, then take picture –for parallel view volume, transformation is affine: made up of translations, rotations, and scales –in the case of a perspective view volume, it also contains a non-affine † perspective transformation that frustum into a parallel view volume, a cuboid –the composite transformation that will transform the arbitrary view volume to the canonical view volume, named the normalizing transformation, is still a 4x4 homogeneous coordinate matrix that typically has an inverse –easy to clip against this canonical view volume; clipping planes are axis- aligned! –projection using the canonical view volume is even easier: just omit the z- coordinate –for oblique parallel projection, a shearing transform is part of the composite transform, to “de-oblique” the view volume Normalizing to the Canonical View Volume † Affine transformations preserve parallelism but not lengths and angles. The perspective transformation is a type of non- affine transformation known as a projective transformation, which does not preserve parallelism

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 8/42 Problem of taking a picture has now been reduced to problem of finding correct normalizing transformation It is a bit tricky to find the rotation component of the normalizing transformation. But it is easier to find the inverse of this rotational component (trust us) So we’ll digress for a moment and focus our attention on the inverse of the normalizing transformation, which is called the viewing transformation. The viewing transformation turns the canonical view into the arbitrary view, or (x, y, z) to (u, v, n) Viewing Transformation Normalizing Transformation

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 9/42 We know the view specification: Position, Look vector, and Up vector We need to derive an affine transformation from these parameters that will translate and rotate the canonical view into our arbitrary view –the scaling of the film (i.e. the cross-section of the view volume) to make a square cross-section will happen at a later stage, as will clipping Translation is easy to find: we want to translate the origin to the point Position; therefore, the translation matrix is Rotation is harder: how do we generate a rotation matrix from the viewing specifications that will turn x, y, z, into u, v, n? –a digression on rotation will help answer this Building Viewing Transformation from View Specification

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 10/42 3 x 3 rotation matrices We learned about 3 x 3 matrices that “rotate” the world (we’re leaving out the homogeneous coordinate for simplicity) When they do, the three unit vectors that used to point along the x, y, and z axes are moved to new positions Because it is a rigid-body rotation –the new vectors are still unit vectors –the new vectors are still perpendicular to each other –the new vectors still satisfy the “right hand rule” Any matrix transformation that has these three properties is a rotation about some axis by some amount! Let’s call the three x-axis, y-axis, and z-axis-aligned unit vectors e 1, e 2, e 3 Writing out: Rotation (1/5)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 11/42 Let’s call our rotation matrix M and suppose that it has columns v 1, v 2, and v 3 : When we multiply M by e 1, what do we get? Similarly for e 2 and e 3 : Rotation (2/5)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 12/42 Thus, for any matrix M, we know that Me 1 is the first column of M If M is a rotation matrix, we know that Me 1 (i.e., where e 1 got rotated to) must be a unit-length vector (because rotations preserve length) Since Me 1 = v 1, the first column of any rotation matrix M must be a unit vector Also, the vectors e 1 and e 2 are perpendicular… So if M is a rotation matrix, the vectors Me 1 and Me 2 are perpendicular… (if you start with perpendicular vectors and rotate them, they’re still perpendicular) But these are the first and second columns of M … Ditto for the other two pairs As we noted in the slide on rotation matrices, for a rotation matrix with columns v i –columns must be unit vectors: ||v i || = 1 –columns are perpendicular: v i v j = 0 (i  j) Rotation (3/5)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 13/42 Therefore (for rotation matrices) We can write this matrix of v i v j dot products as where M T is a matrix whose rows are v 1, v 2, and v 3 Also, for matrices in general, M -1 M = I, (actually, M -1 exists only for “well-behaved” matrices) Therefore, for rotation matrices only we have just shown that M -1 is simply M T M T is trivial to compute, M -1 takes considerable work: big win! Rotation (4/5)

I N T R O D U C T I O N T O C O M P U T E R G R A P H I C S Andries van Dam September 18, D Viewing III 14/42 Summary If M is a rotation matrix, then its columns are pairwise perpendicular and have unit length Inversely, if the columns of a matrix are pairwise perpendicular and have unit length and satisfy the right-hand rule, then the matrix is a rotation For such a matrix, Rotation (5/5)