Creating an Ambient Occlusion Render in Maya

Shader recipe series

Over here in the gadgets corner, recipes don't really make a whole lot of sense, but it occurred to us the other night while digging up advice for cooking lemon pepper chicken that we could start a series featuring a different sort of recipe—shader recipes.

Entire “cookbooks” have been written on materials and shaders in Maya, UDK, 3DS Max, Vray, etc.

It's something a lot of beginners have difficulties with and for good reason! Tweaking an array of arcane parameters like “specular strength” and “diffuse weight” in an attempt to mimic real-world materials like wood, glass, stone, or ceramic tile is no easy task.

So, here we are.

Starting with ambient occlusion, we'll start to introduce some application settings for some common real-world materials that are tough to nail down. We'll mostly be using Maya in this series, although we may veer into the Unreal Development Kit a time or two. We're excited about this series and expect to learn as much writing it as you do reading it!

of 02

What is Ambient Occlusion?

The American Gaming Association's Launch Of 'Gaming Votes,' The Industry's First Voting Initiative Targeting Key Presidential Election States
Getty Images for American Gaming / Getty Images

Don't let the name fool you—ambient occlusion is actually a pretty straightforward material to build, and it's an incredibly important one.

Not only is AO used (pretty universally) for rendering out work-in-progress images, it's also frequently used as a base pass in compositing and texture painting because it helps bring out detail and “ground” objects in a scene by unifying the shadows.

Ambient occlusion is a form of self-shading material, meaning it works even if there isn't any lighting in your scene. In theory, it's a rudimentary approximation of global illumination and is meant to mimic the way light spreads around a room or environment.

Ambient occlusion renders have a characteristic “soft-shadowed” appearance with subtle darkening anywhere two surfaces come into close proximity or contact (corners of a room, the underside of objects, fine details, etc.). Ambient occlusion images have occasionally been called “clay renders” because of their resemblance to modeling clay.

Here's a model we made for a workshop last year that uses ambient occlusion to show off the form of the model (weapon concept by Diego Almazan).

of 02

Creating an Ambient Occlusion Shader:

Creating an ambient occlusion shader for basic progress images is pretty easy, and doesn't require any UVs, texture maps, or lighting.

There are multiple ways to implement the effect for slightly different results, but the one we'll introduce here is nice and straightforward, requiring just a single Mental Ray node and a basic Lambert material.

Here's a short step-by-step explanation.

Open up the Hypershade window and create a new Lambert material.

Give the material a name—we usually use something like ambientOcclusion_mat.

Double click the material to open up its material attributes. This is where we'll set most of the parameters for the shader.

By default, the material's diffuse color is a neutral gray, but we don't want our highlights to blow out, so we're actually going to slide the color value down toward the darker end of the spectrum. We're using 0, 0, .38 for the HSV value on the color attribute, but this is a matter of personal preference.

The next thing we need to do is plug an ambient occlusion node into the material's incandescence attribute.

Click the checkered box next to the incandescence input. This will bring up the render node window.

Under the Mental Ray tab, click textures and find mib_amb_occlusion on the list. Click it, and the node will open up in the attribute editor on the right side of your screen.

You should see a list of attributes—the ones that are important to us are samples, bright/dark, spread, and max distance, however, the only thing we'll change is the number of samples.

In the ambient occlusion node, the number of samples controls the amount of noise in your render.

Leaving samples at 16 or 32 will be relatively grainy while upping the value to something like 64 or 128 will appear very smooth. 32 samples is nice for testing, but if we plan on showing an image we'll typically use 64 or 128.

Try a few renders at different sample levels to get a feel for the differences—you might find you like the grainy appearance at the lower end of the spectrum.

Here's a comparison image we made using an outdoor environment we modeled awhile back showing the difference between a Maya base render, and ambient occlusion renders with 64 and 128 samples. See how much better the image looks with ambient occlusion?

You can also play around with the other attributes if you'd like:

Bright and dark control the minimum and maximum values in your render. If you find that your highlights are blown out or your shadows are getting crushed, you can use these sliders to compensate. Spread and max distance will alter the falloff/occlusion distance between your light and dark values.

There you go! Hopefully, you've learned a little bit about ambient occlusion and how it can be used as a nice presentation material for your 3d scenes.

Was this page helpful?