Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5...

13
Lecture 21: All Together with Refraction December 1, 2016 November 9, 2017 11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 1

Transcript of Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5...

Page 1: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Lecture 21:All Together with Refraction

December 1, 2016November 9, 2017

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 1

Page 2: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Translucence• Some light passes through the material.– Typically, “passed through” light gets the

diffuse reflection properties of the surface, unless object is 100% translucent (i.e. transparent)

• Speed of light is a function of the medium– This causes light to bend at boundaries– example: looking at the bottom of a pool

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 2

Page 3: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Refraction- WithTrigonometry

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 3

Key is Snell’s law …sin θt( )=ηi

ηt

sin θi( )

WN

R

θ i

θ i

θt TT = ηi

ηt

cos θi( )− cos θt( )"

#$

%

&'N −

ηi

ηt

W

Therefractionrayis:

𝜃" Angleofincidence

𝜃# Angleofrefraction

𝜂" Index ofrefractionmaterial#1

𝜂# Indexofrefractionmaterial#2

Page 4: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Practical Refraction: Solids• When light enters a solid glass object?

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 4

N W

hair= 1.0

hglass= 1.5

θr = sin−1 ηi

ηr

sin θi( )"

#$

%

&'= sin−1 0.67 ⋅sin θi( )( )

Theta i Sin mu Theta r0 0.00 0.67 0.0010 0.17 0.67 6.6720 0.34 0.67 13.3330 0.50 0.67 20.0040 0.64 0.67 26.6750 0.77 0.67 33.3360 0.87 0.67 40.0070 0.94 0.67 46.6780 0.98 0.67 53.3390 1.00 0.67 60.00

Page 5: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

More Recursion• This changes ray tracing from tail-recursion

to double-recursion…

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 5

camera

light1 light2

light3

NN

This is the recursiveRefraction ray

Page 6: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

PracticalRefraction:Surfaces

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 6

• What happens as it passes through a solid or surface?

sinθ1 =ηi

ηr

sinθi

sinθi =ηr

ηi

sinθ2

sinθ1 =ηi

ηr

ηr

ηi

sinθ2

= sinθ2

Note: this assumes the two surfaces of the solid are coplanar!

Ø Overalleffect:displacementoftheincidentvector

Page 7: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Refraction- NoTrigonometry.

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 7

WN

R

θ i

θ i

θ tT-N

T =αW +βNsin θi( )2 µ 2 = sin θt( )2

FirstConstraint:Snells Law

µ =µi

µt

1− cos θi( )2( )µ 2 =1− cos θt( )2

1− W ⋅N( )2( )µ 2 =1− −N ⋅T( )2

1− W ⋅N( )2( )µ 2 =1− −N ⋅ αW +βN( )( )2

Page 8: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Refraction- NoTrigonometry

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 8

Second Constraint: Refraction ray is unit length.

T ⋅T = αW +βN( ) ⋅ αW +βN( ) =1

=α 2 + 2αβ W ⋅N( )+β 2 =1

Two quadratic equations in two unknowns.Solving is a bit involved, …Here is the answer.

α = −µ β = µ W ⋅N( )− 1−µ 2 +µ 2 W ⋅N( )2

Page 9: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

AWonderfulRealExample

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 9

Yes,refractiontypicallymakeseverthingupsidedownandbackwards.

https://physicsb-2009-10.wikispaces.com

Page 10: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Refraction and Polygons• It is entirely possible to implement refraction

through complex solid models defined by polygons.

• But! Doing so requires the following:–Models must be complete: no holes!– All faces (triangles) must be tagged to a solid.• Needed to find where refraction ray exits the solid.

• There is a simpler special case– Thin faces with parallel sides (next slide).

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 10

Page 11: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

Special Case: Thin Faces• Consider entrance and exit– The are parallel (see picture)

• Refraction vectors– Pass through at a shifted angle– But exit in the same direction

• Result is an offset only– Offset depends on index of refraction– Offset depends on the thickness of the face

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 11

Page 12: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 12

Page 13: Lecture 21: All Together with Refractioncs410/yr2017fa/more_progress/pdfs/cs410_… · glass = 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i

TheCompletePackage

11/9/17 CSU CS410 Fall 2017, © Ross Beveridge & Bruce Draper 13

WhenyouunderstandeverylineofcodeintheSageNotebookcreatingthisimageyouarewillbeinapositiontowriteatrulycompellingraytracer.