Atmospheric Scattering

I’ve recently implemented a relatively simple atmospheric scattering simulation to my renderer. The color of the sky is due to the scattering of light by air molecules. Rayleigh scattering, which is caused by particles much smaller than the wavelengths of visible light, is responsible for the blue-ish color of the sky during the day and the red/orange color of the sky during the twilight hours.  Mie scattering on the other hand is caused by aerosols and is responsible for the “haze” of light that surrounds the sun. I use both Rayleigh and Mie scattering together in order to achieve the correct the effect.

The sky itself is modeled using a 6420 kilometer sphere encapsulating a 6360 kilometer sphere used to represent the earth. The camera is translated as to be on top of the earth, so if the user places the camera at one meter above the ground at Point(0,1,0) my renderer will actually position the camera at Point(0, 6360001, 0).

Since the density of the atmosphere changes with altitude, I use ray marching along the viewing ray to take this into account. Additionally, at each sample point along the viewing ray, I use ray marching along the line of sight from that point to the sun in order to calculate the amount of light that is attenuated due to scattering before reaching that point.

Here are some of my test results thus far:

 

Sky

 

Sunset

 

Rendering of the sky using atmospheric scattering with both rayleigh and mie scattering

Rendering of the sky using atmospheric scattering with both rayleigh and mie scattering

Fisheye view of sky looking directly at the zenith

Fisheye view of sky looking directly at the zenith. Same as above image.

Environment Map Image Based Lighting

I’ve recently been playing around with image based lighting, which is where an omnidirectional panoramic image is used as a spherical map at an “infinitely far distance” to light the synthetic objects in the scene.

Below you can see a few example renders I have done so far. Both scenes make use of a cathedral environment map – the first showcases a mirror and glass ball respectively and the second is a dispersive diamond.

There are still a few details that need to be worked out however. First, there are some bugs in my importance sampling algorithm which causes speckling on diffuse objects. Secondly, I am currently not taking advantage of the full high dynamic range of the environment map which is why my renderings may appear a bit washed out. Hopefully soon I will be able to save my renderings as HDR .exr files.

Cathedral_Image_Map

Cathedral_map_diamond