CS 4731: Computer Graphics Lecture 13: Projection Emmanuel Agu.

Slides:



Advertisements
Similar presentations
Lecture 3: Transformations and Viewing. General Idea Object in model coordinates Transform into world coordinates Represent points on object as vectors.
Advertisements

1 Computer Graphics Chapter 8 3D Transformations.
CLASS 6 PERSPECTIVE CS770/870. Orthographic projections Isometric ObliqueIn isometric all distances along the major axes are the same.
Projection Matrix Tricks Eric Lengyel Outline  Projection Matrix Internals  Infinite Projection Matrix  Depth Modification  Oblique Near Clipping.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Viewing and Projections
1 Computer Graphics Chapter 4 2D Viewing Algorithms.
CS 4731: Computer Graphics Lecture 7: Introduction to Transforms, 2D transforms Emmanuel Agu.
Projection Matrices Ed Angel
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
Viewing Transformations CS5600 Computer Graphics by Rich Riesenfeld 5 March 2002 Lecture Set 11.
The Pinhole Camera Model
Viewing Doug James’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals of Computer Graphics, Chap 7 Wen-Chieh (Steve) Lin Institute of Multimedia.
4.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 4 Projection Clipping Viewport Transformation.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Viewing and Projections Mon 22 Sep 2003 project 1 solution demo recap: projections.
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
Projection Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m
Introduction to 3D viewing 3D is just like taking a photograph!
12.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 12 – 3D Graphics Transformation Pipeline: Projection and Clipping.
Viewing and Projections
Computer Graphics (fall 2009)
1 Projection Matrices. 2 Objectives Derive the projection matrices used for standard OpenGL projections Introduce oblique projections Introduce projection.
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.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
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.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
Computer Graphics Zhen Jiang West Chester University.
University of North Carolina at Greensboro
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)
Three-Dimensional Viewing
Three-Dimensional Viewing Hearn & Baker Chapter 7
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: Viewing
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
3D Transformation A 3D point (x,y,z) – x,y, and z coordinates
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.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
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.
Visible Surface Detection
Computer Graphics - Chapter 5 Viewing
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
University of North Carolina at Greensboro
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
Viewing in 3D Chapter 6.
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.
CENG 477 Introduction to Computer Graphics
3D Clipping.
Projections and Normalization
Computer Graphics 9: Clipping In 3D
Viewing Transformations
Computer Graphics Lecture 20
Isaac Gang University of Mary Hardin-Baylor
Last Time Canonical view pipeline Projection Local Coordinate Space
Chap 3 Viewing Pipeline Reading:
Viewing (Projections)
Interactive Computer Graphics Viewing
Computer Graphics Computer Viewing
Window to Viewport Transformations
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

CS 4731: Computer Graphics Lecture 13: Projection Emmanuel Agu

3D Projection Modeling Viewing Projection Transformation Transformation Transformation Viewport Transformation Display

Projection Transformation Projection – map the object from 3D space to 2D screen x y z x y z Perspective: gluPerspective()Parallel: glOrtho()

Parallel Projection After transforming the object to the eye space, parallel projection is relatively easy – we could just drop the Z After transforming the object to the eye space, parallel projection is relatively easy – we could just drop the Z Xp = x Yp = y Zp = -d We actually want to keep Z – why? x y z (x,y,z) (Xp, Yp)

Parallel Projection OpenGL maps (projects) everything in the visible volume into a canonical view volume (-1, -1, 1) (1, 1, -1) Canonical View Volume glOrtho(xmin, xmax, ymin, ymax,near, far) (xmin, ymin, near) (xmax, ymax, far)

Parallel Projection: glOrtho Parallel projection can be broken down into two parts Translation which centers view volume at origin Scaling which reduces cuboid of arbitrary dimensions to canonical cube (dimension 2, centered at origin)

Parallel Projection: glOrtho Translation sequence moves midpoint of view volume to coincide with origin: E.g. midpoint of x = (xmax + xmin)/2 Thus translation factors: -(xmax+xmin)/2, -(ymax+ymin)/2, -(far+near)/2 And translation matrix M1:

Parallel Projection: glOrtho Scaling factor is ratio of cube dimension to Ortho view volume dimension Scaling factors: 2/(xmax-xmin), 2/(ymax-ymin), 2/(zmax-zmin) Scaling Matrix M2:

Parallel Projection: glOrtho Refer: Hill, Concatenating M1xM2, we get transform matrix used by glOrtho X

Perspective Projection: Classical Side view: x y z (0,0,0) d Projection plane Eye (projection center) (x,y,z) (x’,y’,z’) -z z y Based on similar triangle: y -z y’ d d y’ = y x -z =

Perspective Projection: Classical So (x*,y*) the projection of point, (x,y,z) unto the near plane N is given as: Numerical example: Q. Where on the viewplane does P = (1, 0.5, -1.5) lie for a near plane at N = 1? (x*, y*) = (1 x 1/1.5, 1 x 0.5/1.5) = (0.666, 0.333)

Pseudodepth Classical perspective projection projects (x,y) coordinates, drops z coordinates But we need z to find closest object (depth testing) Keeping actual distance of P from eye is cumbersome and slow Introduce pseudodepth: all we need is measure of which objects are further if two points project to same (x,y) Choose a, b so that pseudodepth varies from –1 to 1 (canonical cube)

Pseudodepth Solving: For two conditions, z* = -1 when Pz = -N and z* = 1 when Pz = -F, we can set up two simultaneuous equations Solving:

Homogenous Coordinates Would like to express projection as 4x4 transform matrix Previously, homogeneous coordinates of the point P = (Px,Py,Pz) was (Px,Py,Pz,1) Introduce arbitrary scaling factor, w, so that P = (wPx, wPy, wPz, w) (Note: w is non-zero) For example, the point P = (2,4,6) can be expressed as (2,4,6,1) or (4,8,12,2) where w=2 or (6,12,18,3) where w = 3 So, to convert from homogeneous back to ordinary coordinates, divide all four terms by last component and discard 4 th term

Perspective Projection Same for x. So we have: x’ = x x d / -z y’ = y x d / - z z’ = -d Put in a matrix form: OpenGL assumes d = 1, i.e. the image plane is at z = -1

Perspective Projection We are not done yet. Need to modify the projection matrix to include a and b x’ x y’ = y z’ 0 0 a b z w 0 0 (1/-d) 0 1 x y z Z = 1 z = -1 We have already solved a and b

Perspective Projection Not done yet. OpenGL also normalizes the x and y ranges of the viewing frustum to [-1, 1] (translate and scale) So, as in ortho to arrive at final projection matrix we translate by –(xmax + xmin)/2 in x -(ymax + ymin)/2 in y Scale by: 2/(xmax – xmin) in x 2/(ymax – ymin) in y

Perspective Projection Final Projection Matrix: glFrustum(xmin, xmax, ymin, ymax, N, F) N = near plane, F = far plane

Perspective Projection After perspective projection, viewing frustum is also projected into a canonical view volume (like in parallel projection) (-1, -1, 1) (1, 1, -1) Canonical View Volume x y z

References Hill, chapter 7