Atmospheric scattering

This weekend I got around to implementing the atmospheric scattering approach described in "A Practical Analytic Model for Daylight". It is basically a simplified model of the scattering that happens when light travels through air, with the light from the object being out-scattered, and sunlight and skylight being in-scattered. The amount of scattering is determined by the amount of turbidity in the air. Higher turbidity leads to higher haziness or cloudiness in the air. The result can be shown in the following two renders, the first with low turbidity and the second with high turbidity:

A Practical Analytic Model for Daylight


Beer's Law

I added Beer's law causing light that travels through water to be attenuated based on the inverse exponential of the distance traveled. This means that increasing depth will give the water a darker appearance, as seen in the render below:

I also switched to an implicit representation of the water surface, reducing the memory requirements. In addition I compute the normal vector based on the water surface equation instead of indirectly based on the height map, meaning the water surface is now bump mapped, and the geometrical resolution doesn't need to be that high in order to get high frequency details in the light reflection and refraction.



I made a simple height map generator which basically just sums a set of sine curves with different directions, amplitudes, and wavelengths, creating something that looks like water. The amplitude of the waves are also modulated by the water depth by looking at the height of the terrain when computing the water height map, so that the waves will get more shallow closer to shore. Combining the water height map with Fresnel based reflection and refraction produces the nice water effect shown in the image below:

The height map for the water now takes up the same amount of memory as the terrain height map, so I might try to avoid storing it explicitly, instead computing the sum of sines on demand. This also requires some changes to the kd-tree I use for ray tracing a height map, storing the tree nodes there implicitly as well. The upshot is that the highest wave frequency would no longer be limited by the resolution of the height map.

Reflections & Refractions in Raytracing