Problem:
If you are like me and like to render everything in one go (not re-rendering a scene multiple times) AND want to have control in compositing, Object ID's are usually a good way to go. But they're not configurable (yet!... I hope ) so it presents some issues.
- Not being able to set the color of each objects ID means you sometimes get colors that are more difficult to use as masks (like faint colors or similar colors to objects nearby)
- Say you have 50 spheres and 50 cubes in a scene. In compositing you want to have one single mask for all the cubes. To do this you'll have to have a lot of patience to combine 50 of the different colored IDs into one.
Layer masks is an alternative (more commonly used) which works even better than Object ID's, UNLESS you have objects intersecting, in which case the mattes/masks will overlap in a way that they leave a blank/transparent space between them that's almost 1px wide. A workaround for this is to make one mask of the group of objects for cutting, and then multiple masks for individual objects in the group for editing (like color correcting and applying filters). But since there's no way to get all these mattes in one single render, this is not an option either!
Solution (I'm using C4D, but I imagine the solution is the same for all):
What I find works is using Render layer to isolate (cut out, if you will) a group of objects which you want to composite with a different background, and then use Render Layer ID info pass (as an alternative to Object ID info pass) to create masks for individual objects inside that group.
1. Enable Render layer with Active Layer set to 1 and tick the Invert box (important, will explain later).
2. Tick the Render Layer ID option under Info passes.
3. Add Object Tags to all objects in the scene.
4. Set the Layer ID in Object Tag of objects you want invisible to 1. This is usually some type of floor which catches shadows. Or maybe just other objects you don't want in the final render. Or if you don't have any other objects, just skip this step.
5. Set the Layer ID in Object Tag of objects you want to belong to one group of "Object ID's" a certain number above 1 (not 1).
6. Set the Layer ID in Object Tag of objects you want to belong to another group of "Object ID's" another number above 1 (not 1 or same as above).
Now with the Render Layer ID you should be able to see three (if you did step 4, otherwise 2) different colors in the Live Viewer. So we have our groups set for the "Object ID's", changing their color is done by simply changing their Layer ID in the Object Tags. So select all of the Object Tags of a group at once, and change the Layer ID to get a different color until you have one that's vivid and different from the others.
Good Layer IDs - UPDATED based on stratified's info below:
73 = Red
18 = Green
36 = Blue
45 = Magenta
54 = Cyan
27 = Yellowish
63 = As close to White as possible
64 = As close to Black as possible