viewing 2
play

Viewing 2 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2016 Projections I - PowerPoint PPT Presentation

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner Viewing 2 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2016 Projections I 2 Pinhole Camera ingredients box, film, hole punch result picture


  1. University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner Viewing 2 http://www.ugrad.cs.ubc.ca/~cs314/Vjan2016

  2. Projections I 2

  3. Pinhole Camera • ingredients • box, film, hole punch • result • picture www.kodak.com www.pinhole.org www.debevec.org/Pinhole 3

  4. Pinhole Camera • theoretical perfect pinhole • light shining through tiny hole into dark space yields upside-down picture one ray of projection perfect pinhole film plane 4

  5. Pinhole Camera • non-zero sized hole • blur: rays hit multiple points on film plane multiple rays of projection actual pinhole film plane 5

  6. Real Cameras • pinhole camera has small aperture (lens opening) • minimize blur aperture • problem: hard to get enough light to expose the film • solution: lens • permits larger apertures • permits changing distance to film plane without actually moving it lens • cost: limited depth of field where image is depth in focus of field 6 http://en.wikipedia.org/wiki/Image:DOF-ShallowDepthofField.jpg

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

  8. General Projection • image plane need not be perpendicular to view plane eye point image plane eye point image plane 8

  9. Perspective Projection • our camera must model perspective 9

  10. Perspective Projection • our camera must model perspective 10

  11. Projective Transformations • planar geometric projections • planar: onto a plane • geometric: using straight lines • projections: 3D -> 2D • aka projective mappings • counterexamples? 11

  12. Projective Transformations • properties • lines mapped to lines and triangles to triangles • parallel lines do NOT remain parallel • e.g. rails vanishing at infinity • affine combinations are NOT preserved • e.g. center of a line does not map to center of projected line (perspective foreshortening) 12

  13. Perspective Projection • project all geometry • through common center of projection (eye point) • onto an image plane x y -z z z x x 13

  14. Perspective Projection projection plane center of projection (eye point) how tall should this bunny be? 14

  15. Basic Perspective Projection similar triangles P(x,y,z) y P(x ’ ,y ’ ,z ’ ) z z ’ =d z ' = d but • nonuniform foreshortening • not affine 15

  16. Perspective Projection • desired result for a point [x, y, z, 1] T projected onto the view plane: x ' x y ' y , = = d z d z x d x y d y ⋅ ⋅ x ' , y ' , z ' d = = = = = z z d z z d • what could a matrix look like to do this? 16

  17. Simple Perspective Projection Matrix x     z / d   y     z / d     d     17

  18. Simple Perspective Projection Matrix x x         y z / d is homogenized version of     z   y       z / d where w = z/d z / d       d     18

  19. Simple Perspective Projection Matrix x x         y z / d is homogenized version of     z   y       z / d where w = z/d z / d       d   x 1 0 0 0 x               y 0 1 0 0 y       = z 0 0 1 0 z             z / d 0 0 1 d 0 1       19

  20. Perspective Projection • expressible with 4x4 homogeneous matrix • use previously untouched bottom row • perspective projection is irreversible • many 3D points can be mapped to same (x, y, d) on the projection plane • no way to retrieve the unique z values 20

  21. Moving COP to Infinity • as COP moves away, lines approach parallel • when COP at infinity, orthographic view 21

  22. Orthographic Camera Projection • camera’s back plane x x     parallel to lens p     y y = • infinite focal length  p    z 0     • no perspective     p convergence x 1 0 0 0 x       p       • just throw away z values y 0 1 0 0 y p       = z 0 0 0 0 z       p       1 0 0 0 1 1       22

  23. Perspective to Orthographic • transformation of space • center of projection moves to infinity • view volume transformed • from frustum (truncated pyramid) to parallelepiped (box) x x Frustum Parallelepiped -z -z 23

  24. View Volumes • specifies field-of-view, used for clipping • restricts domain of z stored for visibility test orthographic view volume perspective view volume y=top y=top x=left x=left y y z x=right z VCS z=-near x VCS y=bottom z=-far z=-far x y=bottom x=right z=-near 24

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

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

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

  28. 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 THREE.PerspectiveCamera (fovy,aspect,near,far); z=-n z=-f 28

  29. Demos • frustum • http://webglfundamentals.org/webgl/frustum-diagram.html • http://www.ugrad.cs.ubc.ca/~cs314/Vsep2014/webGL/view- frustum.html • orthographic vs projection cameras • http://threejs.org/examples/#canvas_camera_orthographic2 • http://threejs.org/examples/#webgl_camera • https://www.script-tutorials.com/webgl-with-three-js-lesson-9/ 29

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