In this assignment is an incremental improvement upon the ray casting system you built for Assignment 4. In particular, you will implement recursive ray tracing for both reflection and refraction.
In the previously defined command to intiate ray tracing an argument specifying the recursion depth was included but not used. In this assignment you will set your recursion depth to 3 and implement recursive ray tracing.
In particular, where as previously the illumination for a point on a surface was defined as the sum of the ambient, diffuse and specular reflection, now it will include a fourth reflection term. This reflection illumination is computed by recursively calling the function you have already defined for computing the illumination given a ray and a scene model (see hint below). Rather than introduce a new weight for this fourth term, use the specular reflection constant Ks already being used for the specular component.
To simplify this assignment, restrict yourself to implementing refraction only for spheres. As discussed in lecture, this will mean that total illumination for a point on a sphere becomes a weighted sum of two terms. The first is the complete ambient plus diffuse plus specular plus reflection term associated with light arriving at the surface. The other new part is ther refraction term. It is the light be transmitted through the solid to the point where you are calculating illumination.
For a sphere, there will be two parts to implementing refraction and it is easiest to conceptualize them independently and code the seperately. The first is to find the path through the sphere to the place where the ray will leave and renter the scene: presumably air. Doing this requires computing the refraction ray through the sphere and then finding the point on the sphere where it intersects the sphere boundary. Think of this point as where your refraction ray will leave the sphere. Next, from this point on the sphere compute the direction of the ray as it leaves the sphere. This calculation is identical to the first with one key difference, the role of the two indices of refraction switch since your now refracting a ray of light leaving the solid and entering air.
So far the two changes in direction are handled as a special case involving the particular sphere through which light is passing. Once you have the point on the sphere where the refraction ray is leaving the sphere as well as its new direction of travel, it is then advisable to recursively use exactly the same function used before to compute the illumination based upon a ray and the scene model. To put this in pragmatic terms, the extra work of creating a semi-transparent sphere is primarily in finding the place on the sphere that the refraction ray leaves the sphere and the direction it travels. After that, no additional new code is needed since one usees the same general function developed for computing illumination given a ray and the scene model.
If one wishes to model a sphere that is 80% transparent, than the final total illumination is 0.2 times the ambient plus diffuse plus specular plus reflection term added to 0.8 times the value passed back along the refraction ray.
It is very much worth your while to begin by making sure that your single function that returns illumination given a ray and the scene model work regardless of whether or not the ray originates at a particular point. In other words, take out an special dependencies upon assumptions such as the ray originates at the focal point or at a pixel. It is recommended you get this working correctly on a scene from the previous assignment before you proceed to implement recursion for either reflection or refraction. Note also you'll be adding a recursion depth value to your illumination computation function that will be used to track if this call is coming from a pixel, depth 1, or from a first bounce off a surface, depth 2. Similarly, a refraction ray will have its depth incremented. This may be obvious, but when the depth reaches three stop computing reflection and refraction terms.
While a sphere floating above a checkerboard is not required for this assignment, you may find it a handy debugging tool. If you google "sphere" "ray trace" and "checkerboard" you'll quickly discover a wealth of imagery, and you'll also begin to see how such a scene is an excellent way of seeing of your reflection functionality is working correctly. Recall a checker board is simply a sequence of squares of alternatng color. Also, this may be one of those times where a model, a checker board, is more easily built by code rather than read from a .obj file. That said, if you choose this approach to debugging keep the generation of the checker board simple.
You will create the .obj, associated material file and command file to render two scenes. Please name these using the convention "scene04.xxx" and "scene05.xxx". Note scene numbers starts where the previous assignment left off.
Scene 4:
Building upon your previous scene 3 of a sphere inside a hollow sphere, for this scene make the sphere partially transparent. Start out trying a transparency of approximatley 80%. If you are following standard alpha blending conventions where 0.0 is completely transparent and 1.0 is opaque, set alpha to 0.2 (note in lecture we switched this convention - you may use either, just be consistent.) .
Scene 5:
Build and render a scene involving at least one semi-transparent sphere that is visually attractive and/or interesting. This portion of the assignment is not worth more than 10% of the complete assignment. That said, this is a chance to really play in the space of ray traced renderings exploring interactions between colored light sources and objects as well as object to object interactions.
As with the previous assignment, your work will be turned in as a tar file submitted through RamCT.
The procedure for running your assignments, on a CS Department Linux Machine.
No addendums at this time (10/27/2012)