Continuing with our tutorial series, entitled “Steampunk Lab”, artist Aradhana Vaidya will be showing us how to use Mel scripts for fast interaction of complex light rigs.

The Steampunk Lab scene has been set up using 2 different light set ups, one setup for day light with the light coming from outside, and one setup for night time, interior lighting. Using a custom UI built using a Mel script and a single master slider, we can blend the balance between these two rigs. In the Visualizer viewport you’ll see an instant, fully-lit update as we scrub the slider value around.

Building a fast & simple visual UI to control this is possible only because of Visualizer’s instant rendering.

The main slider is created using a single floatSliderGroup control. As the value of the slider changes from 0 to 1, a Mel callback function updates several values in the scene simultaneously, namely:

* Exterior and Interior Light intensities
* Color gain on the Image Based Light or IBL, which is adding diffuse light to the scene
* The background image
* A so-called “practical source” light bulb material shader

To try it yourself, take a look at the example Maya scene and script which are available for download here.

In the scene, there is a point light and a light bulb. We are changing both the intensity of the Maya light, and the brightness of the light bulb’s material shader, driven by the master slider’s 0 to 1 value. The light intensity is driven using this mel command:

setAttr “DayLightShape.intensity” ($value * 2.2) ;

where “dollar value” contains the value returned by the master slider.

As you must have seen in a previous tutorial, the light bulb material shader is built using several ramp shader nodes and the color of the ramps can be changed by using a blendcolors node. Changing the blender value will blend between color1 and color2, or texture1 and texture2, if the texture is hooked up. So the blender value is also driven by the value of the slider, using this command:

setAttr “blendColors1.blender” $value;

You will see that the Visualizer instantly updates the entire fully-lit view as you make changes to the slider value. This fast approach is incredibly useful and can help you in your lighting or look development decisions, whether you’re working alone or discussing in real-time with your director or A.D.

I hope this tutorial inspires you to try something similar on your own. If you have any questions, please post them here and we will be happy to help.