I have been working on a new script for some time now, and it’s finally ready to be shared!
The script is called Effect ID Changer, and like my other scripts, it does exactly what it says on the tin!
First, you’ll need to download the script from here.
Before installing the script, open the script in notepad or similar, and read the notes / disclaimer / credits at the top of the script. If you are unsure about using this script, or unsure as to it’s effect, please do not use it. Also, always test this script on none important and none production work before including it into your workflow. Sorry to be pessimistic, I just have to cover my own arse sometimes!!
Anyway, to install the script in 3Ds Max by going to MAXScript, Run Script. Once you have done that, assign it to your UI. I personally prefer to add it to my tool bar for quick access.
If you then open the script, you will see the interface –
You will see there are 30 mask buttons, well 31 if you include the reset button, and two buttons at the bottom, which I will explain in a bit.
Firstly, let me explain what this script does. In Vray 2.2 (possibly earlier versions too), in the vray
materials, options, there is a tick box called “Override material effect ID” and the Effect ID value is greyed out. By ticking this box, and changing the ID number, you can generate masks at render time by adding the MultiMatteElement to your render elements passes.
This script automates this process, and makes the task very quick and very efficient. It might sound a little complex, but bare with me! This script removes the need to have a wire colour pass, or the need to generate mask after the rendering is complete, thus saving quite a chunk of time, and we all know how unreliable the wire colour pass can be. Also the wire colour pass will only give you a selection of an object, not the material. For example a car has many materials, and if the car is one collapsed mesh, the wire colour pass will only allow you to select the car as a whole, where as with this script you can give the glass, paint work, tyres, etc all different masks, even for collapsed meshes!
The key thing to remember when using this script is is that it works on a material level, not a object level. If you have two different objects with the same material, they will appear on the same mask. This is my preferred way of working, as it makes sense to adjust the materials rather than the objects. You can have more than 1 material on a mask, for example you might have the grass and roof tiles on the same mask, as you know the grass and roof tiles will never overlap (OK maybe on aerial shots!), but you get the idea, right?
OK so that’s the principles behind the script, but how does it work? Simple, select the object that has a material that you wish to mask, and click on the mask slot / button that you would like to use. The script will find the vray material, even if it’s inside multi sub, blend, two sided, etc and change it’s ID.
The only slight downside to this is that if you have a multi sub material, such as a car, when you click for example on mask 10, all the vray materials inside the multi sub material will change to ID 10. Sadly the only way to control this is to manually edit the vray materials inside the multi sub material to a different ID.
And now for the really good part. I bet some of you are wondering how on earth you keep track of the masks you have just assigned. Well this script has a little trick up it’s sleeve. If you right click on a mask button, you can edit the text!
This script also saves the button text when you close the script window, and saves the data to a .ini file inside your 3Ds Max temp folder. On my PC it’s saved to c:\Users\Dean\AppData\Local\Autodesk\3dsMaxDesign\2012 – 64bit\enu\temp\ so as long as you installed 3Ds Max to the default location, the file should be stored here.
Knowing where this file is saved could be very important, if you change PCs just copy and paste this file and the script will read it. Also, if you are in a studio, and you want everyone to be using the same ID numbers for the same masks, you can drop this .ini file onto each users PC.
So now to the bottom two buttons. The Select Unassigned button simply selects objects that have materials applied to them that haven’t had any mask ID assigned to them. It’s just a pretty quick way to see what has and hasn’t been assigned a mask.
The + Render Elements button is the last part of this script, and this adds the correct render elements to your Render Elements tab in you render settings dialogue. Click this button once (clicking more than once will only add duplicates and is very pointless), and the script automatically creates 10 new render passes, and configures them to that when you render you image (or animation) the correct passes are rendered.
Each MultiMatteElement will contain 3 mask. MME1 contains mask 1,2,3, and when rendered mask 1 will appear as red, mask 2 as green, and mask 3 as blue. This is repeated through the other MultiMatteElements, thus having 30 masks in total.
So all that’s left to do now is to render your scene and open it up the RGB and MultiMatteElements in Photoshop. The easier way to extract each map from the MultiMatteElement is to hide the channels you don’t need, and simple select all , and copy.
Then paste the mask into your RGB file. You can then use this pass as a mask for any post-processing adjustments or masking.
As you can see here I used the mask as a Layer Mask to badly adjust the grass! You would then repeat the process for any mask.
I think that’s just about covered everything, and if there’s anything I’ve missed, or if you experience any bugs please let me know. Also it would be great if you do use it, and it works OK, please let me know which version of Max and Vray you are using.