Monday, August 31, 2009

Maya Ambient Occlusion tips

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.

Id Inclexcl: 0 Id Nonself: 0
(both feature disabled)

Id Inclexcl: 2 Id Nonself: 0
(include only objects with id 2)

Id Inclexcl: -2 Id Nonself: 0
(Exclude objects with id 2)

Id Inclexcl: 0 Id Nonself: 2
(Objects with id 2 do not cast AO on themself)

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 for pointing this out to me.


  1. hi sylvain, here is some more data on maya occ my blog :)

  2. really good breakout of the AO node ... good job.


Note: Only a member of this blog may post a comment.