Back to Teaching Homepage

Generating Fog in Mental Ray for Maya:

The Purpose of this demo is to provide context and a how-to for creating Light Fog using Mental Ray in Maya. Belive it or not, its not all that hard!
First off, the problem. Many students are used to creating light fog by attaching fog to their spotlight or volume light. While this does generate a cone of light beams, it isn't physically realistic, and more importantly, this effect can't be used in mental ray. So if you wanted to combine this effect with GI, FG, AO, or any of the other advaced rendering techiniques, you'd be out of luck.

So Mental Ray has it's own system. Lets examine it. First off, here is the scene that I have built. Its an alleyway. There are 2 lights in the scene currently, Spotlight1 (which we will discuss in more detail in a minute) and Pointlight1. Pointlight1 is just a simple pointlight which I have colored a dark purple. It has a low intensity, a linear decay, is positioned BEHIND the camera (so it doesn't create a glowing orb in the field of view) and it has no shadows. I have also created a Bounding Box around the scene. This will be examined more in a minute as well. Lastly, I have created a camera for rendering, and made sure that it is INSIDE THE BOUNDING BOX.

Lets take a look at Spotlight1, its the important one here. The only real thing I've done to it is I have enabled Depth Map Shadows. Now, you can use Raytrace shadows, and they will cast accurate shadows in the scene from the light as it hits physical objects, BUT depth map shadows are needed to accurately calculate the path of the light as it moves through the air. I have upped the resolution to 1024 and the Filter Size to 3, which will create a smoother (less noisy) fog-shadow.

In the render settings window, I have gone into Features-Extra Features and enabled "Auto Volume" and upped the Volume Samples to the shown amount. This will also help create a smoother shadow in the fog.

Next, I need to create the fog itself. First I create a Transmat Material (found in the Mental Ray Materials section), then I create a Parti_Volume material as well. You can see what both of these materials look like here in the image below:

Next I will apply the Transmat material to the Bounding Box around the scene. I will also make sure that in the render stats "cast shadows" and "receive shadows" are set to off. The transmat material plus these setting will make the box itself essentially invisible. It is just there, like the glass walls of a fishtank, to hold the medium inside, in this case: fog.

I then enter the shading Group node of the Transmat material and hook up the parti_volume material into the Volume Material section.

You have to make sure that the scatter amount is turned up (as seen below). Also notice that I have given it a faint brown/yellow color. In my scene, the spotlight itself is white, the color of the fog is taken from this value. You can also edit the height value (currently at zero) if you desire to pin the fog to the ground for instance.

And... thats it! just render and enjoy the volume fog.

 

RETURN TO TOP