computer graphics
play

Computer Graphics - Camera Transformations - Hendrik Lensch - PowerPoint PPT Presentation

Computer Graphics - Camera Transformations - Hendrik Lensch Computer Graphics WS07/08 Camera Transformations Overview Last lecture: Transformations Today: Generating 2D image from 3D world Coordinate Spaces Camera


  1. Computer Graphics - Camera Transformations - Hendrik Lensch Computer Graphics WS07/08 – Camera Transformations

  2. Overview • Last lecture: – Transformations • Today: – Generating 2D image from 3D world • Coordinate Spaces • Camera Specification • Perspective transformation • Normalized screen coordinates • Next lecture: – Rasterization – Clipping Computer Graphics WS07/08 – Camera Transformations

  3. Camera Transformations • Goal – Compute the transformation between points in 3D and pixels on the screen – Required for rasterization algorithms (OpenGL) • They project all primitives from 3D to 2D • Rasterization happens in 2D (actually 2-1/2D) • Given – Camera description – Pixel raster description Computer Graphics WS07/08 – Camera Transformations

  4. Camera Transformations • Model transformation – Object space to world space • View transformation – World space to eye space • Combination: Modelview transformation – Used by OpenGL Computer Graphics WS07/08 – Camera Transformations

  5. Camera Transformation • Projection transformation – Eye space to normalized device space – Parallel or perspective projection • Viewport transformation – Normalized device space to window (raster) coordinates Computer Graphics WS07/08 – Camera Transformations

  6. Coordinate Transformations • Local (object) coordinate system (3D) – Object vertex positions • World (global) coordinate system (3D) – Scene composition and object placement • Rigid objects: constant translation, rotation per object • Animated objects: time-varying transformation in world-space – Illumination • Camera/View/Eye coordinate system (3D) – Camera position & direction specified in world coordinates – Illumination & shading can also be computed here • Normalized device coordinate system (2-1/2D) – Normalization to viewing frustum – Rasterization – Shading is executed here (but computed in world or camera space) • Window/Screen (raster) coordinate system (2D) – 3D to 2D transformation: projection Computer Graphics WS07/08 – Camera Transformations

  7. Per-Vertex Transformations Computer Graphics WS07/08 – Camera Transformations

  8. Viewing Transformation • Camera position and orientation in world coordinates – Center of projection, projection reference point (PRP) – Optical axis, view plane normal (VPN) – View up vector (VUP) (not necessarily perpendicular to VPN) ⇒ External (extrinsic) camera parameters • Transformation 1.) Translation of all vertex positions by projection center 2.) Rotation of all vertex position by camera orientation convention: view direction along negative Z axis VUP PRP -VPN Computer Graphics WS07/08 – Camera Transformations

  9. Perspective Transformation • Camera coordinates to screen coordinate system ⇒ Internal (intrinsic) camera parameters – Field of view (fov) • Distance of image plane from origin (focal length) or field of view (angle) – Screen window • Window size on image plane • Also determines viewing direction (relative to view plane normal) – Near and far clipping planes View Frustum • Avoids singularity at origin (near clipping plane) • Restriction of dynamic depth range (near&far clipping plane) • Together define „View Frustum“ – Projection (perspective or orthographic) – Mapping to raster coordinates • Resolution • Adjustment of aspect ratio Computer Graphics WS07/08 – Camera Transformations

  10. Camera Parameters: Simple • Camera definition in ray tracer – o : center of projection, point of view – f : vector to center of view, optical axis – x , y : span of half viewing window – xres , yres : image resolution – x , y : screen coordinates y x d x y f o Computer Graphics WS07/08 – Camera Transformations

  11. Camera Parameters: RMan Computer Graphics WS07/08 – Camera Transformations

  12. Camera Model Imaging optics Computer Graphics WS07/08 – Camera Transformations

  13. Lens Camera b r Δ s a f g 1 1 1 = + Lens Formula f b g f g = Object center in focus b − g f − f ( g r ) = Object front in focus b ' − − ( g r ) f Computer Graphics WS07/08 – Camera Transformations

  14. Lens Camera: Depth of Field Δ s a b ⎛ − ⎞ b Δ = ⎜ ⎟ Circle of Confusion Δ e e a 1 ⎝ ⎠ b ' b’ Δ > Δ Sharpness Criterion s e Δ − g s ( g f ) 1 < ∝ Depth of Field (DOF) ⇒ r r + Δ − af s ( g f ) a DOF: Defined as length of interval (b') with CoC smaller than ∆ s The smaller the aperture, the larger the depth of field Computer Graphics WS07/08 – Camera Transformations

  15. Pinhole Camera Model f r x g Pinhole small r = x f r ⇒ image sharp = ⇒ x g f g ⇒ infinite depth of field ⇒ image dark ⇒ diffraction effects Computer Graphics WS07/08 – Camera Transformations

  16. Perspective Transformation • 3D to 2D projection – Point in eye coordinates: P( x e ,y e ,z e ) – Distance: center of projection to image plane: D – Image coordinates: ( x s ,y s ) Computer Graphics WS07/08 – Camera Transformations

  17. Transformations • Homogeneous coordinates (reminder :-) ⎛ ⎞ ⎛ ⎞ x X ⎜ ⎟ ⎜ ⎟ ⎛ ⎞ ⎛ ⎞ x X / W ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ y Y ∋ → ∈ → 3 ⎜ ⎟ 4 ⎜ ⎟ R y P(R ), and Y / W ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ z Z ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ ⎝ ⎠ z Z / W ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ ⎝ ⎠ 1 W • Transformations – 4x4 matrices – Concatenation of transformations by matrix multiplication ⎛ ⎞ ⎛ ⎞ 1 0 0 d r r r 0 ⎜ ⎟ ⎜ ⎟ x 00 01 02 ⎜ ⎟ ⎜ ⎟ 0 1 0 d r r r 0 ( ) = α β γ = y 10 11 12 T ( d , d , d ) ⎜ ⎟ R , , ⎜ ⎟ x y z 0 0 1 d r r r 0 ⎜ ⎟ ⎜ ⎟ z 20 21 22 ⎜ ⎟ ⎜ ⎟ ⎝ ⎠ 0 0 0 1 ⎝ ⎠ 0 0 0 1 Computer Graphics WS07/08 – Camera Transformations

  18. Viewing Transformation • Goal: – Camera: at origin, view along –Z, Y upwards (right hand) – Translation of PRP to the origin – Rotation of VPN to Z-axis – Rotation of projection of VUP to Y-axis • Rotations – Build orthonormal basis for the camera and form inverse • Z ´ = VPN, X ´ = normalize(VUP x VPN), Y ´ = Z ´ × X ´ • Viewing transformation y ´ VUP T ⎛ ⎞ X ´ Y ´ Z ´ 0 -z ´ = -VPN ⎜ ⎟ x x x x ´ ⎜ ⎟ X ´ Y ´ Z ´ 0 PRP = = − y y y V RT T ( PRP ) ⎜ ⎟ z X ´ Y ´ Z ´ 0 ⎜ ⎟ z z z ⎜ ⎟ y ⎝ ⎠ 0 0 0 1 x Computer Graphics WS07/08 – Camera Transformations

  19. Backface Culling • Polygon normal in world coordinates N P = V 1 x V 2 Oriented polygon edges V 1 , V 2 • Line-of-sight vector V – Dot product N P • V > 0 : surface visible < 0 : surface not visible V V ⇒ Draw only visible surfaces ⇒ Applicable to closed objects only Computer Graphics WS07/08 – Camera Transformations

  20. Sheared Perspective Transformation • Step 1: Optical axis may not go through screen center – Oblique viewing configuration ⇒ Shear (Scherung) – Shear such that viewing direction is along Z-axis – Window center CW (in 3D view coordinates) • CW = ( (right+left)/2, (top+bottom)/2, -focal) T • Shear matrix Projection plane ⎛ ⎞ CW − ⎜ ⎟ x 1 0 0 focal ⎜ ⎟ CW z -z ⎜ ⎟ left CW = − y ⎜ ⎟ 0 1 0 H CW CW ⎜ ⎟ z x ⎜ ⎟ 0 0 1 0 ⎜ ⎟ right ⎝ ⎠ 0 0 0 1 View from top Computer Graphics WS07/08 – Camera Transformations

  21. Normalizing • Step 2: Scaling to canonical viewing frustum – Scale in X and Y such that screen window boundaries open at 45 degree angles – Scale in Z such that far clipping plane is at Z= -1 45° -z -z -near -near -focal -focal -far far far -1 • Scaling matrix ⎛ ⎞ 2 focal ⎜ ⎟ 0 0 0 ⎛ ⎞ 1 / far 0 0 0 − ⎜ ⎟ ⎜ ⎟ right left ⎜ ⎟ ⎜ ⎟ 0 1 / far 0 0 2 focal = = 0 0 0 S S S ⎜ ⎟ ⎜ ⎟ − far xy top bottom 0 0 1 / far 0 ⎜ ⎟ ⎜ ⎟ ⎜ ⎟ 0 0 1 0 ⎜ ⎟ ⎝ ⎠ 0 0 0 1 ⎜ ⎟ ⎝ ⎠ 0 0 0 1 Computer Graphics WS07/08 – Camera Transformations

  22. Perspective Transformation • Step 3: Perspective Transformation – From canonical perspective viewing frustum (= cone at origin around -Z-axis) to regular box [-1 .. 1] 2 x [0 .. 1] • Mapping of X and Y – Lines through the origin are mapped to lines parallel to the Z-axis • x ´ = x/-z und y ´ = y/-z • Perspective Transformation (-1, 1) ⎛ ⎞ 45° 1 0 0 0 ⎜ ⎟ ⎜ ⎟ 0 1 0 0 = P ⎜ ⎟ A B C D -z ⎜ ⎟ unknown ⎜ ⎟ − ⎝ ⎠ (-1, -1) 0 0 1 0 • Perspective Projection = Perspective Transformation + Parallel Projection Computer Graphics WS07/08 – Camera Transformations

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