Here are a set of Python scripts that I have been developing to automate common rendering and lighting tasks in mental ray for Maya. Eventually, they will allow you to set up ambient occlusion with one click, set up and adjust a depth pass, generate command line rendering syntax through a GUI, add/adjust lights, and provide a set of buttons to easily set up test renders.


Download the scripts on GitHub. Learn how to add external Python scripts to your shelf here.


Or view a video tutorial about how to set up the Ambient Occlusion script in Maya here: /blog/importing-and-running-external-python-scripts-maya-2011-video.

Ambient Occlusion

If you run this script, you will be presented with a window to add and adjust ambient occlusion settings using the mib_ambient_occlusion surface shader. An explanation of what is going on behind the scenes and what parameters to adjust can be found here. If you are happy with the default settings you can run the script and choose, 'Add Ambient Occlusion'. The script will select all your objects and create a new ambient occlusion shader and a new render layer. It will set up some default render settings and attach the shader to all the objects in your scene. If you add more objects to the scene or want to adjust the ambient occlusion settings, simply run the script again and choose 'Update Objects/Settings'. This works best if you have not set up any ambient occlusion render layers or shaders prior to using the script.

Batch Render Commands

You can launch this script and choose various parameters from your scene and it will automatically generate the correct syntax to render via the command line. You can choose various settings in the fields and drop-downs, then press the 'Append Command' button to add the render command to the text area. You can change the values and press 'Append Command' again to generate multiple rendering jobs (for multiple render layers, resolutions or file formats for example). Then you can press 'Save Script' to save the file as a shell script to the data folder of your project directory. These commands work best when you have a project set for your scene in Maya. For more information on rendering via the command line check out this blog post.


The new update adds the script for adding and editing lights in your scene. When launched it automatically lists all the lights in your scene in rows and allows you to edit individual light's attributes. Learn more about it and check out a screenshot here.