University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Viewing and Projections Mon 22 Sep 2003 project 1 solution demo recap: projections.

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.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Prog 2, Kangaroo Hall.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections IV.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Projections II Week 4,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections III.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections II.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections III.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Lighting and Shading Week.
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Viewing, Projections.
Projection Matrices CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
Objectives Derive the perspective projection matrices used for standard OpenGL projections Derive the perspective projection matrices used for standard.
Projections and Picking Wed 24 Sep 2003
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Viewing and Projections Wed 17 Oct 2003 project 1 recap: display lists viewing.
Lecture 3 – Transformation And Coordinate Systems
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Midterm Review Week 7, Wed 16 Oct 2003 midterm review project 1 demos, hall.
OpenGL (II). How to Draw a 3-D object on Screen?
Introduction to OpenGL Pipeline From Programmer View Tong-Yee Lee.
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
Introduction to 3D viewing 3D is just like taking a photograph!
Viewing and Projections
Computer Graphics (fall 2009)
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.
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.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
CAP 4703 Computer Graphic Methods Prof. Roy Levow Chapter 5.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
CS 4731: Computer Graphics Lecture 13: Projection Emmanuel Agu.
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.
University of North Carolina at Greensboro
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.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Foundations of Computer Graphics (Spring 2012) CS 184, Lecture 5: 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.
Viewing
Rendering Pipeline Fall, D Polygon Rendering Many applications use rendering of 3D polygons with direct illumination.
Taxonomy of Projections FVFHP Figure Taxonomy of Projections.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections IV.
Viewing and Projection
CS552: Computer Graphics Lecture 11: Orthographic 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.
Outline 3D Viewing Required readings: HB 10-1 to 10-10
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Rendering Pipeline Fall, 2015.
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
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
CSC461: Lecture 20 Parallel Projections in OpenGL
Projections and Normalization
Viewing/Projections I Week 3, Fri Jan 25
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Viewing II Week 4, Mon Jan 25
Last Time Canonical view pipeline Projection Local Coordinate Space
Chap 3 Viewing Pipeline Reading:
Viewing III Week 4, Wed Jan 27
Viewing (Projections)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Presentation transcript:

University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Viewing and Projections Mon 22 Sep 2003 project 1 solution demo recap: projections 1 projections 2

Week 4, Mon 22 Oct 03 © Tamara Munzner2 News Project 1 solution executable available –idea of what’s expected –no need to copy look and feel exactly

Week 4, Mon 22 Oct 03 © Tamara Munzner3 Projection Taxonomy recap planarprojections perspective:1,2,3-point parallel oblique orthographic cabinet cavalier top,front,side axonometric:isometricdimetrictrimetric from 3D to 2D

Week 4, Mon 22 Oct 03 © Tamara Munzner4 Projection recap center of projection I perspective I orthographic oblique I parallel : center of projection at ∞

University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 5 Projections 2

Week 4, Mon 22 Oct 03 © Tamara Munzner6 Perspective Projection project all geometry through a common center of projection (eye point) onto an image plane x z x z y x -z

Week 4, Mon 22 Oct 03 © Tamara Munzner7 Projective Transformations transformation of space –center of projection moves to infinity –view volume transformed from frustum (truncated pyramid) to parallelepiped (box) -z x -z x Frustum Parallelepiped

Week 4, Mon 22 Oct 03 © Tamara Munzner8 View Volumes –specifies field-of-view, used for clipping –restricts domain of z stored for visibility test z perspective view volume orthographic view volume x=left x=right y=top y=bottom z=-near z=-far x VCS x z y y x=left y=top x=right z=-far z=-near y=bottom

Week 4, Mon 22 Oct 03 © Tamara Munzner9 View Volume convention –viewing frustum mapped to specific parallelepiped Normalized Device Coordinates (NDC) same as clipping coords –only objects inside the parallelepiped get rendered –which parallelepiped? depends on rendering system

Week 4, Mon 22 Oct 03 © Tamara Munzner10 Normalized Device Coordinates left/right x =+/- 1, top/bottom y =+/- 1, near/far z =+/- 1 -z x Frustum z=-n z=-f right left z x x= -1 z=1 x=1 Camera coordinates NDC z= -1

Week 4, Mon 22 Oct 03 © Tamara Munzner11 Understanding Z z axis flip changes coord system handedness –RHS before projection (eye/view coords) –LHS after projection (clip, norm device coords) x z VCS y x=left y=top x=right z=-far z=-near y=bottom x z NDCS y (-1,-1,-1) (1,1,1)

Week 4, Mon 22 Oct 03 © Tamara Munzner12 Understanding Z near, far always positive in OpenGL calls glOrtho(left,right,bot,top,near,far); glOrtho(left,right,bot,top,near,far); glFrustum(left,right,bot,top,near,far); glFrustum(left,right,bot,top,near,far); glPerspective(fovy,aspect,near,far); glPerspective(fovy,aspect,near,far); orthographic view volume x z VCS y x=left y=top x=right z=-far z=-near y=bottom perspective view volume x=left x=right y=top y=bottom z=-near z=-far x VCS y

Week 4, Mon 22 Oct 03 © Tamara Munzner13 Understanding Z why near and far plane? –near plane: avoid singularity (division by zero, or very small numbers) –far plane: store depth in fixed-point representation (integer), thus have to have fixed range of values (0…1) avoid/reduce numerical precision artifacts for distant objects

Week 4, Mon 22 Oct 03 © Tamara Munzner14 Asymmetric Frusta our formulation allows asymmetry –why bother? -z x Frustum right left

Week 4, Mon 22 Oct 03 © Tamara Munzner15 Simpler Formulation left, right, bottom, top, near, far –nonintuitive –often overkill look through window center – symmetric frustum constraints left = -right, bottom = -top

Week 4, Mon 22 Oct 03 © Tamara Munzner16 Field-of-View Formulation FOV in one direction + aspect ratio (w/h) –determines FOV in other direction –also set near, far (reasonably intuitive) -z x Frustum z=-n z=-f  fovx/2 fovy/2 h w

Week 4, Mon 22 Oct 03 © Tamara Munzner17 Projection Normalization CCS NDCS VCS perspectivedistortion viewing normalized device clipping distort such that orthographic projection of distorted objects is desired persp projection –convenient coord sys: clipping, hidden surfaces orthographic projection

Week 4, Mon 22 Oct 03 © Tamara Munzner18 Basic Perspective Projection similar triangles z P(x,y,z) P(x’,y’,d) z=d y also nonuniform foreshortening – not affine but

Week 4, Mon 22 Oct 03 © Tamara Munzner19 Basic Perspective Projection can express as homogenous 4x4 matrix!

Week 4, Mon 22 Oct 03 © Tamara Munzner20 Projective Transformations can express as homogeneous 4x4 matrices! 16 matrix entries –multiples of same matrix all describe same transformation –15 degrees of freedom –mapping of 5 points uniquely determines transformation

Week 4, Mon 22 Oct 03 © Tamara Munzner21 Projective Transformations determining the matrix representation –need to observe 5 points in general position, e.g. [left,0,0,1] T  [1,0,0,1] T [0,top,0,1] T  [0,1,0,1] T [0,0,-f,1] T  [0,0,1,1] T [0,0,-n,1] T  [0,0,0,1] T [left*f/n,top*f/n,-f,1] T  [1,1,1,1] T –solve resulting equation system to obtain matrix

Week 4, Mon 22 Oct 03 © Tamara Munzner22 Perspective Projection specific example –assume image plane at z = -1 –a point [x,y,z,1] T projects to [-x/z,-y/z,-z/z,1] T  [x,y,z,-z] T -z

Week 4, Mon 22 Oct 03 © Tamara Munzner23 Perspective Projection

Week 4, Mon 22 Oct 03 © Tamara Munzner24 Projection Normalization CCS NDCS alter w / w VCS projectiontransformation viewing normalized device clipping distort such that orthographic projection of distorted objects is desired persp projection –separate division from standard matrix multiplies –division: normalization perspectivedivision

Week 4, Mon 22 Oct 03 © Tamara Munzner25 Orthographic Derivation scale, translate, reflect for new coord sys x z VCS y x=left y=top x=right z=-far z=-near y=bottom x z NDCS y (-1,-1,-1) (1,1,1)

Week 4, Mon 22 Oct 03 © Tamara Munzner26 Orthographic Derivation scale, translate, reflect for new coord sys

Week 4, Mon 22 Oct 03 © Tamara Munzner27 Orthographic Derivation solving for a and b gives: same idea for right/left, far/near

Week 4, Mon 22 Oct 03 © Tamara Munzner28 Orthographic OpenGL glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(left,right,bot,top,near,far);

Week 4, Mon 22 Oct 03 © Tamara Munzner29 Perspective Derivation x z NDCS y (-1,-1,-1) (1,1,1) x=left x=right y=top y=bottom z=-near z=-far x VCS y z

Week 4, Mon 22 Oct 03 © Tamara Munzner30 Perspective Derivation earlier: complete: shear, scale, projection-normalization

Week 4, Mon 22 Oct 03 © Tamara Munzner31 Perspective Derivation

Week 4, Mon 22 Oct 03 © Tamara Munzner32 Perspective Derivation similarly for other 5 planes 6 planes, 6 unknowns

Week 4, Mon 22 Oct 03 © Tamara Munzner33 Perspective OpenGL glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(left,right,bot,top,near,far); or glPerspective(fovy,aspect,near,far);

Week 4, Mon 22 Oct 03 © Tamara Munzner34 Perspective Example view volume left = -1, right = 1 bot = -1, top = 1 near = 1, far = 4

Week 4, Mon 22 Oct 03 © Tamara Munzner35 Perspective Example tracks in VCS: left x=-1, y=-1 right x=1, y=-1 view volume left = -1, right = 1 bot = -1, top = 1 near = 1, far = 4 z=-1 z=-4 x z VCS top view 1 1 NDCS (z not shown) real midpoint 0 xmax-1 0 DCS (z not shown) ymax-1 x=-1 x=1

Week 4, Mon 22 Oct 03 © Tamara Munzner36 Perspective Example / w

Week 4, Mon 22 Oct 03 © Tamara Munzner37 Viewport Transformation generate pixel coordinates –map x, y from range –1…1 (normalized device coordinates) to pixel coordinates on the display –involves 2D scaling and translation x y display viewport

Week 4, Mon 22 Oct 03 © Tamara Munzner38 Viewport Transformation (-1,-1) (1,1) (0,0) (w,h) NDCS DCS glViewport(x,y,a,b); default : a b x y glViewport(0,0,w,h); OpenGL

Week 4, Mon 22 Oct 03 © Tamara Munzner39 Projective Rendering Pipeline OCS - object coordinate system WCS - world coordinate system VCS - viewing coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device coordinate system OCS WCS VCS CCS NDCS DCSmodelingtransformationviewingtransformationprojectiontransformationviewporttransformation alter w / w objectworld viewing device normalized device clipping perspectivedivision glVertex3f(x,y,z) glTranslatef(x,y,z)glRotatef(th,x,y,z)....gluLookAt(...) glFrustum(...) glutInitWindowSize(w,h)glViewport(x,y,a,b)