1 / 54

Viewing/Projections III Week 4, Wed Jan 31

Explore the concepts of orthographic and perspective projections, camera models, and view volumes in computer graphics. Learn about projection matrices, OpenGL implementations, and the rendering pipeline. Review various demonstrations and resources to enhance your understanding of viewing transformations.

cmcmullen
Download Presentation

Viewing/Projections III Week 4, Wed Jan 31

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. http://www.ugrad.cs.ubc.ca/~cs314/Vjan2007 Viewing/Projections IIIWeek 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) 11-12 • Fri 11-12

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

  4. Reading for Next Time • RB Chap Color • FCG Sections 3.2-3.3 • FCG Chap 20 Color • FCG Chap 21 Visual Perception

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

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

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

  8. orthographic view volume perspective view volume y=top y=top x=left x=left y y z x=right VCS z=-near x VCS y=bottom z=-far z=-far x y=bottom x=right z=-near Review: Transforming View Volumes NDCS y (1,1,1) z (-1,-1,-1) x

  9. NDCS y (1,1,1) z (-1,-1,-1) x Orthographic Derivation • scale, translate, reflect for new coord sys VCS y=top x=left y z x=right x z=-far y=bottom z=-near

  10. NDCS y (1,1,1) z (-1,-1,-1) x Orthographic Derivation • scale, translate, reflect for new coord sys VCS y=top x=left y z x=right x z=-far y=bottom z=-near

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

  12. Orthographic Derivation • scale, translate, reflect for new coord sys VCS y=top x=left y z x=right x z=-far y=bottom z=-near 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 • http://www.cs.brown.edu/exploratories/freeSoftware/catalogs/viewing_techniques.html

  19. Projections II

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

  21. Asymmetric Frusta • our formulation allows asymmetry • why bother? binocular stereo • view vector not perpendicular to view plane Left Eye Right 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) x w h fovx/2 Frustum -z  fovy/2 z=-n z=-f

  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): • http://www.xmission.com/~nate/tutors.html

  26. viewing transformation projection transformation modeling transformation viewport transformation 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 object world viewing O2W W2V V2C VCS WCS OCS clipping C2N CCS perspectivedivide normalized device N2D NDCS device DCS

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

  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 • http://www.gris.uni-tuebingen.de/projects/grdev/doc/html/etc/AppletIndex.html#Transformationen

  31. viewing transformation projection transformation modeling transformation viewport transformation 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 object world viewing O2W W2V V2C VCS WCS OCS clipping C2N CCS perspectivedivide normalized device N2D NDCS device DCS

  32. Separate Warp From Homogenization normalized device clipping • 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 viewing V2C C2N CCS VCS NDCS projection transformation perspective division alter w / w

  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 • after homogenizing, once again w=1 projection transformation perspective division alter w / w

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

  36. Demo • Brown applets: viewing techniques • parallel/orthographic cameras • projection cameras • http://www.cs.brown.edu/exploratories/freeSoftware/catalogs/viewing_techniques.html

  37. viewing transformation projection transformation modeling transformation viewport transformation 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 object world viewing O2W W2V V2C VCS WCS OCS clipping C2N CCS perspectivedivide normalized device N2D NDCS device DCS

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

  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 0 500 x y 0 y -1 viewport x NDC 1 1 -1 300

  40. 0 500 x y 0 y height -1 viewport x NDC 1 width 1 -1 300 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)

  41. 0 500 x y 0 y height -1 viewport x NDC 1 width 1 -1 300 N2D Transformation

  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... 0 1024 x 0 y 0 500 y offset x 0 y display height x offset viewport viewport 300 display 768 display width

  43. Perspective Example view volume left = -1, right = 1 bot = -1, top = 1 near = 1, far = 4 tracks in VCS: left x=-1, y=-1 right x=1, y=-1 x=1 x=-1 1 ymax-1 z=-4 realmidpoint -1 z=-1 1 xmax-1 -1 0 -1 0 x NDCS (z not shown) DCS (z not shown) z VCStop view

  44. viewing transformation modeling transformation viewport transformation 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 glVertex3f(x,y,z) object world viewing alter w O2W W2V V2C VCS WCS OCS glFrustum(...) projection transformation clipping glTranslatef(x,y,z) glRotatef(th,x,y,z) .... gluLookAt(...) C2N / w CCS perspective division normalized device glutInitWindowSize(w,h) glViewport(x,y,a,b) N2D NDCS device DCS

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

  46. Perspective To NDCS Derivation VCS NDCS y=top x=left y (1,1,1) y z (-1,-1,-1) x z z=-near y=bottom z=-far x x=right

  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

More Related