Download - CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Transcript
Page 1: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

CS 445 / 645Introduction to Computer Graphics

Lecture 10Lecture 10

Camera ModelsCamera Models

Lecture 10Lecture 10

Camera ModelsCamera Models

Page 2: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Where are we?

Rendering PipelineRendering PipelineRendering PipelineRendering Pipeline

ModelingTransformation

Illumination

ViewingTransformation

Clipping

Projection

Rasterization

Display

Page 3: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 4: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Pinhole Camera

Non-zero sized holeNon-zero sized holeNon-zero sized holeNon-zero sized hole

Film Plane

Pinhole

Multiple raysof projection

Page 5: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Pinhole Camera

Theoretical PinholeTheoretical PinholeTheoretical PinholeTheoretical Pinhole

Film Plane

Pinhole

One rayof projection

Page 6: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Pinhole Camera

Field of ViewField of ViewField of ViewField of View

Film Plane

Field of ViewPinhole

FocalLength

Page 7: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Pinhole Camera

Field of ViewField of ViewField of ViewField of View

Film Plane

Field of ViewPinhole

FocalLength

Page 8: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 9: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 10: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 11: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Moving the COP

Perspective vs. Orthographic ViewsPerspective vs. Orthographic ViewsPerspective vs. Orthographic ViewsPerspective vs. Orthographic Views

Perspective

When COP at infinity, Orthographic View

Page 12: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 13: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Perspective Projection

Our camera must model perspectiveOur camera must model perspectiveOur camera must model perspectiveOur camera must model perspective

Page 14: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Perspective Projection

How tall shouldthis bunny be?

COP

ProjectionPlane

Page 15: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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’ = ?

Page 16: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

,','

',

'

Page 17: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

A Perspective Projection Matrix

Answer:Answer:Answer:Answer:

0100

0100

0010

0001

d

M eperspectiv

Page 18: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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,,

Page 19: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 20: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 21: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 22: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

Pipeline

Modelview

PerspectiveDivision

Projection

Clip

Rasterize

Page 23: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 24: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 25: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 26: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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

Page 27: CS 445 / 645 Introduction to Computer Graphics Lecture 10 Camera Models Lecture 10 Camera Models.

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