Ray Tracing Assignment Goal is to reproduce the following Whitted, - - PDF document

ray tracing assignment
SMART_READER_LITE
LIVE PREVIEW

Ray Tracing Assignment Goal is to reproduce the following Whitted, - - PDF document

So You Want to Write a Ray Tracer Checkpoint 6 Refraction Ray Tracing Assignment Goal is to reproduce the following Whitted, 1980 1 Ray Tracing Assignment Seven checkpoints 1. Setting the Scene 2. Camera Modeling 3. Basic


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

slide-2
SLIDE 2

2

Ray Tracing Assignment

  • Seven checkpoints
  • 1. Setting the Scene
  • 2. Camera Modeling
  • 3. Basic Shading
  • 4. Procedural Shading
  • 5. Recursive Ray Tracing – Reflection
  • 6. Recursive Ray Tracing – Transmission
  • 7. Tone Reproduction

Ray Tracing Assignment

  • Seven checkpoints
  • 1. Setting the Scene
  • 2. Camera Modeling
  • 3. Basic Shading
  • 4. Procedural Shading
  • 5. Recursive Ray Tracing – Reflection
  • 6. Recursive Ray Tracing – Transmission
  • 7. Tone Reproduction
slide-3
SLIDE 3

3

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-4
SLIDE 4

4

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.

slide-5
SLIDE 5

5

Calculating transmission ray

  • Snell’s law applet

– http://www.physics.nwu.edu/ugrad/vpl/optics/snell.htm l

  • 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

Things to think about

  • Must keep track if you are inside or outside

η Index of refraction Normal vector

slide-6
SLIDE 6

6

Things to think about

  • 2 ways to deal

– If n • d < 0 then

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

– Use faceForward

i

η

Things to think about

  • FaceForward (RenderMan)

– The result is A, if A and B form an acute angle when placed head to tail, otherwise the result is -A. A (input): This is the first input vector. B (input): This is the second input vector. OUT (output): The result is A, if A and B form an acute angle when placed head to tail, otherwise the result is -A.

slide-7
SLIDE 7

7

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

slide-8
SLIDE 8

8

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.075 Kd = 0.075 Ks = 0.2 Ke = 20.0 Kr = 0.01 Kt = 0.85 Sphere2 – rear Color (amb/diffuse)

(0.7, 0.7, 0.7)

Color (spec) = white Ka = 0.15 Kd = 0.25 Ks = 1.0 Ke = 20.0 Kr = 0.75 Kt = 0.0

Refraction

  • Due date:

– Must be posted to Web site by Midnight Feb 7th – Recall:

  • 10% penalty per day

– Having trouble?

  • Let me know EARLY.
  • Questions?
slide-9
SLIDE 9

9

Extra extra

  • For 5 points:

– Like reflection…spawn multiple rays.