RSS_Button

Ambient Occlusion – Using mib_amb_occlusion node



Occlusion is a fast and simple method to simulate the effects of global illumination. Ambient occlusion is most often calculated by casting rays in every direction from the surface. Rays which reach the background or “sky” increase the brightness of the surface, whereas a ray which hits any other object contributes no illumination. As a result, points surrounded by a large amount of geometry are rendered dark, where as points with little geometry on the visible hemisphere appear light. The soft appearance achieved by ambient occlusion alone is similar to the way an object appears on an overcast day. So what basically this shader does is try to re-create the effect of ambient occlussion. It is moderately low on render time, and has significant advantages in the final look of an image. The mib_amb_occlusion node come with a variety of attributes to customize the final rendered AO image.


Introduction


First off the ambient occlussion node is a mental ray node so, so u would require the mayatomr plugin to be enabled. The ambient occlusion node can be found in the Hypershade under Create > MentalRay Textures > mib_amb_occlusion.

occ_image_0

There are various ways to connect the mib_amb_occlusion node to the desired object.

1. The first is the preset that comes with maya`s render layer system, which makes a surface shader and connects the mib_amb_occlusion node to the surface shaders outColor.

occ_image_1
2. In this case one can connect the mib_amb_occlusion node`s outValue to the ambient or Incandescence of any desired shader. The connections are the same as above expect for the fact that u would not connect to outColor but to ambient or Incandescence.

3. One can also connect the mib_amb_occlusion node to the shading group of a material, the the shading groups attributes there will be a mental ray tab with a field called Material Shader.

occ_image_2

 


Samples


Controls the overall quality of the occlusion. Increasing the number of samples will reduce noise and give u a smoother render, the higher the number the more expensive the render cost. It quite easy to go overboard with this attribute, so know when to quit.

Default – 16

occ_image_3

 


Bright / Dark


These two sliders control the lightest/darkest color of the occlusion. It can work as a clamp to keep the black and white range under a limit or one can change the colors for other desired looks.

Default – White/Black

occ_image_4

 


Spread


Spread is the basic dropoff between the bright and the dark colors in the occlusion. A higher spread will require more samples.

Default – 0.800

occ_image_5

 


Max Distance


Max Distance is the how far a ray of occlusion will go in search of another object to occlude. Zero is basically all objects in infinity will occlude each other.

Default – 0.800

occ_image_6

 


Falloff


This attribute is only useable if the max distance is not equal to zero. It is basically how fast the occulussion effect with die out with have over the distance.

Default – 1

occ_image_7

 


Reflective


When turned on, the occlussion will reflect on surrounding objects. This is good when u have a lot of reflective objects in the scene.

Default – Off

occ_image_8

 


Output Mode


This consists of three modes, that defines what the returned color will be.

Default – 0

occ_image_9

 


Occlusion In Alpha


When turned on, the occlussion will show up in the alpha channel, For this to work u will have to use the 3rd step in connecting the shader to the ShadingGroup Node.
Turn on Pass Custom Alpha Channel  in the Render Settings > MentalRay Tab  > Under Custom Entities.

occ_image_10

 


Occlusion & Transparency


By default occlusion does not respect transparency, then if u need transparent objects to be occluded, u will need to connect the AO shader to the amient or incandescence.

occ_image_11

 


Extra Options


miLabel Attribute

For the next two options to work  i.e id_inclexcl and id_nonself, all your objects need to be assigned with id numbers, and these id numbers need to be added in a new attribute called miLabel. So for the below to options to work you will need to add an attribute to each and every geometry in the scene, and give it an id number.

occ_image_11 MEL SCRIPT

I have made a script for this purpose called crAssignID that lets u add the attribute and assign id numbers to a group of selected objects.
It has a couple of helpful options and can be found below, or looking into the scripts section of this blog.

http://www.artbycrunk.com/script/maya/scripts-crassignid/

id_inclexcl

This is basically an include/exclude from occlusion.
0 means that this attribute will have no effect. Same value as the miLabel means that only those objects can cause occlusion.
A Negative value of the miLabel means that those objects will not cause any occlusion.

id_nonself

This is basically an self or non self occlussion option again
0 means this attribute will have no effect. Same value as the miLabel means that those object will not self occlude.

occ_image_12

This is difficult to explain how these two attributes really works, you will just need to try it out yourself. If u have any problems please leave a comment 🙂



Most Related Posts





  • francesco says:
    (April 7, 2009 at 1:31 pm)

    That’s a tutorial! The best on the net! Thanks…

  • umesh says:
    (June 20, 2009 at 2:10 am)

    nyc R&D 😀

  • jitendra jamodkar says:
    (July 1, 2009 at 4:55 pm)

    above tutoial is good
    but i have tips and tricks lighting as well as
    assignement how i can do best of best work

    ok thank u

  • Vishal says:
    (September 12, 2009 at 1:48 pm)

    Hi! Crunk,

    thanks for such a wonderful tutorial on AO

  • Mike says:
    (December 14, 2009 at 2:04 am)

    One of the best ambient oclusion tutorials i’ve ever seen.
    Thanks for share.

  • Drew says:
    (January 7, 2010 at 3:45 am)

    Word. Thanks a bunch for this simple guide to MentalRay Ambient Occlusion in Maya. (there are some keywords for google to crawl.)

  • Choo says:
    (February 19, 2010 at 12:53 pm)

    Hey Crunk
    I’m an architecture student who’s new to Maya.

    Just wanted to say that all your tutorials rock and are super helpfull.

    You’re awsome keep it up

  • imrankhan says:
    (March 8, 2010 at 12:24 am)

    It is a very very nice aoc tutorial and i will be very helpful for me in lighting thanks a lot….. 🙂

  • wenchi says:
    (April 26, 2010 at 8:39 pm)

    wow~this is what i need
    thanks for your tutorial,
    this really helps me a a lot!!

  • zark son says:
    (June 27, 2010 at 10:31 pm)

    that is a good understanding for the occusion ~thx ~

  • dragon says:
    (September 14, 2010 at 5:03 pm)

    hey good one mate! this the best one around :silly:
    hope to c something on motion vector soon :whistle:

  • Sridhar says:
    (September 15, 2010 at 11:38 am)

    Nice Documentation,Thanks for Sharing 🙂

  • Arif says:
    (March 28, 2011 at 11:56 pm)

    good job, its much faster then preset occlusion in maya

  • Michael says:
    (June 9, 2011 at 7:41 am)

    So when your rendering something that has glass involved (say a kitchen with glass hanging lamps or windows) you would want to exclude those object with the miLabel?

    • Crunk says:
      (June 10, 2011 at 2:21 pm)

      yes you would want to exclude all glass objects using the miLabel.. or if u wanted a more realistic effect you could create another shader just for those glass objects and use transparency based occlussion with it. 🙂

  • Michael says:
    (June 11, 2011 at 6:43 am)

    Crunk, you mention creating another shader for my glass. Im not sure i understand you. How do you go about doing that?
    (thanks for the prompt reply)

  • Michael says:
    (June 11, 2011 at 6:59 am)

    Sorry to post again, i tried deleting or editing the last one. Do i just create a lambert material and connect the AO into the ambient or incand.?

    • Crunk says:
      (June 12, 2011 at 12:33 am)

      yes u make a new lambert, and connect the AO shader into the ambient or incand or even the color channel.. and change the transparency value to what is needed.

  • tinyant says:
    (August 1, 2011 at 12:12 am)

    Hi, Thanks for the script, I have a question, how do i include more one object ID to the mib_amb_occlusion’s ID inclexcl & id nonself.
    Assuming i have 3 objects, ID: 1, 2, 3. I wish to have ID 1 & 2 to the Id nonself.

    • Crunk says:
      (August 12, 2011 at 9:19 pm)

      hi, currently i don’t know of any out of the box solution that can do multiple objectIDs, what you could do is make a new render layer.. and do a layer override on the mi-label attribute.. then ad this new id to the Id nonself.

  • sikkandar says:
    (August 11, 2011 at 5:21 pm)

    i dont know how to download these tutorials so plese tell me how to download these video tutorials

    • Crunk says:
      (August 12, 2011 at 9:23 pm)

      hi sikkandar, there are no downloadable videos for this tutorial, you can shoot me a comment specific to the problem… 🙂

  • Sebastian says:
    (October 5, 2011 at 5:20 pm)

    Hi can U please show me how to make this transparent oclusion. I am using it in seperate layer and the combine it in photoshop.

  • JgNeoN says:
    (February 23, 2012 at 6:35 pm)

    hey crunk, thats a great tutorial !!
    I like your wire render toon , too !!!
    Thank’s

  • Mayatutorial says:
    (March 12, 2012 at 4:40 pm)

    Thanks for the tutorial, I’ve post the tutorial and link it to your site.

    http://mayatutorial.net

    Thanks

  • V1 says:
    (March 16, 2012 at 1:41 am)

    Couldn’t get this to work,. when i found a other tutoriol telling me to set the background to white and turn on lancos in mental-ray render settings 😉
    Now it works 🙂

  • Josh Evans says:
    (March 11, 2013 at 3:07 pm)

    This is a great resource, thanks for being so thorough!

  • Julie says:
    (March 18, 2015 at 9:57 am)

    Years later this is still one of the best tuts on AO, I did have a question tho. When rendering an interior scene (4 walls no roof), I’ve futzed with the settings every which way and with the max distance either at 0.00 … everything comes out WAY to dark grey… or a max distance of anywhere between .01 to 50 everything is just way too bright white. How do i find a happy middle for interiors? My AOs come out perfect until I throw up 4 walls 😛 Thank you in advance for any help you might have.