23
Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

Embed Size (px)

DESCRIPTION

3 Ray Tracing n Very ‘realist’ images but n Very slow – not real-time © Copyright LightWork Design. Model courtesy of Real-Time Visualisation

Citation preview

Page 1: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

1

Projection: Completing the Camera Model

©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

Page 2: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

2

Summary

Up to now we saw how to create images using ray tracing

COPView Window (showing pixels)

Page 3: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

3

Ray Tracing

Very ‘realist’ images but Very slow – not real-time

© Copyright LightWork Design. Model courtesy of Real-Time Visualisation

Page 4: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

4

Let’s accelerate by simplifying

Drop the global illumination part• i.e no recursion

Drop the lighting, just ambient Assume only polygons Instead of tracing rays to each pixel, just

trace them to the vertices and fill the space in-between

Instead of tracing the vertices, project them

Page 5: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

5

Projection

Although much faster, it creates several new problems:• Projecting the vertices• Clipping to the view volume• Visible surface determination• Rendering a polygon in 2D• Lighting• Shadows• Global illumination (Radiosity)

Page 6: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

6

Full camera specification

We have already seen:• VRP, VPN, VUV, COP, view plane window

Some more parameters:• Viewplane Distance• Type of projection

– Perspective – all rays converge to the COP– Parallel – parallel rays from points in the scene

(DOP)• Front and back clip planes• View plane window

Page 7: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

7

Perspective Projection

In order to get a natural looking image we need the perspective

For a simple arrangement it is easy to find the projection

COP

C

QP

AO

viewplane

Z

Y

Page 8: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

8

Canonical Frames

We use these as intermediate stages from which we know how to proceed

Canonical Frame for Perspective Projection: • Cop at (0,0,-1)• Viewplane coincident with

U-V plane• Viewplane window

bounded by –1 to +1

V

N

+1

-1

COP

O

View Volume

Page 9: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

9

Canonical Frame for Parallel Projection Orthographic parallel projection Direction of projection (DOP) is (0,0,-1) View volume bounded by –1 and +1 on U and V And by 0 and 1 on the N axis p’ = (x, y, 0) V

N

+1

-1

O

DOP

View Volume

Page 10: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

10

General Perspective to Canonical Parallel

V

NVRP=O

COP

VP

truncated View Volume

view window

V

N

+1

-1

COP

O

V

N

+1

-1

O

DOP

Page 11: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

11

General Perspective to Canonical Perspective

We will apply a set of transformation matrices (4 in total)

Each one ‘corrects’ a particular aspect of the projection

Then we put them all together to get one matrix

Page 12: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

12

Step 1: move the view plane to the UV plane (n = 0)

100010000100001

d

cop

Viewplane

d cop

V

N

Viewplane

V

N

Page 13: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

13

Step 2: translate the COP so that it lies on the N axis

Viewplane

V

N

Viewplane

V

N

cop

cop

10010000100001

yx cc

Page 14: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

14

Step 3: change the view volume into a regular pyramid

N

Viewplane

V

Ncop

V

cop D

D

10

01

0020

0002

DdypyDdx

pxdy

pydx

pxdy

Ddx

D WhereD = d – cz

dx = x2 – x1

dy = y2 – y1

px = x2 + x1

py = y2 + y1

Page 15: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

15

Step 4: Scale by 1/D

N

V

cop 1

1

N

V

cop D

D

10000100

0010

0001

D

D

D

Page 16: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

16

We multiply all 4 matrices together to get (Q):

11212

0111

0020

0002

Dd

dypy

Ddycc

dxpx

Ddxc

DDdypy

Ddxpx

dx

dx

yzx

Page 17: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

17

Canonical Viewing Space (Canonical Perspective)

We can now compute T = MQ, where • M maps WC to VC• Q maps VC to canonical VC

V

N

+1

-1

COP

O

Page 18: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

18

The composite matrix T = MQ

2u1D-n1(px)

Ddx2v1D-n1(py)

Ddyn1D 0

2u2D-n2(px)Ddx

2v2D-n2(py)Ddy

n2D 0

2u3D-n3(px)Ddx

2v3D-n3(py)Ddy

n3D 0

-2(qu)D-(qn)(px) + 2cxD-(px)cz

Ddx -2(qv)D-(qn)(py) + 2cyD-(py)cz

Ddy -(qn)+d

D 1

Page 19: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

19

Where the symbols mean:

D = d –cz xi = Ui - cx (i = 1,2) yi = Vi - cy (i = 1,2) dx = x2 - x1 = U2 - U1 dy = y2 - y1 = V2 - V1 px = x1 + x2 = U1 + U2 - 2 cx py = y1 + y2 = V1 + V2 - 2 cy

(q1 ,q2 ,q3 )is the VRP

qu = i=1

3qiui

qv = i=1

3qivi

qn = i=1

3qini

Page 20: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

20

Canonical Viewing Space to Canonical Parallel

Given a point in CVS Result in CPS is

1000110000100001

P

1,,, zyx

1,

1,

1,

11,,,

zz

zy

zxzzyx

Page 21: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

21

Towards Canonical Parallel

This step introduced the perspective projection

V

N

+1

-1

O

DOP

Dmin Dmax

Page 22: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

22

Front and Back Clipping Planes

Actually want Z between 0 and 1 Replace P with

1100

110000100001

minmax

maxmin

minmax

max

DDDD

DDD

P

Page 23: 1 Projection: Completing the Camera Model ©Yiorgos Chrysanthou 2001, Anthony Steed 2002-2003

23

Recap

Moving away from Ray-Tracing to projection

Finalised a camera specification and looked at mapping• General perspective• Canonical perspective• Canonical parallel

We’ll spend next couple of weeks tidying up problems!• Clipping, lighting, visibility, etc…