Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This little utility script can make it a breeze to add a "Matte" render layer, with contribution maps for separate objects, so you have a single render layer that can generate an unlimited number of different mattes for every object in your scene. You don't have to deal with RGB colors or manually making contribution maps and render passes by yourself.
To use this script, just run it. It will show a simple window with a blank text box and a button. Then follow these steps:
1. Select the object(s) you want to have a separate matte for 2. Type a name for the matte into the text box 3. Click the "Make Pass" button 4. Repeat steps 1-3 for each matte you want to make
The script will create a render layer called "MATTE" if one does not exist. It will create a surface shader set to solid white and assign that shader as the override shader for the layer. It will generate the appropriate contribution map and render pass and do all of the associations for you, based on the name you supply. Objects can be in multiple matte passes with no problems.
Obviously this is designed around a mental ray workflow, because it uses contribution maps and render passes.
I hope you enjoy this. Please let me know if you have any issues with the script.