Computer Graphics WS07/08 – Camera Transformations
Computer Graphics
- Camera Transformations -
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
Computer Graphics WS07/08 – Camera Transformations
Computer Graphics WS07/08 – Camera Transformations
– Transformations
– Generating 2D image from 3D world
– Rasterization – Clipping
Computer Graphics WS07/08 – Camera Transformations
– Compute the transformation between points in 3D and pixels on the screen – Required for rasterization algorithms (OpenGL)
– Camera description – Pixel raster description
Computer Graphics WS07/08 – Camera Transformations
– Object space to world space
– World space to eye space
– Used by OpenGL
Computer Graphics WS07/08 – Camera Transformations
– Eye space to normalized device space – Parallel or perspective projection
– Normalized device space to window (raster) coordinates
Computer Graphics WS07/08 – Camera Transformations
– Object vertex positions
– Scene composition and object placement
– Illumination
– Camera position & direction specified in world coordinates – Illumination & shading can also be computed here
– Normalization to viewing frustum – Rasterization – Shading is executed here (but computed in world or camera space)
– 3D to 2D transformation: projection
Computer Graphics WS07/08 – Camera Transformations
Computer Graphics WS07/08 – Camera Transformations
– 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
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 PRP VUP
Computer Graphics WS07/08 – Camera Transformations
⇒Internal (intrinsic) camera parameters – Field of view (fov)
(focal length) or field of view (angle)
– Screen window
(relative to view plane normal)
– Near and far clipping planes
– Projection (perspective or orthographic) – Mapping to raster coordinates
View Frustum
Computer Graphics WS07/08 – Camera Transformations
– 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
x y d x y
Computer Graphics WS07/08 – Camera Transformations
Computer Graphics WS07/08 – Camera Transformations
Imaging optics
Computer Graphics WS07/08 – Camera Transformations
Lens Formula
g b f 1 1 1 + = f g g f b − =
Object center in focus
f r g r g f b − − − = ) ( ) ( '
Object front in focus f g b a r Δs
Computer Graphics WS07/08 – Camera Transformations
b a Δe b’
⎟ ⎠ ⎞ ⎜ ⎝ ⎛ − = Δ ' 1 b b a e
Circle of Confusion
e s Δ > Δ
Sharpness Criterion Depth of Field (DOF)
) ( ) ( f g s af f g s g r − Δ + − Δ < a r 1 ∝
The smaller the aperture, the larger the depth of field Δs DOF: Defined as length of interval (b') with CoC smaller than ∆s
Computer Graphics WS07/08 – Camera Transformations
f g r x
⇒ image sharp ⇒ infinite depth of field ⇒ image dark ⇒ diffraction effects
Computer Graphics WS07/08 – Camera Transformations
– Point in eye coordinates: P(xe ,ye ,ze) – Distance: center of projection to image plane: D – Image coordinates: (xs ,ys)
Computer Graphics WS07/08 – Camera Transformations
– 4x4 matrices – Concatenation of transformations by matrix multiplication
⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ → ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ∈ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ → ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎝ ⎛ ∋ W Z W Y W X W Z Y X z y x z y x R / / / and ), P(R 1
4 3
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 1 1 1 ) , , (
z y x z y x
d d d d d d T
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 , ,
22 21 20 12 11 10 02 01 00
r r r r r r r r r R γ β α
Computer Graphics WS07/08 – Camera Transformations
– 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
– Build orthonormal basis for the camera and form inverse
) ( 1 ´ ´ ´ ´ ´ ´ ´ ´ ´ PRP T Z Y X Z Y X Z Y X RT V
T z z z y y y x x x
− ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = =
x y z
x´ y´ VUP PRP
Computer Graphics WS07/08 – Camera Transformations
Oriented polygon edges V1, V2
– Dot product
> 0 : surface visible < 0 : surface not visible ⇒ Draw only visible surfaces ⇒ Applicable to closed
V
V
Computer Graphics WS07/08 – Camera Transformations
– Oblique viewing configuration
– Shear such that viewing direction is along Z-axis – Window center CW (in 3D view coordinates)
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − − = 1 1 1 1
z y z x
CW CW CW CW H
x CW
focal View from top right left Projection plane
Computer Graphics WS07/08 – Camera Transformations
– 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
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − − ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = = 1 1 2 2 1 / 1 / 1 / 1 bottom top focal left right focal far far far S S S
xy far
45°
far
far
Computer Graphics WS07/08 – Camera Transformations
– From canonical perspective viewing frustum (= cone at origin around -Z-axis) to regular box [-1 .. 1]2 x [0 .. 1]
– Lines through the origin are mapped to lines parallel to the Z-axis
45° (-1, -1) (-1, 1)
unknown
Computer Graphics WS07/08 – Camera Transformations
– No shear w.r.t. X and Y
– Mapping of two known points
T T T T
45°
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − − − = 1 1 1 1 1 1 n n n P
( )⎟
⎟ ⎠ ⎞ ⎜ ⎜ ⎝ ⎛ − − n z n + z = z' 1 Nonlinear transformation of z
Computer Graphics WS07/08 – Camera Transformations
– Scaling in Z with factor 0
– Scaling (by 1/2 in X and Y) and translation (by (1/2,1/2))
– Delivers normalized device coordinates
⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ = 1 2 1 2 1 2 1 2 1
parallel
P
Computer Graphics WS07/08 – Camera Transformations
– Adjustment of aspect ratio
– May be non-uniform → Distortion
– Positioning on the screen
Computer Graphics WS07/08 – Camera Transformations
– Bring near clipping plane into the origin
⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎟ ⎠ ⎞ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎜ ⎝ ⎛ − − − = = 1 1 1 1 1 1 2 2 near n f b t r l T S P
near xyz
Computer Graphics WS07/08 – Camera Transformations
– Perspective Projection – Orthographic Projection
– Different camera parameters as input – Different canonical viewing frustum – Different normalized coordinates
– ... Different transformation matrices
xy far persp parallel raster raster
near xyz parallel raster raster
Computer Graphics WS07/08 – Camera Transformations
– 3D: Normalized [-1 .. 1]3 oder [-1 .. 1]2 x [0 .. -1] – Clipping – Parallel projection
– Translation and scaling
– Where is the origin?
– Viewport-Transformation
– 2D: Units in pixels [0 .. xres-1, 0 .. yres-1]
Computer Graphics WS07/08 – Camera Transformations
– Modeling transformations AND viewing transformation – No explicit world coordinates
– simple specification
– glViewport(x, y, width, height)
Computer Graphics WS07/08 – Camera Transformations
– Linear in homogeneous coordinates
– Depth-of-field – Lens distortion, aberrations – Vignetting – Flare
Computer Graphics WS07/08 – Camera Transformations
– Scene composition
– Translation to camera position – Rotation to camera view orientation, optical axis along z axis – Different camera specifications
– Scaling to canonical frustum
– Lines through origin → parallel to z axis
– Omit depth
– Aspect ratio adjustment – Origin shift in image plane