Part One - Parallel Projection textbook

Slides:



Advertisements
Similar presentations
Computer Graphics - Viewing -
Advertisements

1 Computer Graphics Chapter 8 3D Transformations.
Three-Dimensional Viewing Sang Il Park Sejong University Lots of slides are stolen from Jehee Lee’s.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Based on slides created by Edward Angel
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
CS 352: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Viewing Transformations
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
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!
And an introduction to matrices COORDINATE SYSTEMS JEFF CHASTINE 1.
Transformation & Projection Feng Yu Proseminar Computer Graphics :
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics I, Fall 2010 Computer Viewing.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
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.
CSE Real Time Rendering Week 5. Slides(Some) Courtesy – E. Angel and D. Shreiner.
2003CS Hons RW778 Graphics1 Chapter 7: Three-Dimensional Viewing Chapter 5: Camera with parallel projection Chapter 5: Camera with parallel projection.
The Camera Analogy ► Set up your tripod and point the camera at the scene (viewing transformation) ► Arrange the scene to be photographed into the desired.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Three-Dimensional Viewing
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
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Classical Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
Viewing and Projection
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
Programming with OpenGL Part 2: Complete Programs Ed Angel Professor of Emeritus of Computer Science University of New Mexico.
CS5500 Computer Graphics April 23, Today’s Topic Details of the front-end of the 3D pipeline: –How to construct the viewing matrix? –How to construct.
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
Digital Image Processing Additional Material : Imaging Geometry 11 September 2006 Digital Image Processing Additional Material : Imaging Geometry 11 September.
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
Viewing Angel Angel: Interactive Computer Graphics5E © Addison-Wesley
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Computer Viewing Isaac Gang University of Mary Hardin-Baylor.
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.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
CS 490: Computer Graphics Chapter 5: Viewing. Interactive Computer GraphicsChapter Overview Specifying the viewpoint Specifying the projection Types.
Chapter 11 Three-Dimensional Geometric and Modeling Transformations
Three Dimensional Viewing
Viewing Viewing and viewing space (camera space)
Viewing.
Computer Viewing.
Isaac Gang University of Mary Hardin-Baylor
and an introduction to matrices
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
Projections and Normalization
Introduction to Computer Graphics with WebGL
CSC461: Lecture 19 Computer Viewing
Viewing/Projections I Week 3, Fri Jan 25
Introduction to Computer Graphics with WebGL
Projections and Hidden Surface Removal
Chapter V Vertex Processing
Last Time Canonical view pipeline Projection Local Coordinate Space
Introduction to Computer Graphics with WebGL
University of New Mexico
Viewing (Projections)
Computer Graphics Computer Viewing
Computer Viewing Ed Angel Professor Emeritus of Computer Science
Part Two - Perspective Projection textbook
CS 352: Computer Graphics Chapter 5: Viewing.
Presentation transcript:

Part One - Parallel Projection textbook 5.1-5.3

Viewing Types Parallel Perspective The two major categories of Projection: Parallel Perspective The default is parallel with a clipping volume of -1 to 1 on each axis.

Perspective www.cs.helsinki.fi http://www.ider.herts.ac.uk/school/courseware/graphics/images/two_point_perspective.gif

docs.autodesk.com

Which is better? Q: Which is better, parallel or perspective? A: Of course, it depends. Perspective looks more realistic. Parallel is required for design. In parallel, lines are not foreshortened, hence can be used for measuring.

Projection of the World onto the Projection Plane http://local.wasp.uwa.edu.au/~pbourke/stereographics/HET409_2003/frustum.html

xp = x z / d (10,?,-20) -Z When P = (5, ?, -1) Xp = 5 / (-1/-1) = 5 (5,?,-10) When P = (5, ?, -5) Xp = 5 / (-5/-1) = 1 (5,?,-5) When P = (10, ?, -20) Xp = 10 / (-20/-1) = .5 (5,?,-1) +X When P = (5, ?, -10) Xp = 5 / (-10/-1) = .5 +Z This very simple formula only works when eye is at the origin.

Viewing Issues We need the ability to work in units of the application. We need to position the camera independently of the objects. We want to be able to specify a clipping volume in units related to the application. We want to be able to do either parallel or perspective projections. Angel textbook page 223

Implementation Since we do not need to work with the intermediate values, we can combine the model view matrix and the projection matrix. gl_Position = matrix * vPosition; Or, leave them separate and have the vertex shader combine them. gl_Position = projection * modelview * vPosition; Angel textbook figure 5.11

Parallel Projection Matrix Parallel is a special case of perspective where the eye is infinite distance from the scene. If we assume the eye is somewhere along the +Z axis then:  

Example 1 Given a world -50 to 50 on each axis, we get the matrix   Given a world -50 to 50 on each axis, left = -50 right = 50 top = 50 bottom = -50 near = 50 far = -50 we get the matrix ┌ .02 0 0 0 ┐ │ 0 .02 0 0 │ │ 0 0 .02 0 │ └ 0 0 0 1 ┘ P = (25,50,0) P' = (.5, 1, 0)

Example 2 Given a world -1 to 1 on each axis, we get the matrix   Given a world -1 to 1 on each axis, left = -1 right = 1 top = 1 bottom = -1 near = 1 far = -1 we get the matrix ┌ 1 0 0 0 ┐ │ 0 1 0 0 │ │ 0 0 1 0 │ └ 0 0 0 1 ┘ So, the default view yields the identity projection matrix.

Example 3 Given a world we get the matrix ┌ 1 0 0 -1 ┐ │ 0 1 0 -1 │   Given a world left = 0 right = 2 top = 2 bottom = 0 near = 0 far = -2 we get the matrix ┌ 1 0 0 -1 ┐ │ 0 1 0 -1 │ │ 0 0 1 -1 │ └ 0 0 0 1 ┘ This world is the same size as the default. To center this world just move everything to the left and down.

Building the simple parallel matrix S = scale ( 2/(right-left), 2/(top-bottom), 2(near-far)); T = translate ( -(right+left)/2, -(top+bottom)/2, (far+near)/2); ProjMatrix = S * T ; Angel textbook page 239

Limitations of Simple Parallel eye must be at infinity on the Z axis. up is always toward +Y. We need the ability to work in units of the application. We need to position the camera independently of the objects. We want to be able to specify a clipping volume in units related to the application. We want to be able to do either parallel or perspective projections.

Look At eye = X,Y,Z location of eye at = direction eye is pointed lookAt (eye, at, up); eye = X,Y,Z location of eye at = direction eye is pointed up = vector to indicate up note that moving and rotating the camera is the same as moving and rotating the world

Implementation modelView = ortho (left, right, bottom, top, near, far); var eye = vec3 (Ex, Ey, Ez); var at = vec3 (0, 0, 0); var up = vec3 (0, 1, 0); projMatrix = lookAt (eye, at, up); // pass modelView and projMatrix to GPU

Frustrum Matrix A = (right+left)/(right-left) B = (top+bottom)/(top-bottom) C = -(far+near)/(far-near) D = -2*far*near/(far-near) E = 2 * near/(right-left) F = 2 * near/(top-bottom)