Motion Graphics by Jeremy Clark

Lighting & Rendering

Custom Shaders in Mental Ray and Maya

My “Survival Horror” interior project is quickly becoming an exercise in new lighting techniques in Maya.

I have moved on to experiment with utilizing the Mental Ray renderer’s full funtionality within Maya – not just using it for the final renders of my scenes, but now also using Mental Ray specific Materials, Shaders and Over-rides in the attributes of the objects within my scene.

My first foray into increased Mental Ray implimentation was through using Custom Light and Lens shaders on the lights and cameras in my scene.

Mental Ray Light Shaders

It’s possible to replace the the standard Maya light shaders in a scene with Mental Ray ones. Mental Ray light shaders control light in a way that mimics real world lighting more closely than standard Maya lights.

(Left) A light with standard Maya light shader & (Right) A light source with a Mental Ray custom shader applied. Note the difference in dropoff around the light source.

In order to replace a standard light with a mental ray one:

1.) Open the attributes for any Maya light, and under the Mental Ray > Custom Shaders panels, select to input a new node in the “Light Shaders” box.

2.) With the “Create New Render Node” window open , select Mental Ray Lights > Physical Light.

3.) The original light’s attributes are now overridden by the newly created Mental Ray Light Shader. It is still possible to change the type of light (Spot, Point, Area etc) within the original light’s shape node. To make adjustments to the Mental Ray light’s intensity, dropoff etc, locate the “Physical_Light1” node’s attribute tab.

“Colour” controls both the colour and Intensity of the Mental Ray light. (Intensity set by altering the colour’s “Value” setting.) Increasing the “Threshold” value tightenes the area of darkness surrounding the Mental Ray light. If, for a large scene, an intensity of 1000 is till too dark, you can apply a Mib_Color_Cie_D node into the Colour input of your physical light. This will allow you to overdrive the intensity of the Physical light further.

Mental Ray Lens Shaders

Custom Mental Shaders can also be applied to Cameras to add greater contol to how your Maya scene’s virtual camera interprets light information. To apply a custom Lense Shader:

1.) Select your camera, and in it’s attribues tab go Mental Ray > Custom Shaders. Select to create a new render node next to the “Lesnse Shaders’ box.

2.) From the “Create Render Nodes” window, go Mental Ray Lenses > (Select desired MR Lense Shader).

An example of a useful Mental Ray Lense shader is the Mia_Exposure_Simple node. This node attaches to the camera and offers greater control over exposure, gamma, knee and other settings.

Another is the Mental Ray Bokeh Lens Shader. This is an alternative way to created depth of field in your renders.

This illustrates use of Mental Ray "Bokeh" custom lens shader. The Bokeh shader is a great way of achieving Depth of Field in a render.

 

Combining Custom Mental RayShaders

It’s also possible to combine custom shaders within a scene. That is, have a custom shader attached to a lens (Lens Shader), and another attached to a Material’s Surface Shader.

For example, by adding a Mental Ray Phsical Light node to a light source, and shine it through a volume that has a Mental Ray Material and Custom Shader Applied, we can achieve the appearance of light passing through “Participating Media”, or airborne particles.

An example of using both custom Mental Ray Light and Material Shaders to render "Participating Media" with a lightsource

One thing worth noting is that volumetric light effects take allot of time to render. For that reason it’s a good idea to utilize render layers, and separate the volumentric effects onto it’s own layer. This way you can isolate it and gain better control, without having to do lots of time consuming renders.

Another example of Volumetric Lighting through the use of Mental Ray Light and Material shaders. Here I rendered the volumetric effects on their own render layer and composited them back into the final image afterwards.


More Indirect Lighting In Maya – Caustics

Within my Film Noir Inspired Lounge scene I also set about learning how to render “Caustics” in Maya and Mental Ray.

“Caustic lighting” generally refers to the patterns of light that are formed when rays of light pass through a transparent material, and are refracted  in a way that patterns appear projected onto surrounding objects. Think of shining a light through a glass of water, and seeing the patterns of light that are produced on the table.

Within Maya, “Caustics” are considered a form of Indirect lighting, as they rely on the use of Global Illumination Photons. For this reason, the workflow for including Caustics in a scene is similar to that of enabling Global Illumination within a render.

Though somewhat straighforward to enable, caustics can be tricky to fine tune, and there are a number of variables that dictate their appearance and quality in a render. Here’s how I implimented them within my scene:

1.) Just like when setting up my Global Illumination lighting, I wanted to keep my Caustic Photon emmitting lights separate from my scene lights. For each light that I wished to appear as if casting the Caustics, I duplicated the light, dropped the cloned light’s “Intensity” to zero, and enabled “Emit Photons” under the new lights “Mental Ray –> Global Illumination and Caustics” attribute editor tab.

2.) Next I jumped into Maya’s “Render Sttings” tab and under the “Indirect Light” tab, I opened the”Caustics” tab and clicked to enable them.

3.) Now came the hard part – fine tuning them to achive a decent enough look. Key settings I tweaked included:

– From the Caustic Light’s shape node Attributes Editor  –> “Mental Ray” –> “Caustic and Global Illumination” dropdown: Photon Intensity (A lower than default value worked well here), “Caustic Photons” (I increaded the number of Photons by 10x the default here), and “Exponent” (I decreased the value from 2.0 to 1.5 here to increase the brightnes of my Caustics patterning.

– Under the “Render Settings” –>”Indirect Lighting” –> “Caustics” tab I set to lower the accuracy from 100 (Default) down to 40. Apparently decreasing the value here is better.

The following depicts two renders of the same lamp, one without , and one with Caustics enabled. Note the patterns formed by the light on the wall behind the glass of the lamp.

This shows a render of one of the lamps in my scene without Caustics enabled.

.. And this is the same lamp, rendered again but with Caustics eneabled.

Though in this scene the effects of Caustics appear somewhat minimal, I still wished to learn about how to use them for a greater understanding of how Indirect lighting works in Maya.


Global Illumination In Maya

My Introduction to Indirect Lighting

Continuing with my Survival-Horror inspired scene in Maya, I’ve started experimenting with different lighting techniques. Having up until this point only utilized simple direct lighting setups to light my scenes, I’ve now moved on to learn more about how to use “Indirect Lighting” to improve the look of my renders.

“Indirect Lighting” occurs when light that is emitted from a direct source (A “Light” in Maya, for example) bounces off of surfaces in the scene. It is from this behavior that this kind of light can also be referred to as “Secondary Light”.

When the light contacts a surface it can take colour from this surface along with it. This newly coloured “secondary” light then lights other objects in our scene.

Global Illumination

The first type of Indirect Lighting that I’ve started to play with in Maya is known as “Global Illumination”. Here light sources are created, and set to “Emit Photons”. These “Photons” travel from the light source and bounce around our scene just like light does in the real world.

It seems that Global Illumination works best if you separate the Direct and Indirect light sources within a scence. Leave the “Direct” lights to provide basic light on objects and cast the scene’s shadows,  and create seperate lights that will emit the Photons required for our Global Illumination.

Therefore we select our “Secondary Light” sources, set their standard “Intensity” to zero (So they do not cast any direct light), but enable “Emit Photons” instead.

Here are two renders of the same scene – one with Global Illumination enabled and one without.

Render withough Global Illumination - Relying only on direct scene lighting.

Render with Global Illumination enabled