Lecture 20: All Together with Refractioncs410/yr2019fa/more_progress/pdfs/… · glass= 1.5 θ r...

13
Lecture 20: All Together with Refraction November 12, 2019 11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 1

Transcript of Lecture 20: All Together with Refractioncs410/yr2019fa/more_progress/pdfs/… · glass= 1.5 θ r...

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

Lecture 20:All Together with Refraction

November 12, 2019

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 1

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

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/12/19 CSU CS410 Fall 2019, © Ross Beveridge 2

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

Refraction - With Trigonometry

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 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

The refraction ray is:

!" Angle of incidence

!# Angle of refraction

$" Index of refraction material #1

$# Index of refraction material #2

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

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

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 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 20: All Together with Refractioncs410/yr2019fa/more_progress/pdfs/… · glass= 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i Sin muTheta

More Recursion• This changes ray tracing from tail-recursion

to double-recursion…

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 5

camera

light1 light2

light3

NN

This is the recursiveRefraction ray

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

Practical Refraction: Surfaces

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 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!

Ø Overall effect: displacement of the incident vector

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

Refraction - No Trigonometry.

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 7

WN

R

θ i

θ i

θ tT-N

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

First Constraint: 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 20: All Together with Refractioncs410/yr2019fa/more_progress/pdfs/… · glass= 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i Sin muTheta

Refraction - No Trigonometry

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 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 20: All Together with Refractioncs410/yr2019fa/more_progress/pdfs/… · glass= 1.5 θ r =sin −1 η i η r sin(θ i) " # $ % & '=sin−10.67⋅sinθ ((i)) Theta i Sin muTheta

A Wonderful Real Example

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 9

Yes, refraction typically makes everthing upside down and backwards.

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

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

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/12/19 CSU CS410 Fall 2019, © Ross Beveridge 10

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

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/12/19 CSU CS410 Fall 2019, © Ross Beveridge 11

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

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 12

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

The Complete Package

11/12/19 CSU CS410 Fall 2019, © Ross Beveridge 13

When you understand every line of code in the Sage Notebook creating this image you are will be in a position to write a truly compelling ray tracer.