viewing projections iii week 4 wed jan 31
play

Viewing/Projections III Week 4, Wed Jan 31 - PowerPoint PPT Presentation

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections III Week 4, Wed Jan 31 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2007 News extra TA coverage in lab to answer questions Wed 2-3:30


  1. University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections III Week 4, Wed Jan 31 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2007

  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 2

  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 3

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

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

  6. Review: Basic Perspective Projection y d y ' y ⋅ similar triangles similar triangles y ' = z = → z d P(x,y,z) P(x,y,z) y y x d ⋅ z = ' d x ' P(x x’ ’,y ,y’ ’, ,z z’ ’) ) P( = z z z z’ ’=d =d z x   1 0 0 0 homogeneous x homogeneous     z / d     coords coords 0 1 0 0 y   y     0 0 1 0     z / d z     0 0 1 d 0      z / d    d       6

  7. Review: Orthographic Cameras x 1 0 0 0 x       • center of projection at infinity p       y 0 1 0 0 y • no perspective convergence p       = • just throw away z values z 0 0 0 0 z       p       1 0 0 0 1 1       7

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

  9. Orthographic Derivation • scale, translate, reflect for new coord sys 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 9

  10. Orthographic Derivation • scale, translate, reflect for new coord sys y top y ' 1 = → = y ' a y b = ⋅ + y bot y ' 1 = → = − 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 10

  11. Orthographic Derivation • scale, translate, reflect for new coord sys y top y ' 1 1 a top b = → = = ⋅ + y ' a y b = ⋅ + y bot y ' 1 1 a bot b = → = − − = ⋅ + 2 1 top b b 1 a top , b 1 a bot = + = − ⋅ = − − ⋅ top bot − 1 a top 1 a bot − ⋅ = − − ⋅ 2 top ⋅ b 1 = − 1 ( 1 ) a bot ( a top ) top bot − − = − ⋅ − − ⋅ − ( top bot ) 2 top 2 a ( bot top ) − − ⋅ = − + b = top bot − 2 a = top bot − − top bot b − = top bot − 11

  12. Orthographic Derivation • scale, translate, reflect for new coord sys y top y ' 1 = → = y ' a y b = ⋅ + y bot y ' 1 = → = − 2 VCS a = top bot − y=top x=left top bot y + b = − z top bot − x=right x z=-far y=bottom z=-near same idea for right/left, far/near same idea for right/left, far/near 12

  13. Orthographic Derivation • scale, translate, reflect for new coord sys 2 right left +   0 0 −   right left right left − −   2 top bot   + 0 0 −   top bot top bot − − P ' P =    2 far near  − + 0 0 −   far near far near − −     0 0 0 1     13

  14. Orthographic Derivation • scale, translate, reflect for new coord sys 2 right left +   0 0 −   right left right left − −   2 top bot   + 0 0 −   top bot top bot − − P ' P =    2 far near  − + 0 0 −   far near far near − −     0 0 0 1     14

  15. Orthographic Derivation • scale, translate, reflect for new coord sys 2 right left +   0 0 −   right left right left − −   2 top bot   + 0 0 −   top bot top bot − − P ' P =    2 far near  − + 0 0 −   far near far near − −     0 0 0 1     15

  16. Orthographic Derivation • scale, translate, reflect for new coord sys 2 right left +   0 0 −   right left right left − −   2 top bot   + 0 0 −   top bot top bot − − P ' P =    2 far near  − + 0 0 −   far near far near − −     0 0 0 1     16

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

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

  19. Projections II 19

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

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

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

  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 x w w h fovx/2 fovx /2 h Frustum Frustum -z -z fovy/2 fovy /2 α α z=-n z=-n z=-f z=-f 23

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

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

  26. Projective Rendering Pipeline object world viewing O2W W2V V2C O2W W2V V2C VCS VCS OCS WCS OCS WCS projection projection modeling modeling viewing viewing transformation transformation transformation transformation transformation transformation clipping C2N C2N CCS CCS OCS - object/model coordinate system perspective perspective WCS - world coordinate system normalized divide divide device VCS - viewing/camera/eye coordinate N2D N2D system NDCS NDCS viewport viewport CCS - clipping coordinate system transformation transformation NDCS - normalized device coordinate device system DCS DCS DCS - device/display/screen coordinate system 26

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

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

  29. Predistortion 29

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

  31. Projective Rendering Pipeline object world viewing O2W W2V V2C O2W W2V V2C VCS VCS OCS WCS OCS WCS projection projection modeling modeling viewing viewing transformation transformation transformation transformation transformation transformation clipping C2N C2N CCS CCS OCS - object/model coordinate system perspective perspective WCS - world coordinate system normalized divide divide device VCS - viewing/camera/eye coordinate N2D N2D system NDCS NDCS viewport viewport CCS - clipping coordinate system transformation transformation NDCS - normalized device coordinate device system DCS DCS DCS - device/display/screen coordinate system 31

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

Recommend


More recommend