ray tracing assignment
play

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 Setting the Scene Camera Modeling


  1. So You Want to Write a Ray Tracer Checkpoint 6 – Refraction Ray Tracing Assignment  Goal is to reproduce the following Whitted, 1980 1

  2. 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  2

  3. Refraction  Perform recursive ray tracing by considering reflection and refraction  Parameters to add:  For each object  k r , k t – reflection and transmission constants  k t ≠ 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 (k r > 0) spawn reflection ray retcolor += k r * illuminate (reflect ray, depth+1) if (k t > 0) spawn transmission ray retcolor += k t * illuminate (trans ray, depth +1) return retcolor 3

  4. Recursive Ray Tracing For each pixel spawn ray from camera pos to pixel pixel_color = illuminate (ray, 1) Calculating Transmission Ray Starting with Snell’s law d n � i η θ = η θ sin sin � i i i t t η t θ Assume d and n are normalized. t t We can find the equation for t, the transmission ray: d is the incoming ray, t is the 2 η − • η − • 2 transmission ray. ( d n(d n) ) ( 1 ( d n ) ) i i t = + n 1 - 2 η η t t If negative – total internal reflection 4

  5. 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 5

  6. 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 6

  7. Things to think about  Must keep track if you are inside or outside 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 � i  Keep track as you are spawning rays 7

  8. 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 (k t = 0.8)  Make other sphere non-transparent  May wish to test first with index of refraction = 1.0 8

  9. Refraction  Note:  If done correctly, you should now have a faithful reproduction of the target image.  Sample parameters  Sphere2 – rear  Sphere1 – front  Color (amb/diffuse)  Color (all) = white (0.7, 0.7, 0.7)  Ka = 0 .0 7 5  Color (spec) = white  Kd = 0 .0 7 5  Ka = 0 .1 5  Ks = 0 .2  Kd = 0 .2 5  Ke = 2 0 .0  Ks = 1 .0  Kr = 0 .0 1  Ke = 2 0 .0  Kt = 0 .8 5  Kr = 0 .7 5  Kt = 0 .0 Refraction  Due date:  Must be posted to Web site by Feb 6th  Recall:  10% penalty per day  Having trouble?  Let me know EARLY.  Questions? 9

  10. Extra extra  For 5 points:  Adjust shadow ray based upon transparency of objects. 10

Recommend


More recommend