Eikasia is an experiment in the perception of forms. The images it creates are composed entirely of shadows - the cubes and ground plane have no texture of their own. They are perceived not by the light that they reflect, but by the shadows cast by neighboring figures. Eikasia explores our rather remarkable ability to visually comprehend shapes, even without the sorts of clues that intuitively seem necessary to do so.

The shadows of the scene begin as hard and directional, but as the image evolves the shadows refine, becoming increasingly soft and diffuse. They are calculated by simulating the cumulative effects of a large number of light sources, ultimately arriving at an approximation to the global illumination of the scene. The technique is called ambient occlusion, and its invention is generally credited to Hayden Landis of Industrial Light & Magic.

Ambient occlusion essentially considers each pixel in the image and asks the question, "in all directions, how often are neighboring objects between this point and the sky?" The algorithm for answering this question is based on raytracing, which is the classic computer graphics technique used to simulate the path of a single photon through a scene. The basic idea is to trace a large number of photons which all begin at the point of interest and which travel in random directions. For each of these directions, we can test to see if the photon runs into any other objects on its way toward the sky. If it does, then we consider it to be contributing shadow, and if it does not, we will count it as contributing light. The image at top-left depicts this idea in two dimensions. The rays of light which are dashed represent directions which can "see" light, meaning they don't run into anything. The solid lines represent directions which are occluded, since they collide with a neighboring object. By testing a large number of these directions (and in three dimensions instead of two) we are able to approximate the degree to which a particular point is in shadow. The math from there is straightforward - to determine the lighting, we simply add up all the directions which were unoccluded, and divide by the total number of directions we tested. In Eikasia's implementation, we see a progressive refinement of this calculation. Each time the image updates, we have traced new directions, which has increased the accuracy of the approximation. Eventually the image converges to an estimate that is imperceptibly different from the true values.

Geek Alert: This section contains full-frontal nerdity.
The ambient occlusion in Eikasia is implemented using a quasi-Monte Carlo sampling technique. It is based on the Halton point set, which is generated using a deterministic formula that has a uniform distribution and "looks" random. The implementation is based on the excellent paper Sampling with Hammersley and Halton Points by Tien-Tsin Wong, Wai-Shing Luk and Pheng-Ann Heng, which appeared in the Volume 2, Number 2 issue of the Journal of Graphics Tools. The reason I chose the Halton set over the Hammersley is that the Halton set is usable for incremental sampling, meaning it does not require foreknowledge of the number of samples which will be taken. Since Eikasia is designed to sample indefinitely, a technique which supported incremental sampling was a requirement.


To demonstrate the distinction, the applet above shows the result of taking 200 samples of both Halton and Hammersley points. Eikasia uses the Halton set in its three dimensional, hemispherical variant, but hopefully this two dimensional applet helps to visualize the trade-offs between the two algorithms. Notice how the Halton points (in red) converge on an even distribution much more quickly than the Hammersley points (in blue), but the Hammersley points ultimately arrive at a nicer distribution overall.