2008-04-30

Ambient Occlusion Pass for interior scenes

There are several ways to render out an ambient occlusion (AO) pass in max with mental ray. However some AO setups require environment changes, and don’t always work with interior scenes. I will explain how to get an AO pass that always works. For those of you who don't know what AO is, it's a method of creating soft shadows in corners where objects meet. It adds an extra sense of reality.

Ambient Occlusion Pass for interior without windows



Create a new mental ray shader. Insert the Ambient/Reflective Occlusion map into the diffuse slot, and put a value in the max distance of the AO map.













In your render settings under the Processing tab turn on Material Override and just click and drag the AO material into the blank material slot under Material Override. Now all of your materials in your scene will use this AO material, even though they still have their own shaders applied to them. Before you render, turn off FG, GI and turn off your exposure. If you don't do this you will get a black rendering. All of these settings will not be lost.


straight render pass before AO is added



Final composite of AO and beauty pass combined


The nice thing about this process is you don't have to turn off or delete any lights in the scene, and you still keep all of your materials intact. When you are done rendering the AO pass just turn back on FG, GI, and your exposure...all of your settings will still remain. Also don't forget to disable the Override Material before you go back to rendering your beauty pass.

29 comments:

Cláudio Stacciarini said...

Hi!
Your blog is very helpful! I will come back to see news, nice work!
My blog:
http://maquetestacciarini.blogspot.com/

lime said...

Why do we need AO? what is it for?
Sorry if the question sounds stupid. Im newbie to mental ray.

ramy said...

Lime, after you question, I added an explaination to AO : "For those of you who don't know what AO is, it's a method of creating soft shadows in corners where objects meet. It adds an extra sense of reality"

Александр said...

Thanks, that was pretty helpfull :)

MetAtroN said...

But how do you combine AO and straight render pass? Am I missing something obvious?

ramy said...

MetAtroN,
this is done in Photoshop. Put the AO layer over the beauty layer and change the mode to multiply to get the result you need.

MetAtroN said...

Thanks for the swift answer :) Minutes after I asked thet question I've found a neat tutorial about this. It really looks cool after both images are combined.

Anonymous said...

Does this work in the same with Vray aswell?

ramy said...

No. V-ray has its own shaders for achieving AO.

Treasure said...

Is the example scene lit only by down lights in the ceiling? If so, what is lighting the ceiling in the ao pass if there is no GI?

Thanks

ramy said...

When the AO shader is used, there is no lighting calculated in the scene. In other words, you would get this same result without lights in your scene.

Garry Johnson said...

Thanx for the tutorial it was v helpful. I noticed u said turn off FG and GI, well I was messing about with setting and turned on FG for fun on the draft preset and noticed it worked just as good. thought I'd let u know

ramy said...

Garry,
you're right. Technically you can leave both FG and GI on for this method, and AO will still render correctly. You may get some photon mapping errors with the GI on, but it still works.

qholmes said...

Ok this is a dumb question but i used a pro material for the material override. Is that ok? Is there one i should use instead? Besides the samples and distance are there other settings i should be looking at? My image was very grainy.

ramy said...

As long as you're getting the results you want, there is no wrong shader to use. I always use the mental ray material. You can use the promaterial, but it may give you strange results since the pro-materials are always preset at certain values. The one setting that I change on the Ambient/Reflective Occlusion map is the Max Distance. I set it to 3' usually. You can also change your samples from 16 to 32 to get a softer rendering.

qholmes said...

If i choose mental ray as a material i dont get have a slot for diffuse?

qholmes said...

Ahhh i just put it in the surface slot and it worked much better. Awesome!

iancamarillo said...

great site! do you know of a way to make the grayscale gradation of the ao a colored gradient map? i would like to have a bright red where the geometry is very dense, then green and blue at the least dense area.

thanks in advance!

Alex said...

I'm attempting to use this method for an interior room with one window; when I do the procedure and render, my result is very dark with only a hint of any detail. Any suggestions?

ramy said...

be sure your exposure is off

ramy said...

iancamrillo: just add red to the Dark slot, and green / blue to the Bright slot in the Ambient/Reflective Occlusion Map.

Anonymous said...

hi, this is helpful ..
can you put the material sample in there .. ?

thanks ..

ramy said...

I added a snapshot of the shader

Anonymous said...

hello, like Alex, don't work for me in a scene under a single dome :( (if I hide the dome it work )

Anonymous said...

Ramy
can you explain the difference between this method and using the AO option that is built into many of the Mental Ray materials?

ramy said...

this method is a "pass" method, meaning it will render everything with just AO only (no colors, textures, reflections, refractions). Then it can be applied to your regular rendering in an editing software such as photoshop. Using AO in the A&D materials applies the AO ontop of the texture so when you render your regular image max will add the AO onto it already. The advantage of doing an AO pass is that you can tweak the amount of it in post production in real-time.

Javier said...

Thanks man, this was just what I needed

Anonymous said...

nice tutorial, one thing which you forgot to mention though was that mental ray needs to be your assigned renderer for you to be able to create a mental ray shader in the first place. You do this by going into render settings, the common tab, then the assign renderer swatch and click the dots beside the "production" label. Here you can change the renderer between the scanline renderer and any other one you have (mental ray). Nice tutorial, extremely helpful :)

Anonymous said...

hey, is there anyway to render a scene with AO inside 3ds max for all objects in the scene without rendering AO seperatly without going to another editing software to edit it haha if that makes sense

Post a Comment