2/24/04© University of Wisconsin, CS559 Spring 2004 Last Time 3D Transformations –Most are natural extensions of 2D transforms –Rotations can be represented.

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Viewing and Projections
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
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.
OpenGL (II). How to Draw a 3-D object on Screen?
Informationsteknologi Wednesday, November 14, 2007Computer Graphics - Class 81 Today’s class Orthogonal matrices Quaternions Shears Synthetic camera Viewing.
CHAPTER 7 Viewing and Transformations © 2008 Cengage Learning EMEA.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)
2/26/04© University of Wisconsin, CS559 Spring 2004 Last Time General Orthographic Viewing –Specifying cameras in world coordinates –Building world  view.
Introduction to 3D viewing 3D is just like taking a photograph!
10/13/200© NTUST Last Time Compositing Painterly Rendering Intro to 3D Graphics Homework 2, 3 due Oct 13 in class.
Transformations Aaron Bloomfield CS 445: Introduction to Graphics
Viewing and Projections
Computer Graphics (fall 2009)
CS 376 Introduction to Computer Graphics 02 / 12 / 2007 Instructor: Michael Eckmann.
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
The Viewing Pipeline (Chapter 4) 5/26/ Overview OpenGL viewing pipeline: OpenGL viewing pipeline: – Modelview matrix – Projection matrix Parallel.
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.
Graphics Graphics Korea University cgvr.korea.ac.kr 3D Viewing 고려대학교 컴퓨터 그래픽스 연구실.
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.
Computer Graphics Bing-Yu Chen National Taiwan University.
Homogeneous Form, Introduction to 3-D Graphics Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 20,
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
Computer Graphics Zhen Jiang West Chester University.
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.
CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.
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)
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.
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.
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Graphics CSCI 343, Fall 2015 Lecture 16 Viewing I
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
A Photograph of two papers
Viewing and Projection
CS559: Computer Graphics Lecture 9: 3D Transformation and Projection Li Zhang Spring 2010 Most slides borrowed from Yungyu ChuangYungyu Chuang.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
CS 551 / 645: Introductory Computer Graphics Viewing Transforms.
OpenGL LAB III.
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
Visible Surface Detection
Rendering Pipeline Fall, 2015.
3D Viewing cgvr.korea.ac.kr.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Lecture 9: Projection Li Zhang Spring 2008
CENG 477 Introduction to Computer Graphics
Computer Graphics (Spring 2003)
Projection in 3-D Glenn G. Chappell
Last Time Canonical view pipeline Projection Local Coordinate Space
Chap 3 Viewing Pipeline Reading:
Last Time 2D and 3D Transformations
© University of Wisconsin, CS559 Fall 2004
Viewing (Projections)
Presentation transcript:

2/24/04© University of Wisconsin, CS559 Spring 2004 Last Time 3D Transformations –Most are natural extensions of 2D transforms –Rotations can be represented in many ways: Orthonormal 3x3 sub- matrix, Quaternions, Axis-Angle, Exponential Map, Euler Angles Coordinate Systems –Local/Object, Global/World, Eye/View/Camera, Canonical View, Window/Screen Canonical to Window mappings Orthogonal projection when the camera axes are aligned with the world axes

2/24/04© University of Wisconsin, CS559 Spring 2004 Today General Orthogonal viewing Perspective viewing

2/24/04© University of Wisconsin, CS559 Spring 2004 Simple Orthographic Projection z y x The view volume is a rectilinear box for orthographic projection Assume that the viewer is looking in the –z direction, with x to the right and y up –Can move but not rotate the camera –Assuming a right-handed coordinate system The view volume is defined by: –a near plane at z=n –a far plane at z=f, (f < n) –a left plane at x=l –a right plane at x=r, (r>l) –a top plane at y=t –and a bottom plane at y=b, (b<t) (r,b,n) (l,t,f)

2/24/04© University of Wisconsin, CS559 Spring 2004 Rendering the Volume To project, map the view volume onto the canonical view volume –After that, we know how to map the view volume to the window The mapping looks similar to the one for canonical → window:

2/24/04© University of Wisconsin, CS559 Spring 2004 General Orthographic Projection We could look at the world from any direction, not just along –z The image could rotated in any way about the viewing direction: x need not be right, and y need not be up How can we specify the view under these circumstances?

2/24/04© University of Wisconsin, CS559 Spring 2004 Specifying a View The location of the eye in space –A point in space for the center of projection, (e x,e y,e z ) The direction in which we are looking: gaze direction –Specified as a vector: (g x,g y,g z ) –This vector will be normal to the image plane A direction that we want to appear up in the image –(up x,up y,up z ), This vector does not have to be perpendicular to n We also need the size of the view volume – l,r,t,b,n,f –Specified with respect to the eye and image plane, not the world

2/24/04© University of Wisconsin, CS559 Spring 2004 General Orthographic (0,0)x y e image planeg b,n b,f t,n t,f Subtle point: it doesn’t precisely matter where we put the image plane

2/24/04© University of Wisconsin, CS559 Spring 2004 Getting there… We wish to end up in the “simple” situation, so we need a coordinate system with: –A vector toward the viewer –One pointing right in the image plane –One pointing up in the image plane –The origin at the eye We must: –Define such a coordinate system, view space –Transform points from the world space into view space –Apply our simple projection from before

2/24/04© University of Wisconsin, CS559 Spring 2004 View Space Given our camera definition: –Which point is the origin of view space? –Which direction is the normal to the view plane, w? –How do we find the right vector, u? –How do we find the up vector, v? Given these points, how do we do the transformation?

2/24/04© University of Wisconsin, CS559 Spring 2004 View Space The origin is at the eye: (e x,e y,e z ) The normal vector is the normalized viewing direction: –It is actually more general to think of it as the vector perpendicular to the image plane We know which way up should be, and we know we have a right handed system, so u=up×w, normalized: We have two vectors in a right handed system, so to get the third: v=w×u

2/24/04© University of Wisconsin, CS559 Spring 2004 World to View We must translate so the origin is at (e x,e y,e z ) To complete the transformation we need to do a rotation After this rotation: –The direction u in world space should be the direction (1,0,0) in view space –The vector v should be (0,1,0) –The vector w should be (0,0,1) The matrix that does that is:

2/24/04© University of Wisconsin, CS559 Spring 2004 All Together We apply a translation and then a rotation, so the result is: And to go all the way from world to screen:

2/24/04© University of Wisconsin, CS559 Spring 2004 OpenGL and Transformations OpenGL internally stores several matrices that control viewing of the scene –The MODELVIEW matrix is intended to capture all the transformations up to the view space –The PROJECTION matrix captures the view to screen conversion You also specify the mapping from the canonical view volume into window space –Directly through function calls to set up the window Matrix calls multiply some matrix M onto the current matrix C, resulting in CM –Set view transformation first, then set transformations from local to world space – last one set is first one applied

2/24/04© University of Wisconsin, CS559 Spring 2004 OpenGL Camera The default OpenGL image plane has u aligned with the x axis, v aligned with y, and n aligned with z –Means the default camera looks along the negative z axis –Makes it easy to do 2D drawing (no need for any view transformation) glOrtho(…) sets the view->canonical matrix –Modifies the PROJECTION matrix gluLookAt(…) sets the world->view matrix –Takes an image center point, a point along the viewing direction and an up vector –Multiplies a world->view matrix onto the current MODELVIEW matrix –You could do this yourself, using glMultMatrix(…) with the matrix from the previous slides

2/24/04© University of Wisconsin, CS559 Spring 2004 Left vs Right Handed View Space You can define u as right, v as up, and n as toward the viewer: a right handed system u  v=w –Advantage: Standard mathematical way of doing things You can also define u as right, v as up and n as into the scene: a left handed system v  u=w –Advantage: Bigger n values mean points are further away OpenGL is right handed Many older systems, notably the Renderman standard developed by Pixar, are left handed

2/24/04© University of Wisconsin, CS559 Spring 2004 Perspective Projection Abstract camera model - box with a small hole in it Pinhole cameras work in practice - camera obscura, etc

2/24/04© University of Wisconsin, CS559 Spring 2004 Distant Objects Are Smaller

2/24/04© University of Wisconsin, CS559 Spring 2004 Parallel lines meet common to draw film plane in front of the focal point

2/24/04© University of Wisconsin, CS559 Spring 2004 Vanishing points Each set of parallel lines (=direction) meets at a different point: The vanishing point for this direction –Classic artistic perspective is 3- point perspective Sets of parallel lines on the same plane lead to collinear vanishing points: the horizon for that plane Good way to spot faked images

2/24/04© University of Wisconsin, CS559 Spring 2004 Basic Perspective Projection Assume you have transformed to view space, with x to the right, y up, and z back toward the viewer Assume the origin of view space is at the center of projection (the eye) Define a focal distance, d, and put the image plane there (note d is negative)

2/24/04© University of Wisconsin, CS559 Spring 2004 Basic Perspective Projection If you know P(x v,y v,z v ) and d, what is P(x s,y s )? –Where does a point in view space end up on the screen? xvxv yvyv -z v d P(x v,y v,z v ) P(x s,y s )

2/24/04© University of Wisconsin, CS559 Spring 2004 Basic Case Similar triangles gives: yvyv -z v P(x v,y v,z v ) P(x s,y s ) View Plane d

2/24/04© University of Wisconsin, CS559 Spring 2004 Simple Perspective Transformation Using homogeneous coordinates we can write:

2/24/04© University of Wisconsin, CS559 Spring 2004 Perspective View Volume Recall the orthographic view volume, defined by a near, far, left, right, top and bottom plane The perspective view volume is also defined by near, far, left, right, top and bottom planes – the clip planes –Near and far planes are parallel to the image plane: z v =n, z v =f –Other planes all pass through the center of projection (the origin of view space) –The left and right planes intersect the image plane in vertical lines –The top and bottom planes intersect in horizontal lines

2/24/04© University of Wisconsin, CS559 Spring 2004 Clipping Planes xvxv -z v Near Clip Plane Far Clip Plane View Volume Left Clip Plane Right Clip Plane f n l r

2/24/04© University of Wisconsin, CS559 Spring 2004 Where is the Image Plane? Notice that it doesn’t really matter where the image plane is located, once you define the view volume –You can move it forward and backward along the z axis and still get the same image, only scaled But we need to know where it is to define the clipping planes –Assume the left/right/top/bottom planes are defined according to where they cut the near clip plane Or, define the left/right and top/bottom clip planes by the field of view

2/24/04© University of Wisconsin, CS559 Spring 2004 Clipping Planes xvxv -z v Near Clip Plane Far Clip Plane View Volume Left Clip Plane Right Clip Plane f FOV

2/24/04© University of Wisconsin, CS559 Spring 2004 OpenGL gluPerspective(…) –Field of view in the y direction (vertical field-of-view) – Aspect ratio (should match window aspect ratio) –Near and far clipping planes –Defines a symmetric view volume glFrustum(…) –Give the near and far clip plane, and places where the other clip planes cross the near plane –Defines the general case –Used for stereo viewing, mostly

2/24/04© University of Wisconsin, CS559 Spring 2004 Perspective Projection Matrices We want a matrix that will take points in our perspective view volume and transform them into the orthographic view volume –This matrix will go in our pipeline just before the orthographic projection matrix (l,b,n) (r,t,n) (l,b,n) (r,t,n)

2/24/04© University of Wisconsin, CS559 Spring 2004 Mapping Lines We want to map all the lines through the center of projection to parallel lines –Points on lines through the center of projection map to the same point on the image –Points on parallel lines map orthographically to the same point on the image –If we convert the perspective case to the orthographic case, we can use all our existing methods The intersection points of lines with the near clip plane should not change The matrix that does this, not surprisingly, looks like the matrix for our simple perspective case

2/24/04© University of Wisconsin, CS559 Spring 2004 General Perspective This matrix leaves points with z=n unchanged It is just like the simple projection matrix, but it does some extra things to z to map the depth properly We can multiply a homogenous matrix by any number without changing the final point, so the two matrices above have the same effect

2/24/04© University of Wisconsin, CS559 Spring 2004 Complete Perspective Projection After applying the perspective matrix, we still have to map the orthographic view volume to the canonical view volume:

2/24/04© University of Wisconsin, CS559 Spring 2004 OpenGL Perspective Projection For OpenGL you give the distance to the near and far clipping planes The total perspective projection matrix resulting from a glFrustum call is:

2/24/04© University of Wisconsin, CS559 Spring 2004 Near/Far and Depth Resolution It may seem sensible to specify a very near clipping plane and a very far clipping plane –Sure to contain entire scene But, a bad idea: –OpenGL only has a finite number of bits to store screen depth –Too large a range reduces resolution in depth - wrong thing may be considered “in front” –See Shirley for a more complete explanation Always place the near plane as far from the viewer as possible, and the far plane as close as possible

2/24/04© University of Wisconsin, CS559 Spring 2004 Clipping Parts of the geometry to be rendered may lie outside the view volume –View volume maps to memory addresses –Out-of-view geometry generates invalid addresses –Geometry outside the view volume also behaves very strangely under perspective projection Triangles can be split into two pieces, for instance Clipping removes parts of the geometry that are outside the view Best done in screen space before perspective divide –Before dividing out the homogeneous coordinate

2/24/04© University of Wisconsin, CS559 Spring 2004 Clipping Points are trivial to clip - just check which side of the clip planes they are on Many algorithms for clipping lines exist –Next lecture Two main algorithms for clipping polygons exist –Sutherland-Hodgman (today) –Weiler (next lecture)

2/24/04© University of Wisconsin, CS559 Spring 2004 Clipping Points A point is inside the view volume if it is on the “inside” of all the clipping planes –The normals to the clip planes are considered to point inward, toward the visible stuff Now we see why clipping is done in canonical view space For instance, to check against the left plane: –X coordinate in 3D must be > -1 –In homogeneous screen space, same as: x screen > -w screen In general, a point, p, is “inside” a plane if: –You represent the plane as n x x+n y y+n z z+d=0, with (n x,n y,n z ) pointing inward –And n x p x +n y p y +n z p z +d>0