Here's is a little mel script which can be useful for people looking for a push-button solution to output arbitrary number of masks from unlimited number of objects or group of objects in their scene, all at once while rendering their beauty pass.
It use the Octane:LayerID attributes, the renderLayerMask pass, and non-invasive Maya render layers.
To use this script :
select one or several objects in the scene, change the octane: layerID in the channel box, from 1 to whatever number you want, select another objects and assign another layerID number to define another mask and so on.
Execute the script.
Batch render your scene.
n.b:
- If you don't want to use batch render but just render, make sure to enable "render all layers".
- if you only want to use IPR, just select the Maya render layer you want render.
- Maya default for name and location for render layer is to give the same file-name to all files but in a sub-folder with the layer name, to change that use the <renderLayer> token in the "filename attribute". e.g: