Introduction

My project involved the computation of the color of the sky, based upon simulation of single scattering of light in the atmosphere. A number of people have worked on this problem, with most of the work coming from a group of Japanese researchers. I chose to follow the general method for handling scattering that these researchers use, and implemented the sky color computation as a part of a multi-spectral ray tracer.

This report is organized as follows: First, I briefly discuss what work has been done in this area. Next, I describe what I did in detail. Finally, I mention some of the ways this work can be extended. This is followed by references and some sample images generated.

Background

Attempts by computer scientists to model atmospheric scattering appear to have started in the early '80s, with the first heavily cited paper on the subject being a SIGGRAPH'92 paper by Blinn. [Although others, such as N.L. Max also worked on similar issues earlier, Blinn's paper seems to be the earliest of the widely cited papers.] This work appears to have focused primarily on local scattering, to reproduce fog, haze, etc. In 1987, Victor Klassen publised a paper dealing with using scattering to determine the sky color. From here, several people began to work on the problem of determining sky color.

Although a number of people worked in this area, the majority of work appears to have been done by a group of Japanese researchers. All of the newer models have remained remarkably close to Klassen's "original" model, with the only major change being a more accurate representation of molecule densities. There has been some work on incorporating multiple scattering into the model, but this seems to still be in the early stages. Although there have been other refinements to the model, most of the work seems to take the approach of figuring out ways to make as few color computations as necessary for some application, or to use the information from the scattering model to perform more advanced rendering.

It should be noted that for many years, there has been a great deal of work on atmospheric scatter in the physics, optics, and remote sensing communities, but this work was not geared toward image generation.

What I Did

Goal

The goal for my project was to use a scattering model to incorporate sky color calculation into a ray tracer.

Multi-spectral Ray Tracer

In order to perform accurate sky color computation, a multi-spectral approach is necessary. I modified the ray-tracer put together for our first assignment to use a multi-spectral approach. Basically, the system performs all computations for 34 wavelengths of light - sampled every 10 nm from 395 nm to 725 nm. After the final values have been computed for each wavelength (just before output to the image file), the spectrum is converted to the CIE XYZ color system. From there, RGB values are generated based on phosphor values which should be close to many monitors.

In order for the ray tracer to be effective, it was necessary to obtain some sample values of reflectance for various substances. I interpolated some data from the CRC Handbook to obtain reflectances for a number of metals (Aluminum, Copper, Gold, Iron, Nickel, Platinum, Silver). I also interpolated solar data to get an intensity spectrum for sunlight. This work allowed me to generate pictures with the ray tracer which seemed significantly better than those generated in the homework assignment (using RGB values for the entire process).

Scattering Model

Without going into the details, I will discuss the scattering model that I implemented. Because they seem to dominate the current work in the field, I chose to follow the scattering model used by Nishita, Nakamae, Kaneda, and their colleagues (actually, a minor combination of the models they use). Although they have many different minor variations to the scattering model, it generally falls into the same format, which is not that different from Klassen's. Basically, for a given viewing direction, one computes the total light which arrives along that direction. This can come directly from the sun (after being attenuated by the atmosphere), or as the result of scattering from some molecule. It is necessary to integrate along the view direction to take account of all potential scatter points. For each scatter point, another two integrations are necessary to measure optical length. Thus, we have, in effect, a double integral. Although in reality, there can be multiple scatters of the light, such a computation is extremely complex (e.g. a quadruple integral for double scattering) and it is not, in general, performed. [Some people have worked on developing ways of estimating the integrals to cut down on computation time.]

There are two main types of scattering which occurs in the atmosphere. The first is due to interactions with the air molecules. These molecules (such as oxygen and nitrogen) are very small, and the scattering falls into the Rayleigh scattering pattern. The physical constants and equations governing this type of scatter are known, and I was able to obtain the necessary values. The second type of scatter is due to large particles suspended in the atmosphere (aerosols), such as pollutants or water droplets. These larger molecules cause a Mie scattering pattern. Because the distribution of particles in the atmosphere is not uniform nor well known, and since the Mie scattering equations have not been determined completely, it is necessary to make some approximations here. I followed the approach of Tadamura et. al. in choosing a phase function for Mie scattering, and chose a scatter coefficient based solely on what looked good.

Two distinct problems were encountered when trying to determine the necessary values for the scattering computation. These problems ate up several hours of work, and comprised the majority of my "debugging". Each of them is due to an error in the paper by Tadamura et. al. The first problem is that the Loschmidt number is reported as 2.7x10^-19, when it should actually be about 2.7X10^19. The second problem is that the turbidity coefficient, B, is said to lie between 0.05 and 2.0. After experiencing problems, I rederived it on my own from a graph in another book (Measure's, see below) and found the value to be approximately 1.2x10^-11. Although the first error was most likely a typo, the magnitude of the difference in the second error makes me wonder if there was some factor they were omitting from the article entirely.

The integrations were performed using the Composite Simpson's Algorithm. At first, I used 100 divisions for each integral, but later found that I could use as few as 10 divisions with no noticible change in the final result. Sky color computation for a single viewing direction tended to take on the order of tenths of seconds on the Silicon Graphics machines around the department.

The scattering algorithm is too complex to go into all details here, so please refer to the papers for more information. Specifics of my code should be found in in-line documentation or the README.keyser file.

Results

Overall, the results appear to be about what I would expect. I found it necessary to apply a constant scaling to the final intensity for most scenes, and this scaling varied from image to image (some scenes were dimmer and needed more scaling). This was to be expected (obviously, it is darker at some times than others!). Also, I computed sky color in all cases as if looking from the viewpoint. For local scenes, this should work fine, but if there are incredibly large images in the scene (such as nearby mountains), this approximation will not be valid.

My program will now output a scene in which the sky color is correctly rendered for all directions. The sky color can be seen in reflections off of objects, or directly from the viewpoint. Please note that I did not implement sky luminance, which is a much more complicated matter than I wanted in this project. Also, I have not put in the sun, specifically, as Klassen does in his paper. This would involve a light attenuation calculation (one integral) for those views in the sun direction, similar to the computation for optical length performed as a part of scatter computation.

Extending the Work

There are a number of different directions one could go from here. One useful feature which has been implemented by others is to use the sky to emit luminance. Though better suited for a radiosity scheme than a ray-tracing approach, it has been applied to both methods of rendering. Diffuse and specular reflection of sky light has already been looked at by some people. Others have tried to speed up computation by either sampling or by expressing the sky color as a combination of basis functions (so that only the weights of the basis functions need to be computed). Multiple scattering has been looked at, but the approaches so far are not fast enough (or use too much of an approximation) to be useful in general. Other people have looked into methods of handling incremental sun position changes quickly. In any case, there are a number of avenues that could be taken, some of which have already been looked at, given the base scattering computation that I have implemented.

References

I will list here those references which I made direct use of when putting together this project (specific aspects of these papers were used), sources for some of the data used in the project, and a few other references that I found interesting but did not directly use in this project. I have not included all the references I looked at, only those that seemed most relevant.

References Directly Used for Project

Data Used in Project

Other Useful Material

Sample Images

A silver object with sun at 45 degree inclination from behind.
A silver object with sun at horizon (0 degree inclination) from behind.
Reflecting spheres near sunset (sun at 5 degree inclination). Spheres are made of (l->r, t->b) aluminum, copper, gold, iron, nickel, and platinum. There are artificial lights providing the highlights.