cs 184 computer graphics
play

CS-184: Computer Graphics Lecture #8: Projection Prof. James - PowerPoint PPT Presentation

1 CS-184: Computer Graphics Lecture #8: Projection Prof. James OBrien University of California, Berkeley V2016-F-08-1.0 2 Today Windowing and Viewing Transformations Windows and viewports Orthographic projection


  1. 1 CS-184: Computer Graphics Lecture #8: Projection Prof. James O’Brien University of California, Berkeley V2016-F-08-1.0 2 Today • Windowing and Viewing Transformations • Windows and viewports • Orthographic projection • Perspective projection 2 08-Perspective.key - September 28, 2016

  2. 3 Screen Space • Monitor has some number of pixels • e.g. 1024 x 768 • Some sub-region used for given program • You call it a window • Let’s call it a viewport instead [ 1024 , 768 ] [ 1024 , 768 ] [ 690 , 705 ] [ 60 , 350 ] 3 [ 0 , 0 ] [ 0 , 0 ] 4 Screen Space • May not really be a “screen” • Image file • Printer • Other • Little pixel details • Sometimes odd • Upside down • Hexagonal 4 From Shirley textbook. 08-Perspective.key - September 28, 2016

  3. 5 Screen Space • Viewport is somewhere on screen • You probably don’t care where • Window System likely manages this detail • Sometimes you care exactly where • Viewport has a size in pixels • Sometimes you care (images, text, etc. ) • Sometimes you don’t (using high-level library) 5 6 Screen Space nx- 0.5,ny-0.5 Integer Pixel Addresses j =5 -0.5,-0.5 i =3 10 × 10 Image Resolution 6 08-Perspective.key - September 28, 2016

  4. 7 Screen Space 1,1 Float Pixel Coordinates v = 0.55 = ( j + 0.5)/ ny 0,0 u = 0.35 = ( i + 0.5)/ nx 7 8 Canonical View Space • Canonical view region • 2D: [-1,-1] to [+1,+1] +1,+1 x =0.0, y =0.0 From Shirley textbook. 8 -1,-1 08-Perspective.key - September 28, 2016

  5. 9 Canonical View Space • Canonical view region y y (1,1) (-1,1) x reflect-y x • 2D: [-1,-1] to [+1,+1] (1,-1) (-1,-1) scale (- n x /2, n y /2) (-0.5, n y -0.5) y y x translate x ( n x /2,- n y /2) ( n x -0.5, -0.5) From Shirley textbook. (Image coordinates are up-side-down.)   n x 2 0 n x � 1     x 0 x 2 0 n y n y � 1 y 0 y    = −    2 2 Remove minus for up-side-up   1 1 0 0 1 9 10 Projection • Process of going from 3D to 2D • Studies throughout history ( e.g. painters) • Different types of projection Many special cases in books just • Linear } one of these two... • Orthographic • Perspective • Nonlinear Orthographic is special case of perspective... 10 08-Perspective.key - September 28, 2016

  6. 11 Perspective Projections 11 12 Ray Generation vs. Projection Viewing in ray tracing • start with image point • compute ray that projects to that point • do this using geometry Viewing by projection • start with 3D point • compute image point that it projects to • do this using transforms Inverse processes • ray gen. computes the preimage of projection 12 08-Perspective.key - September 28, 2016

  7. 13 Linear Projection • Projection onto a planar surface • Projection directions either • Converge to a point • Are parallel (converge at infinity) 13 14 Linear Projection • A 2D view Perspective Orthographic 14 08-Perspective.key - September 28, 2016

  8. 15 Linear Projection Orthographic Perspective 15 16 Linear Projection Orthographic Perspective 16 08-Perspective.key - September 28, 2016

  9. 17 Linear Projection • A 2D view Note how different things can be seen Parallel lines “meet” at infinity Perspective Orthographic 17 18 Orthographic Projection • No foreshortening • Parallel lines stay parallel • Poor depth cues 18 08-Perspective.key - September 28, 2016

  10. 19 Orthographic Projection 19 20 Canonical View Space • Canonical view region • 2D: [-1,-1] to [+1,+1] From Shirley textbook. • Define arbitrary window and define objects • Transform window to canonical region • Do other things (we’ll see clipping latter) • Transform canonical to screen space • Draw it. 20 08-Perspective.key - September 28, 2016

  11. 21 Canonical View Space World Coordinates Canonical Screen Space (Meters) (Pixels) Note distortion issues... 21 22 Canonical View Space • Canonical view region • 3D: [-1,-1,-1] to [+1,+1,+1] • Assume looking down -Z axis • Recall that “Z is in your face” -Z [1,1,1] [-1,-1,-1] 22 08-Perspective.key - September 28, 2016

  12. 23 Orthographic Projection • Convert arbitrary view volume to canonical -Z [1,1,1] [-1,-1,-1] 23 24 Orthographic Projection View vector Up vector far,bottom,left Center Right = view X up near,top,right Origin *Assume up is perpendicular to view. 24 08-Perspective.key - September 28, 2016

  13. 25 Orthographic Projection • Step 1: translate center to origin 25 26 Orthographic Projection • Step 1: translate center to origin • Step 2: rotate view to -Z and up to +Y 26 08-Perspective.key - September 28, 2016

  14. 27 Orthographic Projection • Step 1: translate center to origin • Step 2: rotate view to -Z and up to +Y • Step 3: center view volume 27 28 Orthographic Projection • Step 1: translate center to origin • Step 2: rotate view to -Z and up to +Y • Step 3: center view volume • Step 4: scale to canonical size 28 08-Perspective.key - September 28, 2016

  15. 29 Orthographic Projection • Step 1: translate center to origin • Step 2: rotate view to -Z and up to +Y • Step 3: center view volume • Step 4: scale to canonical size M = S · T 2 · R · T 1 M = M o · M v 29 30 Perspective Projection • Foreshortening: further objects appear smaller • Some parallel line stay parallel, most don’t • Lines still look like lines • Z ordering preserved (where we care) 30 08-Perspective.key - September 28, 2016

  16. 31 Perspective Projection Image from D. Forsyth Pinhole a.k.a center of projection 31 32 Perspective Projection Image from D. Forsyth Foreshortening: distant objects appear smaller 32 08-Perspective.key - September 28, 2016

  17. 33 Perspective Projection • Vanishing points • Depend on the scene • Not intrinsic to camera “One point perspective” 33 34 Perspective Projection • Vanishing points • Depend on the scene • Nor intrinsic to camera “Two point perspective” 34 08-Perspective.key - September 28, 2016

  18. 35 Perspective Projection • Vanishing points • Depend on the scene • Not intrinsic to camera “Three point perspective” 35 36 Perspective Projection View Frustum u v n 36 08-Perspective.key - September 28, 2016

  19. 37 Perspective Projection Far f Top Near t n Bottom Y View b Up Center Distance to image plane i -Z 37 38 Perspective Projection • Step 1: Translate center to origin Y -Z 38 08-Perspective.key - September 28, 2016

  20. 39 Perspective Projection • Step 1: Translate center to origin • Step 2: Rotate view to -Z , up to +Y Y -Z 39 40 Perspective Projection • Step 1: Translate center to origin • Step 2: Rotate view to -Z , up to +Y • Step 3: Shear center-line to -Z axis Y -Z 40 08-Perspective.key - September 28, 2016

  21. 41 Perspective Projection • Step 1: Translate center to origin • Step 2: Rotate view to -Z , up to +Y • Step 3: Shear center-line to -Z axis 1 0 0 0 & # $ ! 0 1 0 0 • Step 4: Perspective $ ! i f + $ 0 0 f ! i $ ! 1 $ − ! 0 0 0 $ ! i % " -Z 41 42 Perspective Projection • Step 4: Perspective • Points at z=-i stay at z=-i • Points at z=-f stay at z=-f • Points at z= 0 goto z=± ∞ -Z • Points at z=- ∞ goto z=-(i+f) • x and y values divided by -z/i 1 0 0 0 • Straight lines stay straight & # $ ! 0 1 0 0 • Depth ordering preserved in [ -i,-f ] $ ! i f + $ 0 0 f ! i $ ! • Movement along lines distorted 1 $ − ! 0 0 0 $ ! i % " 42 08-Perspective.key - September 28, 2016

  22. 43 Perspective Projection From Shirley textbook. WRONG! 1 0 0 0 & # $ ! 0 1 0 0 $ ! i f + $ 0 0 f ! i $ ! 1 $ − ! 0 0 0 $ ! i % " 43 44 Perspective Projection “Eye” plane Top Near Far s e n i l l a t n o z i r o h e m o S View vector z ˆ 44 08-Perspective.key - September 28, 2016

  23. 45 Perspective Projection Visualizing division of x and y but not z z ˆ 45 46 Perspective Projection Motion in x,y z ˆ 46 08-Perspective.key - September 28, 2016

  24. 47 Perspective Projection Note that points on near plane fixed z ˆ 47 48 Perspective Projection Recall that points on far plane will stay there... z ˆ 48 08-Perspective.key - September 28, 2016

  25. 49 Perspective Projection When we also divide z points must remain on straight lines z ˆ 49 50 Perspective Projection Lines extend outside view volume z ˆ 50 08-Perspective.key - September 28, 2016

  26. 51 Perspective Projection Motion in z z ˆ 51 52 Perspective Projection Motion in z − ∞ z ˆ 52 08-Perspective.key - September 28, 2016

  27. 53 Perspective Projection Motion in z − ∞ z ˆ 53 54 Perspective Projection Total motion z ˆ 54 08-Perspective.key - September 28, 2016

  28. 55 Perspective Projection • Step 1: Translate center to orange • Step 2: Rotate view to -Z , up to +Y • Step 3: Shear center-line to -Z axis • Step 4: Perspective • Step 5: center view volume • Step 6: scale to canonical size -Z 55 56 Perspective Projection • Step 1: Translate center to orange } M v • Step 2: Rotate view to -Z , up to +Y • Step 3: Shear center-line to -Z axis M p } • Step 4: Perspective • Step 5: center view volume } M o • Step 6: scale to canonical size M = M o · M p · M v -Z 56 08-Perspective.key - September 28, 2016

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend