In this tutorial we will be learning how to render volumetric effects using Mental Ray. In particular, we will be using Mental Ray’s Parti-Volume shader to create volumetric light effects like light fog in our scene, and the Parti-Volume Photon shader for volumetric caustics.
The scene we'll be using consists of a simple hallway with some windows. We will be rendering the effect of light fog shining into the hallway, as when seen from inside.
To get started. our first goal is to assign some basic materials to the scene. We will assign a simple colored material to the hallway, and a Mental Ray Arch & Design material will serve this purpose.
We are now going create a Spotlight that is going to illuminate the scene. We will be using a spotlight because a spotlight can help us direct the photons exactly where we want to, unlike a Point Light or Directional Light, which emits photons in all directions.
We are going to direct the Spotlight so that it points through one of the windows as shown below.
We will turn on Ray Traced Shadows for this light and we are also going to set the Multiplier to 10, to brighten up the scene a bit. We are going to set the light to emit photons for our caustics effect that we will be generating later.
To do this, Right Click on the light and go to Object Properties > Mental Ray tab and check on the Generate Caustics option.
Next we are going to set some rendering options, like changing the renderer to Mental Ray and assigning a volume shader to the scene. To set the renderer to Mental Ray, Press F10 to go to the Rendering Options and then go to the Assign Renderer rollout and change the Production renderer to Mental Ray.
Next go to the Renderer tab and scroll down to the Camera Shaders section inside the Camera Effects rollout, and assign a Parti Volume shader to the Volume slot. This will be the volumetric shader that shades the light's fog effect. We will be tweaking the shader a little later.
Now Let’s turn on global illumination for our scene. We are doing so because our hallway is going to have only one light source and if we do not have the light bounce off the walls, we will have a dark room. To turn on global illumination, press F10 to go to the Render Setup and go to the Indirect illumination tab to Enable Global Illumination.
We are also going to increase the number of emitted Caustic and GI Photons to 200000. This way we will have much more detailed lighting in our setup.
Let’s give the scene a quick render to test out our setup so far.
As we can see above, we can definitely see the light fog, but the effect is too strong. Now is the time to tweak the Parti-Volume shader to get our desired effect. Let’s now take a look at the various settings in the Parti-Volume shader that we can use to our advantage.
We will just take a look at the most important parameters in the shader.
Scatter color: Denotes the color of the light fog. Keep in mind that the fog color is independent of the Spotlight's color. So if you change the color of the spotlight, keep in mind that you need to match it with the Scatter Color. In our case we will leave it at the default white color.
Another important use of the scatter color is that we can use it to control the intensity of the fog by adjusting the whiteness of the color. Since our current setup has a very intense fog effect, we can decrease it to something more manageable like 0.235.
Extinction: This parameter controls the intensity of the fog effect. It denotes the amount of scattering the light undergoes when travelling through the environment. Let’s reduce this to something like 0.02 and give it a quick test render.
r,g1,g2: These three parameters are jointly used to denote the type of scattering that we need. It denotes whether we need an isotropic scattering or forward or backward scattering. This has to deal with whether the particles in the environment scatter the light to the front of them, behind them, or evenly in all directions. Some preset combinations are shown below:
The differences between the scattering types are subtle, but can clearly be seen by comparing the various scattering modes in the Ram player.
Non Uniform: This parameter can be used to introduce cloudy effects into the light's fog. A value like 1 produces a non-uniform, cloudy shading, while 0 produces a uniform fog effect.
Use this parameter with caution since it can directly affect rendering times. You might also not want to overdo the effect (like in the image below), where the parameter is set to 1, just for exaggeration.
Height: This parameter is used for simulating ground fog effects and can be activated by setting the Mode to Fill Only Below Height. It can be used to shade the light's fog only below a certain height.
Minimum and Maximum Step Distance: This parameter controls the accuracy with which the scattering is shaded. Smaller numbers mean more accurate shading at the cost of rendering time, while larger numbers can speed up rendering but can introduce some artifacts. Play with the values until you get the right amount for your setup. A rule of thumb is to set the Minimum Distance to be 10% of the Maximum Distance.
We can also specify which lights need to be volumetrically shaded using the Lights option. But since our scene has only one light, we will leave it at the defaults.
Up until now we have seen how we can shade light fog in Mental Ray. Now let’s see how we can use the same Parti-Volume shader to shade the photons and get volume caustics.
Creating Volume caustics effects
To create volume caustics, we need a particular setup that shades the caustic photons into our scene.
The following setup shows how it’s done.
First let's turn on Caustics in the Mental Ray setup by going to the Render Setup dialog by pressing F10 and navigating to the Caustics section in the Indirect Illumination tab. Turn on caustics by checking the Enable box to have caustics generated in our scene.
For volume caustics, we need a spotlight that generates photons. These photons pass through the photon collector which specifies which photons need to be shaded for the volumetric effects. These to be shaded photons, now pass through the object that generates the caustics and finally get shaded volumetrically. Let’s see how we can model this setup in 3ds Max.
For the photon collector we are going to use a simple Plane and a Mental Ray material, so that we can customize the material according to our needs. In this case we are going to use it to just shade the photons. Let’s see how to do that below.
As you can see, I have assigned a Transmat material to the Surface, Shadow and Photon components of the shader. A Transmat shader is nothing more than a dummy shader that tells the main Mental Ray shader to do nothing for the specified component. So we are not going to render the surface, shadow, nor any photons from the photon collector Plane. It’s just going to be a plane that shades the caustics photons that are going to be generated. And as for the Photon Volume, we assign a Parti-Volume Photon shader which is just a Parti-Volume shader designed for photons.
Also make sure that you turn Off the shadows for the photon collector Plane, since we do not need it to cast any shadows onto the scene.
We are going to use a Raytrace material for the glass Sphere that is going to cast the caustics. We are going to set it to be completely transparent and give it some Reflection. The Specular Highlight profile can also be changed to get a more controlled reflection on the Sphere.
Down in the Mental Ray Connections for the shader, we are going to assign a DGS Material Photon shader. This gives the Sphere a volume in which the photons can get refracted and generate the caustics effect.
Also make sure to check the Generate Caustics checkbox for the Plane and the Sphere in the Object Properties dialog. Now render the scene. Here I have reduced the Scatter Color of the light fog to bring out the caustics effect.
In the above image we can see that the color of the volume caustics is white (same as the Spotlight's color). But we can change the color of the volume caustics in a total of two ways.
Change the light color of the Spotlight
Change the Scatter Color of the photon volume shader on the photon collector.
Changing the Scatter Color changes the entire caustic simulation's color and hence diffuses the green color more into the environment. But it does not affect the environment color, since the scene is still lit by the white spotlight.
Changing the Spotlight's Color changes the entire color of the scene and also the caustics effect. But it has a much tighter diffusion of color. Keep in mind that the light fog is still white since it is independent of the Spotlight color, and is instead dependent on the Scatter Color of the Parti-Volume shader.
Using the above setup we can easily introduce volumetric effects into our scenes to improve the realism and also give some scenes that wow factor using light fog. Hope you guys learned something new from this tutorial. And I hope to see you again in another exciting tutorial!