6.837 - Project #5


Ground Rules for all projects:
Links you might find helpful on this project:

In this last project you are asked to make two changes to the ray tracer given in class.

  1. Add refraction to the illumination model.


    • The last two parameters of the surface model kt and nt should be interpreted as follows; kt is the fraction of the transmitted ray's intensity that is reflected to the eye, nt is the ratio of the surrounding material's index of refraction to the object's index of refraction. For example, if you want to simulate a spherical water drop the index of refraction for water is approximately 1.33. If we assume the surrounding material is air then its index of refraction is 1. So when a ray strikes from the outside of an object the relative index of refraction is computed as follows.

      And when a ray strikes inside an object and exits it the relative index of refraction is:

      Note: You will need to add code to keep track of whether a ray strikes the "inside" or "outside" of a primitive.

    • Here is how you can compute the refracted ray. The following vectors are represent the geometry at the point that is being shaded. The vectors n and v are passed as inputs to the Surface.Shade( ) method.
      The refracted vector t can be computed using the following derivation. This derivation is based on simple geometric relationships, vector algebra, and Snell's Law as discussed in Lecture 16.


  2. Add your own primitive. For example
    • cone tipX tipY tipZ baseX baseY baseZ baseRadius
    • cylinder topX topY topZ baseX baseY baseZ Radius
    • torus centerX centerY centerZ orbitX orbitY orbitZ Radius
    • triangle aX aY aZ bX bY bZ cX cY cZ
    • others


  3. You may optionally do any of the following
    • Add more primitives
    • Add texture mapping
    • Add bump mapping
    • Incorporate bounding volumes or spatial subdivision


You should start with this version of the code. When you turn in your project I expect to see at least one example applet and a new scene file that displays transparency as well as your new primitive.



What does a crystal ball look like?

Here is an example scene file (tboard.ray) that can be used to test refraction.