Refraction is the bending of light as it passes from one transparent medium to another. The amount of this bending is dependent on a property of a medium known as its "Index of Refraction", abbreviated as "IOR". This property can be expressed as a number, greater numbers indicating a greater amount of bending.
The term "Dispersion" refers to the dependence of a material's IOR on the wavelength of light. The IOR measured for a given medium varies with the wavelength of light used, and generally a higher wavelength results in a lower IOR. Dispersion is the cause of rainbows, and other similar phenomena whereby white light is split into a spectrum.
Simulating refraction in computer graphics is straightforward, the technique known as raytracing handles it quite well. Simulating dispersion is a little more complicated, and usually more computationally intensive. Luckily in most cases it isn't necessary to take into account dispersive effects, since they are usually quite small and therefore not noticeable. In cases where large dispersive effects are needed in a scene (such as a rainbow), faking it is generally much faster than computing an exact solution.
Sometimes, however, the need (or desire) may arise for a relatively accurate treatment of dispersion. In this experiment I attempt to create an image featuring an accurate dispersive effect using only standard raytracing techniques. Note that there's nothing new about my method, it's just something I was interested in trying.
For this experiment I've chosen to render diamond gems. The beauty of a diamond is a result of both its high IOR, which causes light to bounce around inside the gem many times creating the "sparkle", and dispersion which cause the light to break into separate colors causing the "fire". I felt this to be a case where the accurate simulation of dispersion as well as refraction might have a significant bearing on the aesthetic appeal of the final image.
For the model I constructed a gem based on the "Tolkowsky" Round Brilliant cut, a style of diamond designed to return the maximum amount of light through the crown of the gem. The material applied was highly transparent, with fresnel reflectance (although this is not seen in the image; see below for an explanation) and an appropriate IOR for diamond. Two of these gems were placed on a flat plane, and a blurred landscape image was used as an environment map. Two shadow-mapped spotlights were set up encased in self-illuminating white boxes.
When computing refraction, standard raytracing uses a single IOR for a material, independent of the color (and hence the wavelength) of the ray being traced. My idea was to render three separate images, each representing only a single wavelength of light, and to then composite these images into a full-color image. By modifying the material's IOR for each of the three images, I would be effectively introducing wavelength-dependent IORs (dispersion) into the raytracing.
Diamond has an IOR of 2.42 for yellow light (wavelength 589.3 nm). The three primary colors used in computer graphics are red, green, and blue, and to represent each of them I used IORs of 2.40, 2.43, and 2.46 respectively. These aren't necessarily the measured IORs for diamond for the relevant wavelengths, but through some quick tests I judged the range of values to be acceptable.
The images were rendered in 3D Studio MAX using the prototype "Ghost" raytracer currently in development at Blur Studios. The settings used were as follows:
Resolution: 800 x 480
Sampling: Min 1, Max 2
0 Reflections, 8 Refractions
Note that with 0 reflections, the fresnel reflectance of the material becomes irrelevant. Reflections were avoided for two reasons. First, because the current build of Ghost spawns too many unnecessary rays when refraction and reflection are combined, slowing down the render. As Ghost matures it will be able to handle such cases much more efficiently, at which point it would be appropriate to enable reflections. Second, as this experiment concentrates on refraction, I didn't want reflections complicating my assessment of the results.
Each image took approximately 92 minutes to render on a 400 MHz Celeron (fortunately I have a network available and was able to render the images concurrently). The compositing was done in Photoshop, and a very slight bloom was added.
Overall I was very pleased with the result. I think the gems themselves look quite realistic, and the fire turned out fairly well. Missed most in the image are the caustics. Primarily these would be reflective caustics, as the design of the Tolkowsky cut minimizes refractive caustics below the gem (that light is refracted up through the crown instead). The lack of reflections doesn't seem to have a significant impact on the image. The fresnel reflections would have been quite weak anyway, and with the refraction elements being so predominant, they are not missed.
As for the dispersion effects, it appears that they originate mainly from the light boxes, with the light from the environment map not dispersing much or at all. This isn't necessarily a bad thing, the fire effect of a diamond should not be overwhelming, but rather subtle in character. I'm not sure of the reason for the environment not dispersing (or appearing not to disperse), but I suspect it could be chiefly due to the softly blurred nature of the map.
Concerning the accuracy of the simulation, there are two items to be considered. The first is that the IOR used for each wavelength's image may not be precisely the same as that found in reality. The error introduced here is not likely large, and can be reduced by obtaining laboratory measurements. The second item introduces an error inherent to the technique. By considering only three wavelengths, we are taking a very small subset of the many wavelengths that would be present in reality. The result is discretely delineated spectra, instead of continuous ones. When the degree of dispersion is small this error is likely to be imperceptible, but in certain cases, such as a simple glass prism, it would likely become very noticeable.
I would say that this technique is feasible for some limited situations, but not for general use. The approximation should be sufficient to produce aesthetically acceptable images, but the tripling of rendertime is a key issue. I think where comprehensive dispersive effects are needed, more rigorous methods should be employed. A great deal of solid research has been done in rendering dispersive effects, and the information should not be difficult to find.
Thanks for reading. I'd be pleased to receive any comments you may have, I can be contacted at email@example.com.