Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0.

Slides:



Advertisements
Similar presentations
Graphics Pipeline.
Advertisements

Three Dimensional Viewing
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Camera Models A camera is a mapping between the 3D world and a 2D image The principal camera of interest is central projection.
Viewing and Projections
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
Announcements. Projection Today’s Readings Nalwa 2.1.
CS485/685 Computer Vision Prof. George Bebis
1 Jinxiang Chai CSCE 441 Computer Graphics. 2 Midterm Time: 10:10pm-11:20pm, 10/20 Location: HRBB 113.
CSCE641: Computer Graphics Image Formation Jinxiang Chai.
Announcements Mailing list Project 1 test the turnin procedure *this week* (make sure it works) vote on best artifacts in next week’s class Project 2 groups.
Lecture 12: Projection CS4670: Computer Vision Noah Snavely “The School of Athens,” Raphael.
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.
The Camera : Computational Photography Alexei Efros, CMU, Fall 2008.
Informationsteknologi Wednesday, November 14, 2007Computer Graphics - Class 81 Today’s class Orthogonal matrices Quaternions Shears Synthetic camera Viewing.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
Perspective projection
Viewing and Projections
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.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Jinxiang Chai CSCE441: Computer Graphics 3D Transformations 0.
10/3/02 (c) 2002 University of Wisconsin, CS 559 Last Time 2D Coordinate systems and transformations.
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
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)
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.
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
12/24/2015 A.Aruna/Assistant professor/IT/SNSCE 1.
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Viewing and Projection
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.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Lecture 18: Cameras CS4670 / 5670: Computer Vision KavitaBala Source: S. Lazebnik.
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
Computer Graphics Projections.
3D Viewing and Clipping Ming Ouhyoung 歐陽明 Professor Dept. of CSIE and GINM NTU.
Rendering Pipeline Fall, 2015.
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
3D Viewing cgvr.korea.ac.kr.
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
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
Viewing/Projections I Week 3, Fri Jan 25
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Lecture 13: Cameras and geometry
Computer Graphics (Spring 2003)
Announcements Midterm out today Project 1 demos.
Last Time Canonical view pipeline Projection Local Coordinate Space
3D Graphics.
Viewing (Projections)
Viewing (Projections)
Announcements Midterm out today Project 1 demos.
CS 352: Computer Graphics Chapter 5: Viewing.
Presentation transcript:

Jinxiang Chai CSCE 441 Computer Graphics 3-D Viewing 0

Outline 3D Viewing Required readings: HB 10-1 to Compile and run the codes in page opengl three-dimensional viewing program example 1

Taking Pictures Using A Real Camera Steps: - Identify interesting objects - Rotate and translate the camera to a desired camera viewpoint - Adjust camera settings such as focal length - Choose desired resolution and aspect ratio, etc. - Take a snapshot

Taking Pictures Using A Real Camera Steps: - Identify interesting objects - Rotate and translate the camera to a desired camera viewpoint - Adjust camera settings such as focal length - Choose desired resolution and aspect ratio, etc. - Take a snapshot Graphics does the same thing for rendering an image for 3D geometric objects

Image space 3D Geometry Pipeline 4 Normalized projection space View space World spaceObject space Aspect ratio & resolution Focal length Rotate and translate the camera

3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 5 Model space (Object space)

3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 6 World space (Object space)

3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 7 Eye space (View space)

3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 8 Normalized projection space

3D Geometry Pipeline Before being turned into pixels by graphics hardware, a piece of geometry goes through a number of transformations... 9 Image space, window space, raster space, screen space, device space

3D Geometry Pipeline 10 Normalized project space View space World spaceObject space Image space

3D Geometry Pipeline World spaceObject space glTranslate*(t x,t y,t z ) Translate, scale &rotate

3D Geometry Pipeline Object space glScale*(s x,s y,s z ) World space Translate, scale &rotate

3D Geometry Pipeline Object space glRotate* Rotate about r by the angle World space Translate, scale &rotate

Image space 3D Geometry Pipeline 14 Screen space Normalized project space View space World spaceObject space

Now look at how we would compute the world->eye transformation 3D Geometry Pipeline View spaceWorld space

Now look at how we would compute the world->eye transformation 3D Geometry Pipeline View spaceWorld space Rotate&translate

Camera Coordinate 17

Viewing Trans: gluLookAt 18 gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

Canonical coordinate system - usually right handed (looking down –z axis) - convenient for project and clipping Camera Coordinate

Mapping from world to eye coordinates - eye position maps to origin - right vector maps to x axis - up vector maps to y axis - back vector maps to z axis Camera Coordinate

We have the camera in world coordinates We want to transformation T which takes object from world to camera Viewing Transformation

We have the camera in world coordinates We want to transformation T which takes object from world to camera Trick: find T -1 taking object from camera to world Viewing Transformation

We have the camera in world coordinates We want to transformation T which takes object from world to camera Trick: find T -1 taking object from camera to world Viewing Transformation ?

Review: 3D Coordinate Trans. Transform object description from to p 24

Review: 3D Coordinate Trans. Transform object description from to p 25

Review: 3D Coordinate Trans. Transform object description from camera to world 26

Trick: find T -1 taking object from camera to world - eye position maps to origin - back vector maps to z axis - up vector maps to y axis - right vector maps to x axis Viewing Transformation

Trick: find T -1 taking object from camera to world Viewing Transformation H&B equation (10-4)

Viewing Trans: gluLookAt 29 gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

Mapping from world to eye coordinates Viewing Trans: gluLookAt How to determine ? gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

Mapping from world to eye coordinates Viewing Trans: gluLookAt How to determine ? gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

Mapping from world to eye coordinates Viewing Trans: gluLookAt gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

Mapping from world to eye coordinates Viewing Trans: gluLookAt gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

Mapping from world to eye coordinates Viewing Trans: gluLookAt H&B equation (10-1) gluLookAt (eye x,eye y,eye z,at x,at y,at z,up x, up y,up z )

Viewing Trans: gluLookAt Test: gluLookAt( 4.0, 2.0, 1.0, 2.0, 4.0, -3.0, 0, 1.0, 0 ) - What’s the transformation matrix from the world space to the camera reference system?

3D Geometry Pipeline View space World space 3D-3D viewing transformation

Projection General definition transform points in n-space to m-space (m<n) In computer graphics map 3D coordinates to 2D screen coordinates

Projection General definition transform points in n-space to m-space (m<n) In computer graphics map 3D coordinates to 2D screen coordinates How can we project 3d objects to 2d screen space?

How Do We See the World? Let’s design a camera: idea 1: put a piece of film in front of camera Do we get a reasonable picture?

Pin-hole Camera Add a barrier to block off most of the rays  This reduces blurring  The opening known as the aperture  How does this transform the image?

Camera Obscura The first camera  Known to Aristotle  Depth of the room is the focal length  Pencil of rays – all rays through a point

Perspective Projection Maps points onto “view plane” along projectors emanating from “center of projection” (COP) 42

Perspective Projection Maps points onto “view plane” along projectors emanating from “center of projection” (COP) 43 What’s relationship between 3D points and projected 2D points?

Consider the projection of a 3D point on the camera plane 3D->2D 44

Consider the projection of a 3D point on the camera plane 3D->2D 45

Consider the projection of a 3D point on the camera plane 3D->2D 46 By similar triangles, we can compute how much the x and y coordinates are scaled

Consider the projection of a 3D point on the camera plane 3D->2D 47 By similar triangles, we can compute how much the x and y coordinates are scaled

Homogeneous Coordinates Is this a linear transformation?

Homogeneous Coordinates Is this a linear transformation? –no—division by z is nonlinear

Homogeneous Coordinates Is this a linear transformation? Trick: add one more coordinate: homogeneous image coordinates homogeneous scene coordinates –no—division by z is nonlinear

Remember how we said 2D/3D geometric transformations work with the last coordinate always set to one What happens if the coordinate is not one We divide all coordinates by w: Homogeneous Point Revisited 51 If w=1, nothing happens Sometimes, we call this division step the “perspective divide”

Now we can rewrite the perspective projection equation as matrix-vector multiplications The Perspective Matrix 52

Now we can rewrite the perspective projection equation as matrix-vector multiplications The Perspective Matrix 53 This becomes a linear transformation!

Now we can rewrite the perspective projection equation as matrix-vector multiplications The Perspective Matrix 54 After the division by w, we have

Perspective Effects Distant object becomes small The distortion of items when viewed at an angle (spatial foreshortening)

Perspective Effects Distant object becomes small The distortion of items when viewed at an angle (spatial foreshortening)

Perspective Effects Distant object becomes small The distortion of items when viewed at an angle (spatial foreshortening)

Perspective projection is an example of projective transformation - lines maps to lines - parallel lines do not necessary remain parallel - ratios are not preserved Properties of Perspective Proj.

Perspective projection is an example of projective transformation - lines maps to lines - parallel lines do not necessary remain parallel - ratios are not preserved One of advantages of perspective projection is that size varies inversely proportional to the distance- looks realistic Properties of Perspective Proj.

What happens to parallel lines they are not parallel to the projection plane? Vanishing Points 60

What happens to parallel lines they are not parallel to the projection plane? The equation of the line: Vanishing Points 61

What happens to parallel lines they are not parallel to the projection plane? The equation of the line: After perspective transformation, we have Vanishing Points 62

Letting t go to infinity: Vanishing Points (cont.) 63

What happens to parallel lines they are not parallel to the projection plane? The equation of the line: Vanishing Points 64

What happens to parallel lines they are not parallel to the projection plane? The equation of the line: How about the line Vanishing Points 65

What happens to parallel lines they are not parallel to the projection plane? The equation of the line: How about the line Vanishing Points 66

What happens to parallel lines they are not parallel to the projection plane? The equation of the line: How about the line Vanishing Points 67 Same vanishing point!

What happens to parallel lines they are not parallel to the projection plane? Each set of parallel lines intersect at a vanishing point on the PP Vanishing Points

What happens to parallel lines they are not parallel to the projection plane? Each set of parallel lines intersect at a vanishing point on the PP Vanishing Points

Parallel Projection Center of projection is at infinity Direction of projection (DOP) same for all points

Orthographic Projection Direction of projection (DOP) perpendicular to view plane

Orthographic Projection Direction of projection (DOP) perpendicular to view plane

Properties of Parallel Projection Not realistic looking Good for exact measurement Are actually affine transformation - parallel lines remain parallel - ratios are preserved - angles are often not preserved Most often used in CAD, architectural drawings, etc. where taking exact measurement is important

Perspective projection from 3D to 2D 3D->2D 74

Perspective projection from 3D to 2D 3D->2D 75 But so far, we have not considered the size of film plane! We have also not considered visibility problem

Image space 3D Geometry Pipeline 76 Screen space Normalized project space View space World spaceObject space z = -1 z = 1

The center of projection and the portion of projection plane that map to the final image form an infinite pyramid. The sides of pyramid called clipping planes Additional clipping planes are inserted to restrict the range of depths Perspective Projection Volume

OpenGL Perspective-Projection 78 Normalized project space View space glFrustum(xw min, xw max,yw min, yw max,d near,d far ) gluPerspective(fovy,aspect,dnear, dfar) z = -1 z = 1

View space (xw min,yw min,Z near ) (xw max,yw max,z near ) General Perspective-Projection z far glFrustum(xw min, xw max,yw min, yw max,d near,d far ) Six parameters define six clipping planes!

General Perspective-Projection glFrustum(xw min, xw max,yw min, yw max,d near,d far ) Left-vertical clipping plane

General Perspective-Projection glFrustum(xw min, xw max,yw min, yw max,d near,d far ) right-vertical clipping plane

General Perspective-Projection glFrustum(xw min, xw max,yw min, yw max,d near,d far ) bottom-horizontal clipping plane

General Perspective-Projection glFrustum(xw min, xw max,yw min, yw max,d near,d far ) top-horizontal clipping plane

General Perspective-Projection glFrustum(xw min, xw max,yw min, yw max,d near,d far ) near clipping plane

General Perspective-Projection glFrustum(xw min, xw max,yw min, yw max,d near,d far ) far clipping plane

Normalized project space (left-handed) View space (right-handed) B’=(1,1,1) A’=(-1,-1,-1) General Perspective-Projection A maps to A’, B maps to B’ Keep the directions of x and y axes! A B

B’=(1,1,1) A’=(-1,-1,-1) General Perspective-Projection H&B equation (10-40) A B

OpenGL Symmetric Perspective- Projection Function gluPerspective(fovy,aspect,dnear, dfar) 88 Assume z-axis is the centerline of 3D view frustum!

Image space 3D Geometry Pipeline 89 Normalized project space View space World spaceObject space

Image space-.>Image space Viewport Transformation 90 glViewport(x min, y min, width, height) (x min,y min ) Display window viewport

Image space-.>Image space Viewport Transformation 91 glViewport(x min, y min, width, height) (x min,y min ) - Besides x and y, each pixel has a depth value z, which is stored in depth buffer. -Depth values will be used for visibility testing -The color of the pixel is stored in color buffer

92 Image space Normalized project space B’=(1,1,1) A’=(-1,-1,-1) Normalized project space A’’=(xv min,yv min,0) B’’=(xv max,yv max,1) Viewport Transformation -1<=z<=1 0<=z<=1

Viewport Transformation 93 Image space Normalized project space B’=(1,1,1) A’=(-1,-1,-1) Normalized project space A’’=(xv min,yv min,0) B’’=(xv max,yv max,1) H&B equation (10-42) -1<=z<=1 0<=z<=1

Image space Summary: 3D Geometry Pipeline 94 Normalized project space View space World spaceObject space

Taking Steps Together 95 Image space Normalized project space View space World spaceObject space

OpenGL Codes 96