The relationship of light with objects could be reduced to 2 interactions; Either light bounces off an object, either partially or completely, or it traverses the object. Traversing the object, an effect known as refraction, shares some characteristics with reflections: Both reflection and refraction mechanisms possess incident and reflected rays, although the similarities end there. The main difference between the two effects would be that in reflection, the ray remains on the same side of the normal of the surface involved, while in refraction, the ray goes into the opposite side of the normal involved. This is illustrated below.
Image from omniadiamonds.com |
Reflections applied to ray tracing
It is fortunate that the tools we have already developed for rendering can be applied to simulate object reflections. They simply need to be adapted to fill that purpose. The key element in reflection would be that instead of having a ray of light coming from a light source, bouncing on an object into our eye, (we here remind the reader that we are describing forward ray tracing for clarity) we have the ray bounce on a first object onto a second one, and then having this second bounce go into our eye.
Intensity of the reflected light
Now that we have established the basic elements for reflection to occur, i.e. two objects at the least, positioned in such a way that the light reflecting off one object is directed at the other, we must focus our attention on how to establish the final light intensity that would enter our eye.
The solution lies in adding all the light intensities involved at every step of the reflection; In the simplest of scenarios, we compute the light intensity of the first object at the point of contact, then this intensity is added to that of the other object, and this sum of intensities for this particular ray are then sent to the eye.
How do we calculate the intensities to be sent to other object? The solution lies in using the Phong model at each point involved in the reflection process; as shown in the illustration below.
The reflection process |
Here is a typical reflection example created with the application:
Two spheres reflecting in each other. |
It is interesting to note that a reflection algorithm could be implemented in a recursive fashion, enabling the superimposition of multiple reflections, creating the double mirror effect. The Simple Ray Tracer application, due to the inherent complexity of establishing a proper recursive reflection method, has instead implemented a non-recursive reflection method that can only create single level reflections in objects. Perhaps, in future developments, such a recursive method will be used.
The reflection coefficient: How much light to reflect?
Another interesting aspect of reflection lies in evaluating how much light an object actually reflects in opposition to how much it absorbs. If an object reflects 100% of the light it receives, we could say that the object does not have a colour of its own, but is only visible by the reflections it creates.
An object could also be totally non reflexive and therefore be invisible; But reality imposes the idea that all objects have different reflexive properties. We can quantify this in our program by
adding another data member to our objects a reflection index. The reflection index is a value of range 0.0 to 1.0 that basically subtracts a portion of the light intensity of an object to replace that portion with the intensity of the reflection. A reflection index of 0.3 for instance would remove 0.3 * the intensity of the object and replace it the intensity of the reflection. A reflection index of 1.0 replaces the intensity of the object entirely by the reflection. The underlying colour disappears. At this point in the implementation, the reflection index serves only a Boolean value. Each object is either entirely or totally non reflexive, a non-reflexive object still being visible as the index only affects the points of the object where reflections occur.
Rendered scene with no reflection |
The same scene, with reflection added. |