University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections III.

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 2005 Tamara Munzner Display Lists, Viewing.
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.
Transformations II Week 2, Wed Jan 17
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 2005 Tamara Munzner Transformations II Week.
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.
Viewing and Transformation
Foundations of Computer Graphics (Spring 2010) CS 184, Lecture 5: Viewing
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Vision/Color Week 5, Mon.
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.
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 Viewing and Projections Mon 22 Sep 2003 project 1 solution demo recap: projections.
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?
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
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)
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.
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.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
OpenGL: Introduction Yanci Zhang Game Programming Practice.
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.
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)
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
©2005, Lee Iverson Lee Iverson UBC Dept. of ECE EECE 478 Viewing and Projection.
Viewing
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
Coordinate Systems Lecture 1 Fri, Sep 2, The Coordinate Systems The points we create are transformed through a series of coordinate systems before.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Viewing/Projection V,
Viewing and Projection. The topics Interior parameters Projection type Field of view Clipping Frustum… Exterior parameters Camera position Camera orientation.
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.
Computer Graphics Projections.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Final Review I University of British Columbia
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
CSE 167 [Win 17], Lecture 5: Viewing Ravi Ramamoorthi
Transformations V, Viewing I Week 3, Fri Jan 22
Rendering Pipeline Aaron Bloomfield CS 445: Introduction to Graphics
CSCE 441 Computer Graphics 3-D Viewing
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Viewing/Projections I Week 3, Fri Jan 25
A Photograph of two papers
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Computer Graphics (Spring 2003)
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)
Viewing/Projections I Week 3, Fri Jan 25
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections III Week 4, Wed Jan 31

2 News extra TA coverage in lab to answer questions Wed 2-3:30 Thu 12:30-2 my office hours reminder (in lab also) Wed (today) Fri 11-12

3 Reading for Today FCG Chapter 7 Viewing FCG Section Windowing Transforms RB rest of Chap Viewing RB rest of App Homogeneous Coords

4 Reading for Next Time RB Chap Color FCG Sections FCG Chap 20 Color FCG Chap 21 Visual Perception

5 Review: Graphics Cameras real pinhole camera: image inverted imageplane eye point point computer graphics camera: convenient equivalent imageplane eye point point center of projection

6 Review: Basic Perspective Projection similar triangles z P(x,y,z) P(x’,y’,z’) z’=d y homogeneouscoords

7 Review: Orthographic Cameras center of projection at infinity no perspective convergence just throw away z values

8 Review: Transforming View Volumes x z NDCS y (-1,-1,-1) (1,1,1) 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

9 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)

10 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)

11 Orthographic Derivation scale, translate, reflect for new coord sys

12 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 same idea for right/left, far/near

13 Orthographic Derivation scale, translate, reflect for new coord sys

14 Orthographic Derivation scale, translate, reflect for new coord sys

15 Orthographic Derivation scale, translate, reflect for new coord sys

16 Orthographic Derivation scale, translate, reflect for new coord sys

17 Orthographic OpenGL glMatrixMode(GL_PROJECTION);glLoadIdentity();glOrtho(left,right,bot,top,near,far);

18 Demo Brown applets: viewing techniques parallel/orthographic cameras projection cameras /viewing_techniques.html

19 Projections II

20 Asymmetric Frusta our formulation allows asymmetry why bother? -z x Frustum right left -z x Frustum z=-n z=-f right left

21 Asymmetric Frusta our formulation allows asymmetry why bother? binocular stereo view vector not perpendicular to view plane Right Eye Left Eye

22 Simpler Formulation left, right, bottom, top, near, far nonintuitive often overkill look through window center symmetric frustum constraints left = -right, bottom = -top

23 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

24 Perspective OpenGL glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(left,right,bot,top,near,far); or glPerspective(fovy,aspect,near,far);

25 Demo: Frustum vs. FOV Nate Robins tutorial (take 2):

26 Projective Rendering Pipeline OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system OCS O2W VCS CCS NDCS DCSmodelingtransformationviewingtransformation projectiontransformation viewporttransformation perspective divide objectworld viewing device normalized device clipping W2VV2C N2D C2N WCS

27 Projection Normalization warp perspective view volume to orthogonal view volume render all scenes with orthographic projection! aka perspective warp x z=  z=d x z=0 z=d

28 Perspective Normalization perspective viewing frustum transformed to cube orthographic rendering of cube produces same image as perspective rendering of original frustum

29 Predistortion

30 Demos Tuebingen applets from Frank Hanisch AppletIndex.html#Transformationen

31 Projective Rendering Pipeline OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system OCS O2W VCS CCS NDCS DCSmodelingtransformationviewingtransformation projectiontransformation viewporttransformation perspective divide objectworld viewing device normalized device clipping W2VV2C N2D C2N WCS

32 Separate Warp From Homogenization warp requires only standard matrix multiply distort such that orthographic projection of distorted objects is desired persp projection w is changed clip after warp, before divide division by w: homogenization CCS NDCS alter w / w VCS projectiontransformation viewing normalized device clipping perspectivedivision V2CC2N

33 Perspective Divide Example 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

34 Perspective Divide Example alter w / w projectiontransformation perspectivedivision after homogenizing, once again w=1

Perspective Normalization matrix formulation warp and homogenization both preserve relative depth (z coordinate)

36 Demo Brown applets: viewing techniques parallel/orthographic cameras projection cameras /viewing_techniques.html

37 Projective Rendering Pipeline OCS - object/model coordinate system WCS - world coordinate system VCS - viewing/camera/eye coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device/display/screen coordinate system OCS O2W VCS CCS NDCS DCSmodelingtransformationviewingtransformation projectiontransformation viewporttransformation perspective divide objectworld viewing device normalized device clipping W2VV2C N2D C2N WCS

38 NDC to Device Transformation map from NDC to pixel coordinates on display NDC range is x = , y = , z = typical display range: x = , y = maximum is size of actual screen z range max and default is (0, 1), use later for visibility x y viewport NDC x y glViewport(0,0,w,h); glDepthRange(0,1); // depth = 1 by default

39 Origin Location yet more (possibly confusing) conventions OpenGL origin: lower left most window systems origin: upper left then must reflect in y when interpreting mouse position, have to flip your y coordinates x y viewport NDC x y

40 N2D Transformation general formulation reflect in y for upper vs. lower left origin scale by width, height, depth translate by width/2, height/2, depth/2 FCG includes additional translation for pixel centers at (.5,.5) instead of (0,0) x y viewport NDC height width x y

41 N2D Transformation x y viewport NDC height width x y

42 Device vs. Screen Coordinates viewport/window location wrt actual display not available within OpenGL usually don’t care use relative information when handling mouse events, not absolute coordinates could get actual display height/width, window offsets from OS loose use of terms: device, display, window, screen... x display viewport display height display width x offset y offset y viewport x 0 0 y

43 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

44 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) O2WW2VV2C N2D C2N

45 Coordinate Systems viewing (4-space, W=1) clipping (4-space parallelepiped, with COP moved backwards to infinity normalized device (3-space parallelepiped) device (3-space parallelipiped) projection matrix divide by w scale & translate projection matrix

46 Perspective To NDCS 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

47 Perspective Derivation simple example earlier: complete: shear, scale, projection-normalization

48 Perspective Derivation earlier: complete: shear, scale, projection-normalization

49 Perspective Derivation earlier: complete: shear, scale, projection-normalization

50 Perspective Derivation

51 Perspective Derivation similarly for other 5 planes 6 planes, 6 unknowns

52 Perspective Example view volume left = -1, right = 1 bot = -1, top = 1 near = 1, far = 4

53 Perspective Example / w

54 OpenGL Example glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45, 1.0, 0.1, ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -5.0 ); glPushMatrix() glTranslate( 4, 4, 0 ); glutSolidTeapot(1); glPopMatrix(); glTranslate( 2, 2, 0); glutSolidTeapot(1); OCS2 O2W VCSmodelingtransformationviewingtransformation projectiontransformation objectworld viewing W2VV2C WCS transformations that are applied first are specified last OCS1 WCS VCS W2O W2O CCS clipping CCS OCS