sam wirch

Simple Ambient Occlusion Render in Maya 2012

Posted In: 
Maya

Similar to my previous post on creating a multi-pass render from Maya 2011, this technique deals with creating a plain and simple ambient occlusion render in Maya 2012 (although the same technique works with Maya 2011 and Maya 2009). This technique is different in that you will only render out the Ambient Occlusion image, rather than all the separate layers of the image.

UPDATE

Check out this blog post about automatically adding and adjusting Ambient Occlusion, or head on over to GitHub to download my rendering and lighting Python scripts for Maya.

UPDATE

Or check out a video tutorial about setting up a script to automatically add Ambient Occlusion here: http://www.samwirch.com/blog/importing-and-running-external-python-scripts-maya-2011-video.

1.

Start by selecting all the objects in your scene that you want to appear in the ambient occlusion render. If you right click in an empty part of the scene, the fly out menu will let you choose Select All. Do this if you want all of your objects in your scene to render with ambient occlusion.

Select All

2.

Make sure the Channel Box / Layer Editor tab is selected and choose the Render layers tab.

Render Layers Tab

3.

From the Layers drop down menu, select Create Layer from Selected.

Create Layer from Selected

4.

This will create layer1. You can rename this layer to AmbientOcclusion if you want to keep your scene nice and tidy, otherwise select the layer, right click on the layer name and then choose Attributes.

5.

Make sure the name of the layer is highlighted in the attributes panel and click on the Presets button. From the dropdown menu, choose Occlusion.

Presets - Occlusion

6.

This will set up your render layer to the ambient occlusion preset and attach an ambient occlusion surface shader to all of your objects. Note - all of the objects in your scene will have a black shader applied to them.

7.

If you choose the mib_amb_occlusion tab when one of your objects is selected (or choose the surfaceShader from the HyperShade) you will be able to adjust the parameters of the ambient occlusion. The most important attributes are Samples, Spread and Max Distance.

mib_amb_occlusion

8.

Increasing the number of samples will make the render less grainy, but will make the render times longer.

Samples Comparison

9.

Spread defines how wide of an angle is used to calculate the occlusion on a point. In practical use it is kind of similar to contrast. Low values of Spread will generally make a harsher transition from black to white, while higher values of Spread will generally make a more gradual transition.

Spread Comparison

10.

Max Distance defines the maximum distance for which occlusion is calculated (Maya Documentation). This number will vary depending on the scale of your scene, but a Maximum Distance of 0 will sample the entire scene and is generally the preferred way to render Ambient Occlusion. If you choose a Maximum Distance of 0, the occlusion is calculated based on the entire scene.

Max Distance Comparison

Comments

Submitted by Kyle Horne on
Thanks a lot I've used a very similar technique for the AO generation its super fast and easy, I don't have to set up lights which is nice.

Submitted by Nataly on
SO USEFULL TUTORIAL!!! Thanks!

Submitted by Anonymous on
Mil gracias!

Submitted by Luxx on
Hi there, I wanted to know how you get the black in the background to white? When I go the cam and put the environment with it doesn't work (maybe because my scene has physical sun and sky)? Normally I made a separate layer and did it the old way and made a layer override but takes longer to render, doesn't it?

Submitted by Sam on
The easiest way might be to render out the alpha channel and then composite a white background in Photoshop or a video compositing program after you render.

Submitted by Lucas on

Create a camera. Go to environment set the background to white. Hold space to open the hotbox, press panels, go to perspective, click camera1 (or what ever camera you just set up) then render.

Submitted by daus on

hi there! I got stuck at step 5. When I press the "preset" button, I can't find the Occlusion. In the presets, there are only luminance depth, geometry depth, diffuse, specular, and shadow. Please help me!
ps: I'm using maya 2013

Submitted by Sam on
They changed the way mental ray is integrated with Maya in Maya 2013. If you don't see an option for Occlusion in the presets dropdown, go to Window > Settings/Preferences > Plug-in Manager, scroll to the bottom and make sure Mayatomr.bundle is loaded.

Submitted by rraallvv on

It doesn't work, mental ray is loaded but the presets are gone

Submitted by Nicolas Oyarzun on

hi, i wonder if you know how to solve this problem, in the render layer i click the render all layers option and put the ao in multiply mode but all the border came out jagged, how can i fix this?? thanks!

Submitted by Sam on
It's hard to say without seeing the scene. You might want to check the quality tab of the render settings for your AO layer and make sure it has high enough anti-aliasing settings. Does the problem happen if you render separate layers and comp them together in an image/video editing program?

Submitted by evilmonkeyy on

I've been struggling to to integrate materials with alphas into the AO. So far the closest to a solution that I've been able to find is making:
a custom mia material and
plugging the alpha data into advanced -> cutout
color
surface shader
AO

its been rather touchy, so I'm looking for better solutions.

Submitted by Sam on
Because of the way Ambient Occlusion is generated, it probably won't work well with alpha maps/transparency. You could either exclude the object from the AO layer, so it doesn't get calculated, or you might be able to try some of the suggestions here: http://forums.cgsociety.org/archive/index.php/t-995792.html

Submitted by Mikey Dee on

HOW THE HECK DO YOU GET THE AO PASS TO RENDER WITHOUT SHOWING THE WHITE GEOMETRY BUT RATHER JUST THE SHADED AREAS, WITH AN ALPHA CHANNEL INSTEAD OF WHITE. OMG THIS IS THE MOST FRUSTRATING THING TO FIND AN ANSWER FOR!!!!!!!!!!!!!!!!!! PLEASE HELP GUYS!!!!!!!!

Submitted by Sam on
What are you trying to accomplish? If you want to composite the AO pass on top of your beauty render, you could place the AO pass on the layer above the beauty pass layer in Photoshop and set the AO layer's Blending Mode to Multiply.

Submitted by Ilse on

There are no options under "presets". I looked at Window > Settings/Preferences > Plug-in Manager and Mayatomr.bundle is loaded. Still occlusion is no option under presets. I have Maya 2013. How can I solve this problem?

Submitted by Sam on
They should show up even if you are on Maya 2013. Make sure the correct render layer is selected and you are viewing the render layer's attributes and not something else you have selected. The preset dropdown will only show the render layer presets for the render layer that is selected.

Submitted by AEY on

Can you help me? I'm having a problem with Maya. When I render nothing displayed on the render view (I'm on mental ray or even if in any other render type), it is just all black. What should I do to fix this? Thanks in advance.

Submitted by Sam on
I'd press the 'A' key to see the alpha channel to see if you're actually rendering anything. If something shows up white in the alpha channel, then you'd need to check your materials and lights. Otherwise, make sure you're rendering with a valid camera on a valid render layer.