Refraction

The following image was created in about an hour using lab9.cpp
and the scratch-a-pixel article on refraction.



Wednesday class will have a brief lecture on light refraction.
You will be given an exercise for extra-credit points.

How to do the image above...

  1. Add to your object definition
       • surface has refraction
       • index-of-refraction (outside)
       • index-of-refraction (inside)

  2. In the trace function, check for refraction.
       • refraction is very similar to reflection (already working)

  3. Create a new ray and recursively call trace, similar to reflection.

  4. Call the refract() function provided by scratch-a-pixel.
       • use the "complete implementation of the refraction function"
       • add arguments for in and out IOR.
       • look at the code closely, and get it working with lab-7 vectors.
       • do not reduce the "weight" when recursing trace().
       • I used the refract() function from the article.
       • Some code refactoring was done. Only refactoring.

  5. The glass sphere is one sphere inside another. A shell of glass.
       • adjust the thinness of the shell to make it look
         like Whitted's famous image.

Have yours working by wed class for some extra credit.

With a slight change to the refract() function, the glass sphere can be made
to look even more real and beautiful. Finding and making this change will
show me that you understand refraction well. 



            before                       after
 
Gordon Griesel