1 / 44

Viewing/Projection IV Week 4, Fri Jan 29

http://www.ugrad.cs.ubc.ca/~cs314/Vjan2010. Viewing/Projection IV Week 4, Fri Jan 29. News. extra TA office hours in lab 005 Fri 2-4 (Garrett) Tamara's usual office hours in lab Fri 4-5 hand in H1 here/now or in box next to 005 lab by 5pm correction: problem 6 worth 54 not 60 marks.

Download Presentation

Viewing/Projection IV Week 4, Fri Jan 29

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/Vjan2010 Viewing/Projection IVWeek 4, Fri Jan 29

  2. News • extra TA office hours in lab 005 • Fri 2-4 (Garrett) • Tamara's usual office hours in lab • Fri 4-5 • hand in H1 here/now or in box next to 005 labby 5pm • correction: problem 6 worth 54 not 60 marks

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

  4. 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: View Volumes • specifies field-of-view, used for clipping • restricts domain of z stored for visibility test z

  5. Review: Understanding Z • z axis flip changes coord system handedness • RHS before projection (eye/view coords) • LHS after projection (clip, norm device coords) VCS NDCS y=top y (1,1,1) x=left y z (-1,-1,-1) z x x=right x z=-far y=bottom z=-near

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

  7. Review: Orthographic Derivation • scale, translate, reflect for new coord sys

  8. Demo • Robins demo: projection • orthographic • perspective

  9. Projections II

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

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

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

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

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

  15. Demo: Frustum vs. FOV • Nate Robins tutorial (take 2): projection • frustum vs perspective

  16. 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

  17. Perspective Warp • warp perspective view volume to orthogonal view volume • render all scenes with orthographic projection! • aka perspective normalization x x z=d z=d z=0 z=

  18. Perspective Warp • perspective viewing frustum transformed to cube • orthographic rendering of warped objects in cube produces same image as perspective rendering of original frustum

  19. Predistortion

  20. 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

  21. Separate Warp From Homogenization normalized device clipping • warp requires only standard matrix multiply • distort such that orthographic projection of distorted objects shows desired perspective 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

  22. 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

  23. Perspective Divide Example • after homogenizing, once again w=1 projection transformation perspective division alter w / w

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

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

  26. 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

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

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

  29. Perspective Derivation earlier: complete: shear, scale, projection-normalization

  30. Perspective Derivation

  31. Perspective Derivation • similarly for other 5 planes • 6 planes, 6 unknowns

  32. 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

  33. 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

  34. 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

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

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

  37. 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

  38. 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(a,x,y,z) .... gluLookAt(...) C2N / w CCS perspective division normalized device glutInitWindowSize(w,h) glViewport(x,y,a,b) N2D NDCS device DCS

  39. 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 • framebuffer

  40. 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

  41. Perspective Example view volume • left = -1, right = 1 • bot = -1, top = 1 • near = 1, far = 4

  42. Perspective Example / w

  43. viewing transformation projection transformation modeling transformation OpenGL Example glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45, 1.0, 0.1, 200.0 ); 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); object world viewing clipping O2W W2V V2C CCS VCS OCS WCS CCS VCS • transformations that are applied to object first are specified last WCS W2O OCS1 W2O OCS2

  44. Reading for Next Time • RB Chap Color • FCG Sections 3.2-3.3 • FCG Chap 20 Color • FCG Chap 21.2.2 Visual Perception (Color)

More Related