You may have notice 2 strange attributes in the mib_amb_occlusion texture in Maya Id Inclexcland Id Nonself.
If you look in at the mib_amb_occlusion docs in the mental ray documentations, you can see the description of those attributes.
So with these you can include or exclude objects with a given id... or even force given object to cast AO on other objects but themself... this looks cool! so what appends when you set a value in there? You lose the occlusion or there are no changes right?
That's because these values are mental ray ids and you need to assign a mental ray id to your objects ... but how can I do this do you ask?
You need to add an extra attributes named miLabel to the transform nodes of your objects and set the id in this miLabel attribute.
But I need to add this attribute on all my objects manually you ask again? of course not! Use this script (see the readme file in the zip for installation and usage)
Now you can take advantage of this feature!
In this example I have added the miLabel attribute to all the objects, I have set the miLabel of the ground plane to 1, the cube to 2 and the sphere to 3. All the obejcts are assign to the same constant shader using the mib_amb_occlusion texture as color.
Here are different results when setting each value in the mib_amb_occlusion texture.
Note that the use of the number 2 is arbitrary, I could have used 34 as my id on the cube and use 34 or -34 as a id value in the mib_amb_occlusion shader.
I hope this tips can help you achieve some tricky Ambient Occlusion renders.
I would like to thanks Daniel Kvasznicza http://www.inetgrafx.com for pointing this out to me.