29
1 GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

Embed Size (px)

Citation preview

Page 1: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

1GR2-00

GR2Advanced Computer

GraphicsAGR

GR2Advanced Computer

GraphicsAGR

Lecture 3Viewing - Projections

Page 2: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

2GR2-00

ViewingViewing

Graphics display devices are 2D rectangular screens

Hence we need to understand how to transform our 3D world to a 2D surface

This involves:– selecting the observer position observer position (or

camera position)– selecting the view plane view plane (or camera film

plane)– selecting the type of projectionprojection

Page 3: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

3GR2-00

Perspective ProjectionsPerspective Projections

There are two types of projection: perspectiveperspective and parallelparallel

In a perspectiveperspective projection, object positions are projected onto the view plane along lines which converge at the observerP1

P2

P1’

P2’

view plane

camera

Page 4: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

4GR2-00

Parallel ProjectionParallel Projection

In a parallel projection, the observer position is at an infinite distance, so the projection lines are parallelP1

P2

view plane

Page 5: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

5GR2-00

Perspective and Parallel Projection

Perspective and Parallel Projection

Parallel projection preserves the relative proportions of objects, but does not give a realistic view

Perspective projection gives realistic views, but does not preserve proportions– Projections of distant objects are

smaller than projections of objects of the same size which are closer to the view plane

Page 6: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

6GR2-00

Perspective and Parallel Projection

Perspective and Parallel Projection

perspective parallel

Page 7: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

7GR2-00

PuzzlePuzzle

Page 8: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

8GR2-00

Another ExampleAnother Example

Page 9: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

9GR2-00

Viewing Coordinate System

Viewing Coordinate System

Viewing is easier if we work in a viewing co-ordinate systemviewing co-ordinate system, where the observer or camera position is on the z-axis, looking along the negative z-direction

xV

yV

zV

Camera is positioned at:(0 , 0, zC)

Page 10: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

10GR2-00

View PlaneView Plane

We assume the view plane is perpendicular to the viewing direction

The view planeis positioned at:(0, 0, zVP)

Let d = zC - zVP be thedistance between thecamera and the plane

xv

yv

zv

Page 11: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

11GR2-00

Perspective Projection Calculation

Perspective Projection Calculation

xv

yv

zv

zVview plane

Q

camerayV

zCzQ zVP

looking along x-axis

Page 12: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

12GR2-00

Perspective Projection Calculation

Perspective Projection Calculation

zVview plane

Q

camerayV

P

By similar triangles, yP / yQ = (zC - zVP) / (zC - zQ)and soyP = yQ * (zC - zVP) / (zC - zQ)oryP = yQ * d / (zC - zQ)

zCzQ zVP

xP likewise

Page 13: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

13GR2-00

Using Matrices and Homogeneous Coordinates

Using Matrices and Homogeneous Coordinates

We can express the perspective transformation in matrix form

Point Q in homogeneous coordinates is (xQ, yQ, zQ, 1)

We shall generate a point H in homogeneous coordinates (xH, yH, zH, wH), where wH is not 1

But the point (xH/wH, yH/wH, zH/wH, 1) is the same as H in homogeneous space

This gives us the point P in 3D space, ie xP = xH/wH, sim’ly for yP

Page 14: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

14GR2-00

Transformation Matrix for Perspective

Transformation Matrix for Perspective

1 0 0 0

0 1 0 0

0 0 -zVP/d zVPzC/d

0 0 -1/d zC/d

xQ

yQ

zQ

1

xH

yH

zH

wH

=

Then xP = xH / wH

iexP = xH / ( (zC - zQ) / d )iexP = xQ / ( (zC - zQ) / d )

yP likewise

Page 15: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

15GR2-00

ExercisesExercises

There are two special cases which you can now derive:– camera at the origin (zC = 0)

– view plane at the origin (zVP = 0) Follow through the operations

just described for these two cases, and write down the transformation matrices

Page 16: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

16GR2-00

Note for LaterNote for Later

The original z co-ordinate of points is retained – we need relative depth in the scene

in order to sort out which faces are visible to the camera

Page 17: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

17GR2-00

Vanishing PointsVanishing Points

When a 3D object is projected onto a view plane using perspective, parallel lines in object NOT parallel to the view plane converge to a vanishing vanishing pointpoint

view plane

vanishing point

one-pointperspectiveprojectionof cube

Page 18: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

18GR2-00

One- and Two-Point Perspective DrawingOne- and Two-Point Perspective Drawing

Page 19: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

19GR2-00

One-point PerspectiveOne-point Perspective

Said to be the firstpainting in perspective

This is:Trinity with the Virgin,St John and Donors,by Mastaccio in 1427

Page 20: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

20GR2-00

Two-point PerspectiveTwo-point Perspective

EdwardHopperLighthouseat Two Lights

-seewww.postershop.com

Page 21: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

21GR2-00

Parallel Projection - Two types

Parallel Projection - Two types

OrthographicOrthographic parallel projection has view plane perpendicular to direction of projection

ObliqueOblique parallel projection has view plane at an oblique angle to direction of projection

P1

P2

view plane

P1

P2

view plane

We shall only consider orthographic projectionorthographic projection

Page 22: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

22GR2-00

Parallel Projection Calculation

Parallel Projection Calculation

xv

yv

zv

zVview plane

Q

yV

zQ zVP

looking along x-axis

Page 23: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

23GR2-00

Parallel Projection Calculation

Parallel Projection Calculation

zVview plane

Q

yV

P

yP = yQ

and similarly xP = xQ

Page 24: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

24GR2-00

Parallel Projection Calculation

Parallel Projection Calculation

So this is much easier than perspective!– xP = xQ

– yP = yQ

– zP = zVP

The transformation matrix is simply1 0 0 0

0 1 0 00 0 zVP/zQ 00 0 0 1

Page 25: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

25GR2-00

View Volumes - View Window

View Volumes - View Window

Type of lens in a camera is one factor which determines how much of the view is captured– wide angle lens captures more than

regular lens Analogy in computer graphics is the

view windowview window, a rectangle in the view plane

xv

yv

zv

view window

Page 26: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

26GR2-00

View Volume - Front and Back Planes

View Volume - Front and Back Planes

We will also typically want to limit the view in the zV direction

We define two planes, each parallel to the view plane, to achieve this– front plane (or near plane)– back plane (or far plane)

front planeback plane

zV

Page 27: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

27GR2-00

View Frustum - Perspective Projection

View Frustum - Perspective Projection

view window

backplane

frontplane

camera

view frustum

zV

Page 28: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

28GR2-00

View Volume - Parallel Projection

View Volume - Parallel Projection

view window

backplane

frontplane

zV

view volume

Page 29: 1GR2-00 GR2 Advanced Computer Graphics AGR Lecture 3 Viewing - Projections

29GR2-00

View VolumeView Volume

The front and back planes act as important clipping planesclipping planes

Can be used to select part of a scene we want to view

Front plane Front plane important in perspective to remove near objects which will swamp picture