synthesis 4b - optics.pptcs236373/tutorials/optics.pdf · optics m. ben-chen, a. vaxman computer...

13
Image Synthesis Exercise class 4a Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 1 Rendering Rendering Reflection and Transmission Reflection and Transmission Camera Parameters Camera Parameters 1 Spring 2009 Previously… How to generate the rays? Place the camera Sh t i l Shoot one or more rays per pixel 2 Spring 2009

Upload: others

Post on 11-Aug-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 1

RenderingRendering

Reflection and TransmissionReflection and TransmissionCamera ParametersCamera Parameters

1Spring 2009

Previously…

How to generate the rays?Place the cameraSh t i lShoot one or more rays per pixel

2Spring 2009

Page 2: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 2

Camera ParametersP - camera location

- camera directiona - field of view angle (in the X axis)da field of view angle (in the X axis)

Pa

d0u

0

0 0

ˆr d y

u r d

= ×

= ×

3

Assumption: The “up” vector of the camera has a positive Y-value

P0r

Spring 2009

Rolling the Cameraα - roll angle

P

α d

r

u

4

P

0 0

0 0

ˆ ˆ ˆcos sinˆ ˆ ˆcos sinr r uu u r

α αα α

= −= +

r

Spring 2009

Page 3: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 3

Default Camera Location

For the projectDirection: (0,0,-1)L tiLocation:

Towards center of bounding boxFar enough, so all the scene is in view for a = 45

yx

Bounding box

5

xz

u

rd

Center

Spring 2009

Shooting the Rays

One ray through center of each pixel

6

More than one ray per pixel?

Spring 2009

Page 4: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 4

Coefficients:

Simple Illumination Model

N

Light source i

Coefficients:ka – ambientkd – diffuseks – specularn – specular highlight

Ii – intensity of source i

iLV

iR

N

Intersection point

7

∑ ∑ ⋅+⋅+=i i

niisiidaa VRIkLNIkIkI )ˆˆ()ˆˆ(

Spring 2009

Extended Illumination Model

LR

N

Light source i

New terms:Shadow

object

iLV

iRShadowIi – intensity of source i, or 0 if source not visible

Reflectionkr – reflection coefficientIr – reflected ray intensity

Transmission

object

objecttI

rI

8ttrr

i i

niisiidaa

IkIk

VRIkLNIkIkI

++

⋅+⋅+= ∑ ∑ )ˆˆ()ˆˆ(

kt – transmission coefficientIt – transmitted ray intensity

Spring 2009

Page 5: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 5

Implementation

ShadowFire shadow rays (for each light source)

O i i i t ti i t Light source iOrigin: intersection pointDirection: intersection point Light source i

ReflectionFire a reflected ray

Origin: intersection pointDirection: reflection vector

Transmission

Light source i

Original Ray Reflected Ray

9

TransmissionFire a transmitted ray

Origin: intersection pointDirection: transmission vector

Transmitted Ray

Spring 2009

The Reflection Vector

NI R

Unit vectorsN – normal

i id tiθ rθ

I – incidentR – reflected

I, R and N are coplanar

ˆ ˆ ˆ ˆi r I N R Nθ θ= ⇒ ⋅ = ⋅

10

i r

Spring 2009

Page 6: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 6

Reflection Vector

ˆˆˆNI R

N ′

INNIINR

NIR

NNIN

ˆˆ)ˆˆ(2ˆ2ˆ

2ˆˆ

ˆ)ˆˆ(

−⋅=−′=

′=+

⋅=′

11

ˆ ˆ ˆ ˆ ˆ2( )R I N N I= ⋅ −

Spring 2009

Reflection Vector

12Spring 2009

Page 7: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 7

Transmission Vectorˆ ˆ ˆsin cosi iI M Nθ θ= − +

NI

θ

ˆ ˆ ˆsin cos

ˆ ˆcosˆ ˆi

t t

i

T M N

N I

θ θ

θθ θ

= −

ˆ ˆcosˆsin

i

i

N IM θθ

−=

M− M

TN−

13

cossin cossinˆ ˆ(cos ) ˆcos

it t

i

i it

t

N IT N

N I N

θθ θθ

η θ θη

= − =

−−

sinsin

i t

t i

η θη θ

=

Snell’s law:

Spring 2009

Transmission Vector

ˆ ˆ ˆcos cosi ii tT I Nη η θ θ

η η⎛ ⎞

= − + −⎜ ⎟⎝ ⎠

NI

θt tη η⎝ ⎠

ˆ ˆcos i I Nθ = ⋅

M− M

TN−

( )

2 2

22 2

2

sin sin sin cos 1

cos 1 1 cos

i i t t

it i

t

η θ η θ θ θ

ηθ θη

= + =

= − −

14

( )( )2 2

2ˆ ˆ ˆ ˆ ˆ ˆ ˆ1 1i i i

t t t

T I I N I N Nη η ηη η η

⎛ ⎞= − + ⋅ − − − ⋅⎜ ⎟⎜ ⎟

⎝ ⎠

Spring 2009

Page 8: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 8

Transmission Vector

15Spring 2009

And in Real Life…

16Spring 2009

Page 9: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 9

Detection:

( )( )2 2

2ˆ ˆ1 1 0i I Nη

− − ⋅ <

Total Internal Reflection

Conditionsηi > ηt

θi > θc (critical angle)

All light goes to reflection

( )( )2tη

17

All light goes to reflection

Spring 2009

Some More Real Life

18Spring 2009

Page 10: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 10

Modeling a Rainbow

19

Picture from “How stuff works” web site

Spring 2009

Modeling a Rainbow

20

Picture from “How stuff works” web siteRainbow Applet

Spring 2009

Page 11: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 11

Reminder - Extended Illumination Model

N

Light source iWe know

I reflected ray

iLV

iR

NIr – reflected ray intensityIt – transmitted ray intensity

Don’t know (yet…)kr – reflection coefficient

object

objecttI

rI

object

21ttrr

i i

niisiidaa

IkIk

VRIkLNIkIkI

++

⋅+⋅+= ∑ ∑ )ˆˆ()ˆˆ(

kt – transmission coefficient

object

Spring 2009

Finding the Coefficients

Fresnel’s Law: if both materials are dielectrics2 2sin ( ) cos ( )1 θ θ θ θ⎡ ⎤− +

(In vacuum)And then, from the energy conservation:

2 2

sin ( ) cos ( )1( ) 12 sin ( ) cos ( )

i t i tr i

i t i t

k θ θ θ θθθ θ θ θ

⎡ ⎤+= +⎢ ⎥+ −⎣ ⎦

1t rk k= −

( )( )

( )( )

2 2

2 2

1(0)

1i t t

ri t t

kη η η

η η η

− −= =

+ +

i tθ θ>

22

Attenuation due to opacity:, ,

Where is the transparency

t tk ck′ =

]1,0[∈c

(1 )d dk c k′ = − (1 )a ak c k′ = −

Spring 2009

Page 12: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 12

Finding the Coefficients - Optimization

kr can be approximated by Schlick approximation

( )( )5

( ) ( )

(0) 1 (0) 1 cos( )r i r i

r r i

k k

k k

θ θ

θ

≈ =

+ − −

23Spring 2009

VRML Parameters - VR MaterialVRSFColor diffuseColor;VRSFFloat ambientIntensity;VRSFColor specularColor;VRSFColor specularColor;VRSFColor emissiveColor;VRSFFloat shininess;VRSFFloat transparency;

ka = ambientIntensity * diffuseColorkd = diffuseColor

24

kd diffuseColorks = specularColorn = shininessηt = emissiveColor[0] (if η == 0, take kr (0)= ks)c = transparencySpring 2009

Page 13: Synthesis 4b - Optics.pptcs236373/Tutorials/Optics.pdf · Optics M. Ben-Chen, A. Vaxman Computer Science Dept. Technion Page 2 Camera Parameters P - camera location-camera direction

Image SynthesisExercise class 4a

Optics

M. Ben-Chen, A. VaxmanComputer Science Dept. Technion Page 13

Texture Mapping

Two texture coords (s,t) for each vertexUse bilinear interpolation for internal pointUse (s,t) as normalized picture coordinatesTexture filtering

Primitive – nearest neighbor (strong aliasing)Simple – bilinear interpolationComplex – general filter

25

1.0

1.0Spring 2009