CS 445 / 645Introduction to Computer Graphics
Lecture 10Lecture 10
Camera ModelsCamera Models
Lecture 10Lecture 10
Camera ModelsCamera Models
Where are we?
Rendering PipelineRendering PipelineRendering PipelineRendering Pipeline
ModelingTransformation
Illumination
ViewingTransformation
Clipping
Projection
Rasterization
Display
Pinhole Camera
IngredientsIngredients
• BoxBox
• FilmFilm
• Hole PunchHole Punch
ResultsResults
• Pictures!Pictures!
IngredientsIngredients
• BoxBox
• FilmFilm
• Hole PunchHole Punch
ResultsResults
• Pictures!Pictures!
www.kodak.com
www.pinhole.org
www.debevec.org
Pinhole Camera
Non-zero sized holeNon-zero sized holeNon-zero sized holeNon-zero sized hole
Film Plane
Pinhole
Multiple raysof projection
Pinhole Camera
Theoretical PinholeTheoretical PinholeTheoretical PinholeTheoretical Pinhole
Film Plane
Pinhole
One rayof projection
Pinhole Camera
Field of ViewField of ViewField of ViewField of View
Film Plane
Field of ViewPinhole
FocalLength
Pinhole Camera
Field of ViewField of ViewField of ViewField of View
Film Plane
Field of ViewPinhole
FocalLength
Moving the Film Plane
Varying distance to film planeVarying distance to film plane
What does this do?What does this do?
Varying distance to film planeVarying distance to film plane
What does this do?What does this do?
Film Plane
d1 Field of ViewPinhole
d2
Adding a Lens
• Pinhole camera has small aperture (lens opening)Pinhole camera has small aperture (lens opening)
– It’s hard to get enough light to expose the filmIt’s hard to get enough light to expose the film
• Lens permits larger aperturesLens permits larger apertures
• Lens permits changing distance to film plane without actually Lens permits changing distance to film plane without actually moving the film planemoving the film plane
• Pinhole camera has small aperture (lens opening)Pinhole camera has small aperture (lens opening)
– It’s hard to get enough light to expose the filmIt’s hard to get enough light to expose the film
• Lens permits larger aperturesLens permits larger apertures
• Lens permits changing distance to film plane without actually Lens permits changing distance to film plane without actually moving the film planemoving the film plane
Computer Graphic Camera
We use We use
• Center of Projection (COP)Center of Projection (COP)
• Projection PlaneProjection Plane
We use We use
• Center of Projection (COP)Center of Projection (COP)
• Projection PlaneProjection Plane
COP
ProjectionPlane
Moving the COP
Perspective vs. Orthographic ViewsPerspective vs. Orthographic ViewsPerspective vs. Orthographic ViewsPerspective vs. Orthographic Views
Perspective
When COP at infinity, Orthographic View
Multi-point Perspective
One-point PerpectiveOne-point Perpective
• One Vanishing PointOne Vanishing Point
Two-point PerspectiveTwo-point Perspective
• Two Vanishing PointsTwo Vanishing Points
One-point PerpectiveOne-point Perpective
• One Vanishing PointOne Vanishing Point
Two-point PerspectiveTwo-point Perspective
• Two Vanishing PointsTwo Vanishing Points
http://www.sanford-artedventures.com/create/tech_2pt_perspective.html
Perspective Projection
Our camera must model perspectiveOur camera must model perspectiveOur camera must model perspectiveOur camera must model perspective
Perspective Projection
How tall shouldthis bunny be?
COP
ProjectionPlane
Perspective ProjectionThe geometry of the situation is that of The geometry of the situation is that of similar trianglessimilar triangles. View . View
from above:from above:
What is x’ ?What is x’ ?
The geometry of the situation is that of The geometry of the situation is that of similar trianglessimilar triangles. View . View from above:from above:
What is x’ ?What is x’ ? d
P (x, y, z)X
Z
Viewplane
(0,0,0) x’ = ?
Perspective Projection
Desired result for a point Desired result for a point [[x, y, z, 1x, y, z, 1]]TT projected onto the projected onto the view plane:view plane:
What could a matrix look like to do this?What could a matrix look like to do this?
Desired result for a point Desired result for a point [[x, y, z, 1x, y, z, 1]]TT projected onto the projected onto the view plane:view plane:
What could a matrix look like to do this?What could a matrix look like to do this?
dzdz
y
z
ydy
dz
x
z
xdx
z
y
d
y
z
x
d
x
,','
',
'
A Perspective Projection Matrix
Answer:Answer:Answer:Answer:
0100
0100
0010
0001
d
M eperspectiv
A Perspective Projection Matrix
Example:Example:
Or, in 3-D coordinates:Or, in 3-D coordinates:
Example:Example:
Or, in 3-D coordinates:Or, in 3-D coordinates:
10100
0100
0010
0001
z
y
x
ddz
z
y
x
d
dz
y
dz
x,,
Homogeneous Coordinates
The role of w in (x, y, z, w)The role of w in (x, y, z, w)• All 3-D points are described with a four vectorAll 3-D points are described with a four vector
• All 3-D tranformations are represented with 4x4 matrixAll 3-D tranformations are represented with 4x4 matrix
• When projected to screen coordinates (rasterization)When projected to screen coordinates (rasterization)
– x, y, and z are divided by point’s w valuex, y, and z are divided by point’s w value
• This allows us to perform perspective foreshortening while This allows us to perform perspective foreshortening while preserving the reversibility of the mappingpreserving the reversibility of the mapping
– We can retrieve x, y, and z by multiplying by wWe can retrieve x, y, and z by multiplying by w
The role of w in (x, y, z, w)The role of w in (x, y, z, w)• All 3-D points are described with a four vectorAll 3-D points are described with a four vector
• All 3-D tranformations are represented with 4x4 matrixAll 3-D tranformations are represented with 4x4 matrix
• When projected to screen coordinates (rasterization)When projected to screen coordinates (rasterization)
– x, y, and z are divided by point’s w valuex, y, and z are divided by point’s w value
• This allows us to perform perspective foreshortening while This allows us to perform perspective foreshortening while preserving the reversibility of the mappingpreserving the reversibility of the mapping
– We can retrieve x, y, and z by multiplying by wWe can retrieve x, y, and z by multiplying by w
Perspective Projection
• Perspective projection matrix is not affinePerspective projection matrix is not affine
– Parallel lines not preservedParallel lines not preserved
• Perspective projection is irreversiblePerspective projection is irreversible
– Many 3-D points can be mapped to same (x, y, d) on the Many 3-D points can be mapped to same (x, y, d) on the projection planeprojection plane
– No way to retrieve the unique z valuesNo way to retrieve the unique z values
• Perspective projection matrix is not affinePerspective projection matrix is not affine
– Parallel lines not preservedParallel lines not preserved
• Perspective projection is irreversiblePerspective projection is irreversible
– Many 3-D points can be mapped to same (x, y, d) on the Many 3-D points can be mapped to same (x, y, d) on the projection planeprojection plane
– No way to retrieve the unique z valuesNo way to retrieve the unique z values
Orthographic Camera Projection
• Camera’s back plane parallel to Camera’s back plane parallel to lenslens
• Infinite focal lengthInfinite focal length
• No perspective convergenceNo perspective convergence
• Camera’s back plane parallel to Camera’s back plane parallel to lenslens
• Infinite focal lengthInfinite focal length
• No perspective convergenceNo perspective convergence
0
y
x
z
y
x
p
p
p
11000
0000
0010
0001
1
z
y
x
z
y
x
p
p
p
Pipeline
Modelview
PerspectiveDivision
Projection
Clip
Rasterize
OpenGL Pipeline
• Projection matrix is stored in GL_PROJECTION stackProjection matrix is stored in GL_PROJECTION stack
– This controls ‘type’ of cameraThis controls ‘type’ of camera
– All vertices are multiplied by this matrixAll vertices are multiplied by this matrix
• GL_MODELVIEW controls camera locationGL_MODELVIEW controls camera location
– All vertices are multiplied by this matrixAll vertices are multiplied by this matrix
• Projection matrix is stored in GL_PROJECTION stackProjection matrix is stored in GL_PROJECTION stack
– This controls ‘type’ of cameraThis controls ‘type’ of camera
– All vertices are multiplied by this matrixAll vertices are multiplied by this matrix
• GL_MODELVIEW controls camera locationGL_MODELVIEW controls camera location
– All vertices are multiplied by this matrixAll vertices are multiplied by this matrix
Making GL_PROJECTION
glFrustum – for perspective projectionsglFrustum – for perspective projections
• xminxmin
• xmaxxmax
• yminymin
• ymaxymax
• near near
• farfar
glFrustum – for perspective projectionsglFrustum – for perspective projections
• xminxmin
• xmaxxmax
• yminymin
• ymaxymax
• near near
• farfar
• Camera looks along –zCamera looks along –z
• min/max need not be symmetric min/max need not be symmetric about any axisabout any axis
• near and far planes are parallel to near and far planes are parallel to plane z=0plane z=0
• Camera looks along –zCamera looks along –z
• min/max need not be symmetric min/max need not be symmetric about any axisabout any axis
• near and far planes are parallel to near and far planes are parallel to plane z=0plane z=0
Making GL_PROJECTION
gluPerspective – for perspective projectionsgluPerspective – for perspective projections
• fovyfovy
• aspectaspect
• nearnear
• farfar
gluPerspective – for perspective projectionsgluPerspective – for perspective projections
• fovyfovy
• aspectaspect
• nearnear
• farfar
• fovy is the angle between top and fovy is the angle between top and bottom of viewing volumebottom of viewing volume
• aspect is ratio of width over heightaspect is ratio of width over height
• This volume is symmetricalThis volume is symmetrical
• View plane is parallel to cameraView plane is parallel to camera
• fovy is the angle between top and fovy is the angle between top and bottom of viewing volumebottom of viewing volume
• aspect is ratio of width over heightaspect is ratio of width over height
• This volume is symmetricalThis volume is symmetrical
• View plane is parallel to cameraView plane is parallel to camera
Making GL_PROJECTION
glOrtho – for orthographic projectionsglOrtho – for orthographic projections
• leftleft
• rightright
• bottombottom
• toptop
• nearnear
• farfar
glOrtho – for orthographic projectionsglOrtho – for orthographic projections
• leftleft
• rightright
• bottombottom
• toptop
• nearnear
• farfar
• (left, bottom) and (right, top) (left, bottom) and (right, top) define dimensions of projection define dimensions of projection planeplane
• near and far used to clipnear and far used to clip
• (left, bottom) and (right, top) (left, bottom) and (right, top) define dimensions of projection define dimensions of projection planeplane
• near and far used to clipnear and far used to clip
Making GL_PROJECTION
It’s like any other matrixIt’s like any other matrix
• These OpenGL commands just build a matrix for youThese OpenGL commands just build a matrix for you
• You could build the matrix yourselfYou could build the matrix yourself
• You can multiply the GL_PROJECTION matrix by any affine You can multiply the GL_PROJECTION matrix by any affine transformation you wishtransformation you wish
– Not typically neededNot typically needed
It’s like any other matrixIt’s like any other matrix
• These OpenGL commands just build a matrix for youThese OpenGL commands just build a matrix for you
• You could build the matrix yourselfYou could build the matrix yourself
• You can multiply the GL_PROJECTION matrix by any affine You can multiply the GL_PROJECTION matrix by any affine transformation you wishtransformation you wish
– Not typically neededNot typically needed
Top Related