Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

30
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura

Transcript of Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Page 1: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

1

Computer Graphics

Lecture 4

View Projection

Taku Komura

Page 2: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Measuring the BRDF

• Measured using a device called gonioreflectometer– Casting light from various directions to the object,

and capturing the light reflected back

Page 3: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Problems with Measured BRDF

• Includes a lot of error

• Huge amount of time to capture

• The data size is enormous – 18 hours acquisition time, 30GB raw data according

to [Ngan et al. EGSR ’05]

-> Fitting the acquired data into analytical models

Page 4: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Analytical models

• Empirical models

– Gouraud, Phong models or more complex models

• Microfacet models

– Assuming the surface is composed of a large number of micro mirrors

– Each reflect light back to the specular direction

Page 5: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Microfacet Theory

• [Torrance & Sparrow 1967]– Surface modeled by tiny mirrors – Value of BRDF at

• # of mirrors oriented halfway between and where is the incoming direction, is the out

going directionAlso considering the statistics of the shadowing/masking

• Modulated by Fresnel, shadowing/masking

[Shirley 97]

Page 6: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Examples : Satin

Page 7: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Examples : velvet

Page 8: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

8

Implementation of viewing.

• Transform into camera coordinates.

• Perform projection into view volume or screen coordinates.

• Clip geometry outside the view volume.

• Remove hidden surfaces (next week)

Page 9: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Transformations

lwlcwproj vMMMv

11/04/23

Local to world matrix

World to cameramatrix

Projection matrix

Local coordinates

Screen coordinates

Page 10: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

View Transformation (from lecture 2)

02/10/09Lecture 4 10

We want to know the positions in the camera coordinate system

vw = Mc→w vc

vc = Mc → w vw

= Mw→c vw

-1

Point in theworld coordinate

Point in thecamera coordinate

Camera-to-world transformation

Page 11: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

11

View ProjectionWe want to create a picture of the scene viewed from the camera

Two sorts of projection

Parallel projection

Perspective projection

Page 12: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

12

Mathematics of Viewing

• We need to generate the transformation matrices for perspective and parallel projections.

• They should be 4x4 matrices to allow general concatenation.

• And there’s still 3D clipping and more viewing stuff to look at.

Page 13: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

13

Parallel projections (Orthographic projection)

• Specified by a direction of projection, rather than a point.

• Objects of same size appear at the same size after the projection

Page 14: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

14

Parallel projection.

1000

0000

0010

0001

orthM

Orthographic Projection onto a plane at z = 0.

xp = x , yp = y , z = 0.

Page 15: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

15

Perspective Projection• Specified by a center of projection and the focal

distance (distance from the eye to the projection plane)

Objects far away appear smaller, closer objects appear bigger

Page 16: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

Projection Matrix• Here we will follow the projection transform

method used in OpenGL • The camera facing the –z direction

Page 17: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

17

Perspective projection – simplest case.

d

y

z

ProjectionPlane.

P(x,y,z)

Pp(xp,yp,-d)

Centre of projection at the origin,Projection plane at z=-d.d: focal distance

x

Page 18: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

18

Perspective projection – simplest case.

d

x

y

z

P(x,y,z)

Pp(xp,yp,-d)

z

P(x,y,z)

d

z

P(x,y,z)

d

y

x

xp

yp

dz

y

z

ydy

dz

x

z

xdx

z

y

d

y

z

x

d

x

pp

pp

/ ;

/

;

:trianglessimilarFrom

Page 19: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

19

Perspective projection.

01/d-00

0100

0010

0001

:matrix 4x4 a as drepresente becan ation transformThe

perM

TTT

pp dzzyxdz

ydz

xddyx

1..1

Page 20: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

20

Perspective projection.

TT

perp

Tp

dzzyxWZYX

z

y

x

PMP

WZYXP

/

101/d-00

0100

0010

0001

point projected general theRepresent

Page 21: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

21

Perspective projection.

ddz

y

dz

x

W

Z

W

Y

W

X

dzzyxP Tp

,/

,/

,,

: 3D back to come W toDropping

/Trouble with this formulation :

Centre of projection fixed at the origin.

Page 22: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

22

Alternative formulation.

z

P(x,y,z)

d

x

xp

z

P(x,y,z)

d

y

yp

Projection plane at z = 0Centre of projection at z = d

1)/( ;

1)/(

dby Multiply

;

:trianglessimilarFrom

dz

y

dz

ydy

dz

x

dz

xdx

dz

y

d

y

dz

x

d

x

pp

pp

Page 23: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

23

Alternative formulation.

11/d-00

0000

0010

0001

perM

z

P(x,y,z)

d

x

xp

z

P(x,y,z)

d

y

yp

Projection plane at z = 0,Centre of projection at z = d

Now we can allow d

Page 24: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

24

Problem

• After projection, the depth information is lost

• We need to preserve the depth information for hidden surface remove during rasterization

Page 25: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

25

3D View Volume

• The volume in which the visible objects exist• For orthographic projection, view volume is a

box.• For perspective projection, view volume is a

frustum.• The surfaces outside the view volume must be

clipped Far clipping plane.

Near clipping plane

left

right

Need to calculate intersectionWith 6 planes.

Page 26: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

26

Canonical View Volume• We can transform the frustum view volume into a

normalized canonical view volume using the idea of perspective transformation

• Much easier to clip surfaces and apply hidden surface removal

Page 27: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

27

Transforming the View Frustum• Let us define parameters (l,r,b,t,n,f) that

determines the shape of the frustum

• The view frustum starts at z=-n and ends at z=-f, with 0<n<f

• The rectangle at z=-n has the minimum corner at (l,b,-n) and the maximum corner at (r,t,-n)

Page 28: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

28

Transforming View Frustum into a Canonical view-volume

• The perspective canonical view-volume can be transformed to the parallel canonical view-volume with the following matrix:

0100

200

02

0

002

)0](,[

nf

fn

nf

nfbt

bt

bt

nlr

lr

lr

n

P

thenfnfnzIf

p

Page 29: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

29

Final step.

• Divide by W to get the 3-D coordinates– Where the perspective projection actually gets done

• Now we have a ‘canonical view volume’.– Don’t flatten z due to hidden surface calculations.

• 3D Clipping– The Canonical view volume is defined by:

-1x 1, -1 y 1 , -1 z 1– Simply need to check the (x,y,z) coordinates and see if they are

within the canonical view volume

Page 30: Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 4 View Projection Taku Komura.

Computer Graphics Inf4/MSc

30

Reading for View Transformation

• Foley et al. Chapter 6 – all of it,– Particularly section 6.5

• Introductory text, Chapter 6 – all of it,– Particularly section 6.6

• Akenine-Moller, Real-time Rendering Chapter 3.5