Sunday, April 22, 2012

miLabel attribute to control ambient occlusion


Mental ray's ambient occlusion material doesn't respect transparency and this can create undesired occlusion for transparent materials like windows.
You can easily turn on and off AO for a certain object using miLabel attribute.
Let's look at the simple scene here.

  


 
All three objects in this scene are assigned with the same ambient occlusion material.
What if object#2 is a transparent object like window. If the window is transparent enough,  it should not cast that much occlusion on the floor.




As you can see in the image above, the window is casting unwanted occlusion onto the floor.

So I'm going to attach a new label attribute to the object#2. It will be used as some sort of an on-off switch.
Select the object#2 and open Add Attribute window. ( Modify>Add Attribute )



Type in miLabel  and select Integer like above and click OK.


 
You will see a new attribute named miLabe is added to the plane.
I set this value to 2.

 


 
Now open the attribute editor for occlusion material set "-2" for Id Inclexcl attribute.
This will prevent any object with miLabel value of 2 from casting occlusion.



Now we don't see the unwanted occlusion from the window any more.
While I'm at it, I find the occlusion at the corner of the wall is excessive.
I added miLabel attribute to the wall and set the value to 1.



 
Then I set Id Nonself to 1. This means that any objects with miLabel of 1 will not have a self-occlusion.
Now the self occlusion on the wall is gone.









No comments:

Post a Comment