Wednesday, May 2, 2012

Rayleigh scattering and Mie scattering in Maya

Rayleigh scattering and Mie scattering are the main reasons why the sky is blue and the fog is white.
Depending upon the size of the particles that the sun ray hits, the color and the directionality of the scattering vary.
If the particles are as tiny as air molecules and therefore smaller than the wavelength of the sun ray, the sun ray is scattered into every direction. In this case, the shorter wavelengths like blue and violet start to scatter first. That's why the sky is blue. But when the sun is low in altitude and has to travel the thicker atmosphere, virtually all the blue is scattered already and the remaining red is also scattered. That's why the sunset sky turns red. Therefore, the behavior is spectrally selective.
In contrast, Mie scattering occurs for larger particles like water droplets. In this case, the scattering is directional and not spectrally selective. so Mie scattering creates mainly white color and tend to look like a halo around the sun or the light sources.

These two natural phenomena are implemented in Maya's physical fog.
Here's a render of a terrain with no atmospheric effect at all.

No matter how gigantic the terrain, it's hard to feel the magnitude of it.
I'll add an environment fog node to the scene. By default the environment node resides in the Maya software render settings, under render options
Once you create the node, mental ray will respect it in rendering

When the Physical type is set to Sky, this works as the combination of Rayleigh and Mie scattering.
Fog is Mie and Air is Rayleigh. You can control both individually.
First, I turn off the Fog by setting the Fog Density to zero. With the Air only, below is the result.
It clearly show the blue sky only.

Not only you can see the sky but also the blue-tinted faraway terrain around the horizon.
This is what's called aerial perspective (or atmospheric perspective). This is one of the essential elements that makes the outdoor scenery looks realistic and natural.

Now I turn on the Fog by raising the fog density.

with the addition of the fog, the terrain near the horizon becomes more desaturated.
Since the fog is sensitive to the direction of the sun, there are controls for the sun's position.

At the Sun Azimuth of zero, the sun is in line with the Z axis. Since the current camera is pointing the Z-direction, the following adjustment will reveal the sun.
I adjust the Fog Light Scatter attribute to a lower value like 0.2. This gives the fog scattering more directionality. ( higher value makes the scattering more uniform )

Here's the result. You can see the white halo forming around the sun.

If you use a very small number like 0.01 for the Fog Light Scatter, you may get a sun like shape like below.

This is an extreme case of back-lit fog.

In conclusion, you may want to use the Mental ray's physical sun and sky for the environment solution but it lacks atmospheric effects such as aerial perspective. On the other hand, Maya's physical fog is not an illumination source like MR's physical sun and sky. So these two features are complementary to each other.


No comments:

Post a Comment