Ray Tracing Assignment Goal is to reproduce the following So You - - PDF document

ray tracing assignment
SMART_READER_LITE
LIVE PREVIEW

Ray Tracing Assignment Goal is to reproduce the following So You - - PDF document

Ray Tracing Assignment Goal is to reproduce the following So You Want to Write a Ray Tracer Checkpoint 6 Refraction Whitted, 1980 Ray Tracing Assignment Ray Tracing Assignment Seven checkpoints Seven checkpoints Setting


slide-1
SLIDE 1

1

So You Want to Write a Ray Tracer

Checkpoint 6 – Refraction

Ray Tracing Assignment

 Goal is to reproduce the following Whitted, 1980

Ray Tracing Assignment

Seven checkpoints

  Setting the Scene  Camera Modeling  Basic Shading   Procedural Shading  Recursive Ray Tracing – Reflection  Recursive Ray Tracing – Transmission   Tone Reproduction

Ray Tracing Assignment

Seven checkpoints

  Setting the Scene  Camera Modeling  Basic Shading   Procedural Shading  Recursive Ray Tracing – Reflection  Recursive Ray Tracing – Transmission   Tone Reproduction

Refraction

 Perform recursive ray tracing by

considering reflection and refraction

 Parameters to add:

 For each object

 kr, kt – reflection and transmission constants  kt ≠ 0 for this checkpoint  Index of refraction (example 0.95)

Recursive Ray Tracing

color illuminate (ray, depth) find closest intersect if (!intersection) return background color else spawn shadow ray retcolor = local illumination if (depth < MAX_DEPTH)

if (kr > 0) spawn reflection ray retcolor += kr * illuminate (reflect ray, depth+1) if (kt > 0) spawn transmission ray retcolor += kt * illuminate (trans ray, depth +1)

return retcolor

slide-2
SLIDE 2

2 Recursive Ray Tracing

For each pixel spawn ray from camera pos to pixel pixel_color = illuminate (ray, 1)

If negative – total internal reflection

Calculating Transmission Ray

t t i i

θ η θ η sin sin =

We can find the equation for t, the transmission ray:

2 2 2 i i

) ) n d ( 1 (

  • 1

n ) n) n(d d ( t

t t

η η η η

+

=

Assume d and n are normalized. Starting with Snell’s law

i

  • t

η

i

  • t

θ

d t n d is the incoming ray, t is the transmission ray.

Total Internal Reflection

 an optical phenomenon that occurs

when light is refracted (bent) at a medium boundary enough to send it backwards, effectively reflecting all of the light.

 In these cases, the transmission ray will

be spawned in the reflection direction.

Total Internal Reflection

Wikipedia

Total Internal Reflection

Total internal reflection occurs around boundary of transparent sphere

Calculating transmission ray

 Snell’s law applet

 http://www.physics.northwestern.edu/ugrad/vpl/opt

ics/snell.html

 Index of refraction of air = 1.0  Optimization

 If indices of refractions are the same

 no bending  Transmission direction is the same as incoming direction

slide-3
SLIDE 3

3 Things to think about

 Must keep track if you are inside or

  • utside

η Index of refraction Normal vector

Things to think about

 2 ways to deal

 If n • d < 0 then

 Inside  Use –n as normal for calculations  Use inside η as

 Keep track as you are spawning rays i

  • Things to think about

public Vector3f faceForward (Vector3f A Vector3f B)

{ // For acute angles, dot product will // be positive if (A.dot(B) >= 0) return A; // Obtuse angle, reverse the first vector Vector3f V = new Vector3f (A); V.scale (-1.0f); return V; }

Refraction

 For sake of checkpoint

 Make one sphere transparent (kt = 0.8)  Make other sphere non-transparent  May wish to test first with index of refraction = 1.0

Refraction

 Note:

 If done correctly, you should now have a faithful

reproduction of the target image.

 Sample parameters

Sphere1 – front Color (all) = white Ka = 0 .0 7 5 Kd = 0 .0 7 5 Ks = 0 .2 Ke = 2 0 .0 Kr = 0 .0 1 Kt = 0 .8 5 Sphere2 – rear Color (amb/diffuse)

(0.7, 0.7, 0.7)

Color (spec) = white Ka = 0 .1 5 Kd = 0 .2 5 Ks = 1 .0 Ke = 2 0 .0 Kr = 0 .7 5 Kt = 0 .0

Refraction

 Due date:

 Must be posted to Web site by May 2nd  Recall:

 10% penalty per day

 Having trouble?

 Let me know EARLY.

 Questions?

slide-4
SLIDE 4

4 Extra extra

 For 5 points:

 Adjust shadow ray based upon

transparency of objects.