Creating Ambient Occlusion with transparency texture– Tutorial

In my previous post Dissecting the mib_amb_occlusion node. I talked about using transparency in Ambient occlusion, but I didn’t really cover the subject of using texture with alpha and having that casing AO on the nearby object.

In this simple scene we have a texture file with alpha assigned to a separate geometry.

If we would to render, we get this result.

A regular AO pass would look something like so

This in theory is accurate, since ambient occlusion doesn’t recognize alpha in texture files.
To get around this limitation, we will be using the mib_fg_occlusion node found under Mental ray lights in the Hypershade (don’t ask me why it’s setting there)

Note: The mib_fg_occlusion node requires having Final Gather to be turned on.

Create a surface Shader and assign the  mib_fg_occlusion to it’s out color.
This Shader will act as the AO for the geometry without transparency.

Create another surface Shader that will be assigned to the transparency object.

Open the SG node of that new shader, under mental ray > custom shader and add mib_transparency node (found under mental ray Sample Compositing)
To get the AO to appear, we just need to add the same mib_fg_occlusion node to the Input of the mib_transparency.

Finally just add the mask of your texture file to the Trnsp slot of the mib_transparency.

To get a better render of our AO, we need to increase the FG settings.

Here is a screenshot for my shading network.

Recent Entries

19 Responses to “Creating Ambient Occlusion with transparency texture– Tutorial”

  1. mohamed wageeh Says:

    thanks ashraf very useful

  2. simha Says:

    ashraf , how about occulsion with bump and displacement maps !!

  3. Ashraf Says:

    Do you mean Transparency + disp + bump ?

  4. kezo Says:

    Hello,

    Thanks for the tutorial it works great except when trying to render more then one alpha object. Overlapping areas render black, any ideas on how to fix this? I tried increasing the Max Trace Depth in the render settings but i’m still geting black patches where the transparent polys overlap.

    Also when you connect the mib_tranparency node to the surface shader are connecting it to the Material Shader channel or the shadow shader channel?

    Thanks for your help.

  5. kezo Says:

    I was able to solve the overlapping by increasing the Raytracing “Refractions” and “Max Trace Depth” under the Quality Tab (not in the final gathering section) but now I can’t get the transparent polys to cast AO onto each other they only effect the object with the first surface shader.

  6. Jon Says:

    this is great, but can you publish an image of that shading network showing the exact connections? i’m missing something, thanks,

  7. Ashraf Says:

    Sorry, I meant the sun/sky connection that is made by pressing the button in the render settings ..simply because the camera lens shader that gets assigned.
    for a complete list please check here.
    http://forum.mentalimages.com/showthread.php?t=6584

  8. Jagdishwar Says:

    Hi Ashraf
    Thanks for this wonderful tutorial…. :)
    i have small query

    Is their any way to bake occlusion to texture by omitting the Alpha region ?

    for example for the low poly Game models where Alpha transparency plays a big role in adding details to the model, but at the time of baking occlusion to texture it will ignore the applied transparency to the plain and occludes the entire plain which actually is incorrect.

    is their any way to solve this problem ?

    Thanks

  9. siddesh Says:

    Hi…….

    Please send maya file to my mail ID

    regards
    Siddesh

  10. UltimateJim Says:

    Awesome tutorial!

    One thing though… I had to invert my colour values on my alphas (flip black/white) in order for the transparency to work with mib_transparency.

  11. SM Says:

    your tutorials are a bit hard to follow. You should make youtube videos :O

  12. cookie Says:

    Under custom shader of the SG group, where do I add the mib_transparency node?

  13. john syracopoulos Says:

    damn you Ash. I wish I had your MR experience. Thanx for the tut.

  14. Ashraf Says:

    Heheheh glad that you liked that trick :)

  15. anon Says:

    Under custom shader of the SG group, where do I add the mib_transparency node? not sure

  16. Ben Says:

    PLEASE ANSWER THIS QUESTION

    Under custom shader of the SG group, where do I add the mib_transparency node?

  17. roy Says:

    any chance of getting the transparency to work with the mia_material AO?

  18. James Says:

    Ashraf,

    Thanks for putting this tutorial together. I’m having some trouble implementing this solution. I have two render layers setup, one for color, one for ambiant occlusion. The AO layer seems to be locking all of the object into one shading group and I can’t seem to assign a second to the plane which I want to have the transparency on. Because I’m using the render layers, is this specific method not going to work?

    Also, I don’t seem to be able to get my shading network to match yours.

    I’m using Maya 2013 on Mac OSX 10.7.4

    Any help would be greatly appreciated!

    -James

  19. Susi Says:

    Can you send me the maya file please? I can’t figure it out why it doesn’t work in my scene :(
    best,
    Susi

Leave a Reply