Mental ray volumetric shadows with parti volume in Maya

From CGNotebook

Jump to: navigation, search


parti_volume volumetric shadows in mental ray for Maya

Crepuscular rays at sunset

This tutorial explains how to create volumetric shadows in haze or fog using the parti_volume mental ray render node. Of course, it'll only render in mental ray! This technique can be used to simulate "God-Rays", technically known as Crepuscular Rays, as seen in the thumbnail on the right.

Demonstration Scene for Download

This tutorial will go through some simple steps to set up this kind of effect using a demonstration scene. Click Here to download the example scene and follow along. It includes a final version of the scene so you can double-check your settings.

An alternative approach to this technique uses d-map shadows and volume primitives. - This technique usually renders faster but is less accurate and lower quality.

1. Add a Light and set Trace Depth attributes

Of course, the first step is to add a light to the scene, if none are present already. A directional light will work best in this instance, as it most closely represents the Sun.

In the attribute editor for the directional light shape, scroll to the Raytrace Shadow Attributes. Enable Use Ray Trace Shadows and set the Ray Depth Limit to at least 5.

Enable the mental ray plugin, if it isn't already running. From your render settings, make sure mental ray is set to be the current renderer, by selecting it from the "Render Using" combo-box at the top of the render settings window.

Under the Quality tab, make sure raytracing is turned on, and that the shadow trace depth is at least 5. If it's any less, the shadows won't trace deep enough through the volume and therefore won't render.

2. Enable Auto Volume

In the render settings window, switch the to features tab, under extra features, enable auto volume, and set the volume samples to 10, to begin with.

3. Fit a Polygon Primitive around your scene

Create a new Polygon Primitive and fit it around your scene, or wherever it is that you need the fog or haze to appear.

4. Make a new Lambert Material and MR nodes

Make a new Lambert Material and assign it to your polygon primitive.

With the new Lambert created, graph its input and output connections in the work area. Switch the set of render nodes to Create mental ray Nodes.

From Materials, middle-mouse button drag a transmat over next to the new Lambert in the work area.

From Volumetric Materials, middle-mouse button drag in a parti_volume too.

5. Connect up the Shader Network

Select the Shading Group for the new Lambert in the work area and press control+a to open the Attribute Editor. Arrange your windows so you can see both your work area with your new Render Nodes and the Attribute Editor at the same time.

Make sure you're on the tab for the shading group (lambertxxSG) in the Attribute Editor and open up the menu sets for mental ray and then Custom Shaders.

Middle mouse button drag your transmat from the Hypershade work area into the channel slots for both Material Shader and Shadow Shader in the Custom Shaders section in the Attribute Editor.

Now middle mouse button drag your parti_volume from the Hypershade work area into the channel slot for the Volume Shader.

The transmat is responsible for making the surface of your stand-in primitive transparent, and to stop the surface itself from casting shadows. If you simply suppress the maya shaders instead, Maya will ignore the whole object when it goes to render it - so make sure you don't check that flag. The parti_volume is responsible for creating the atmospheric effect inside the primitive.

6. Connect the Lights to the parti_volume

Select the parti_volume node in the Hypershade work area to bring up its attributes in the Attribute Editor.

Now in the Attribute Editor, open up the Light Linking menu set, then Lights. Leaving the lights[0] channel slot visible, switch to the Lights Tab in the Hypershade window.

In the same fashion as the previous step, middle mouse button drag your Light icon from the Lights Tab into the lights[0] channel slot in the Attribute Editor. If you need to connect more lights, refresh the Attribute Editor and another slot will appear.

The setup will work without explicitly connecting your lights to the parti_volume, but it's better to be sure...

7. Tweak the Shading Network


The final step is to tweak the parti_volume node to make the volume material actually respond to light. At the very least, turn up the Scatter attribute. For more information on tweaking the parti_volume node, click here.

A Note re: Photons!

In its current form, this setup won't allow photons to enter the volume. If you do need photons coming in from your light, follow the steps at the end of this tutorial to add a transmat_photon to your Photon Shader slot.

Personal tools
Google AdSense
please help us grow!