Presentation is loading. Please wait.

Presentation is loading. Please wait.

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Projections II Week 4,

Similar presentations


Presentation on theme: "University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Projections II Week 4,"— Presentation transcript:

1 University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner http://www.ugrad.cs.ubc.ca/~cs314/Vjan2005 Projections II Week 4, Wed Jan 26

2 2 Reading (Mon and today) FCG Section 5.3.1 rest of Chapter 6 RB rest of Chapter Viewing rest of Appendix Homogeneous Coords

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

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

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

6 6 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

7 7 Review: Ortho to NDC 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)

8 8 NDC to Viewport Transformation generate pixel coordinates map x, y from range –1…1 (NDC) to pixel coordinates on the display involves 2D scaling and translation x y display viewport

9 9 NDC to 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 2D scaling and translation

10 10 Origin Location yet more possibly confusing conventions OpenGL: lower left most window systems: upper left often have to flip your y coordinates when interpreting mouse position

11 11 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

12 12 Viewing Transformation OCS WCS VCSmodelingtransformationviewingtransformation OpenGL ModelView matrix objectworld viewing y x VCS Peye z y x WCS y z OCS image plane

13 13 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

14 14 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

15 15 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

16 16 Perspective Projection alter w / w projectiontransformation perspectivedivision

17 17 Canonical View Volumes standardized viewing volume representation orthographic perspective orthogonal parallel x or y -z x or y -z 1 Front Plane front plane back plane x or y = +/- z

18 18 Why Canonical View Volumes? permits standardization clipping easier to determine if an arbitrary point is enclosed in volume consider clipping to six arbitrary planes of a viewing volume versus canonical view volume rendering projection and rasterization algorithms can be reused

19 19 Projection Normalization one additional step of standardization warp perspective view volume to orthogonal view volume render all scenes with orthographic projection! x z=  z=d x z=0 z=d

20 20 Predistortion

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

22 22 Demos Tuebingen applets from Frank Hanisch http://www.gris.uni-tuebingen.de/projects/grdev/doc/html/etc/ AppletIndex.html#Transformationen

23 Perspective Warp matrix formulation preserves relative depth (third coordinate) what does mean?

24 24 Projection Normalization distort such that orthographic projection of distorted objects is desired persp projection separate division from standard matrix multiplies clip after warp, before divide division: normalization CCS NDCS alter w / w VCS projectiontransformation viewing normalized device clipping perspectivedivision

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

26 26 Coordinate Systems http://www.btinternet.com/~danbgs/perspective/

27 27 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

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

29 29 Perspective Derivation

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

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

32 32 Perspective Example / w

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

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

35 35 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

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

37 37 Demo: Frustum vs. FOV Nate Robins tutorial (take 2): http://www.xmission.com/~nate/tutors.html

38 38 Projection Taxonomy planarprojections perspective:1,2,3-point parallel oblique orthographic cabinet cavalier top,front,side axonometric:isometricdimetrictrimetric http://ceprofs.tamu.edu/tkramer/ENGR%20111/5.1/20

39 39 Perspective Projections one-pointperspective two-pointperspective three-pointperspective classified by vanishing points

40 Parallel Projection projectors are all parallel vs. perspective projectors that converge orthographic: projectors perpendicular to projection plane oblique: projectors not necessarily perpendicular to projection plane ObliqueOrthographic

41 41 Axonometric Projections projectors perpendicular to image plane select axis lengths http://ceprofs.tamu.edu/tkramer/ENGR%20111/5.1/20

42 42 Oblique Projections x y z cavalier d d x y z cabinet d d / 2 projectors oblique to image plane select angle between front and z axis lengths remain constant both have true front view cavalier: distance true cabinet: distance half

43 43 Demos Tuebingen applets from Frank Hanisch http://www.gris.uni-tuebingen.de/projects/grdev/doc/html/etc/ AppletIndex.html#Transformationen


Download ppt "University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Projections II Week 4,"

Similar presentations


Ads by Google