Ray Tracing 6

Ray Tracing 6

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 the Scene Setting the Scene Camera Modeling Camera Modeling Basic Shading Basic Shading Procedural Shading Procedural Shading Recursive Ray Tracing – Reflection Recursive Ray Tracing – Reflection Recursive Ray Tracing – Transmission Recursive Ray Tracing – Transmission Tone Reproduction Tone Reproduction Refraction Recursive Ray Tracing color illuminate (ray, depth) Perform recursive ray tracing by find closest intersect considering reflection and refraction if (!intersection) return background color else Parameters to add: spawn shadow ray For each object retcolor = local illumination if (depth < MAX_DEPTH) kr, kt – reflection and transmission constants if (kr > 0) kt ≠ 0 for this checkpoint spawn reflection ray retcolor += kr * illuminate (reflect ray, depth+1) Index of refraction (example 0.95) if (kt > 0) spawn transmission ray retcolor += kt * illuminate (trans ray, depth +1) return retcolor 1 Recursive Ray Tracing Calculating Transmission Ray For each pixel Starting with Snell’s law d ! n spawn ray from camera pos to pixel i !i η sinθ =η sinθ pixel_color = illuminate (ray, 1) i i t t ηt θ t t Assume d and n are normalized. We can find the equation for t, the d is the incoming transmission ray: ray, t is the η (d −n(d •n)) η2 (1 −(d •n)2 ) transmission ray. t = i +n 1- i η η 2 t t If negative – total internal reflection Total Internal Reflection 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. Wikipedia Total Internal Reflection 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 Total internal reflection occurs around boundary of no bending transparent sphere Transmission direction is the same as incoming direction 2 Things to think about Things to think about Must keep track if you are inside or 2 ways to deal outside If n • d < 0 then Index of Inside Use –n as normal for calculations η refraction Use inside η as !i Normal vector Keep track as you are spawning rays Things to think about Refraction public Vector3f faceForward (Vector3f A Vector3f B) For sake of checkpoint { Make one sphere transparent (k = 0.8) // For acute angles, dot product will t // be positive Make other sphere non-transparent if (A.dot(B) >= 0) return A; // Obtuse angle, reverse the first vector May wish to test first with index of refraction = 1.0 Vector3f V = new Vector3f (A); V.scale (-1.0f); return V; } Refraction Refraction Note: Due date: If done correctly, you should now have a faithful reproduction of the target image. Must be posted to Web site by May 2nd Sample parameters Recall: 10% penalty per day Sphere1 – front Sphere2 – rear Color (all) = white Color (amb/diffuse) Having trouble? (0.7, 0.7, 0.7) Ka = 0 .0 7 5 Color (spec) = white Let me know EARLY. Kd = 0 .0 7 5 Ka = 0 .1 5 Ks = 0 .2 Kd = 0 .2 5 Questions? 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 3 Extra extra For 5 points: Adjust shadow ray based upon transparency of objects. 4.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us