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.

41 comments:

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

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

    ReplyDelete
  3. 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"

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

    ReplyDelete
  5. 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.

    ReplyDelete
  6. 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.

    ReplyDelete
  7. Does this work in the same with Vray aswell?

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

    ReplyDelete
  9. 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

    ReplyDelete
  10. 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.

    ReplyDelete
  11. 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

    ReplyDelete
  12. 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.

    ReplyDelete
  13. 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.

    ReplyDelete
  14. 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.

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

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

    ReplyDelete
  17. 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!

    ReplyDelete
  18. 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?

    ReplyDelete
  19. be sure your exposure is off

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

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

    thanks ..

    ReplyDelete
  22. I added a snapshot of the shader

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

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

    ReplyDelete
  25. 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.

    ReplyDelete
  26. Thanks man, this was just what I needed

    ReplyDelete
  27. 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 :)

    ReplyDelete
  28. 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

    ReplyDelete
  29. @Ramy,

    when you posted your example render including the AO-Pass and the beauty pass.. would you like to explain or show us with a snapshot, how the 3 different layers look like and how you combined it in potoshop ?

    You wrote you just use Multiply, but when ever I try it it just get's to dark.

    @Beauty Pass:
    What exaclty do you understand with the beuaty pass ? would you like to post the render of the beauty pass only ?

    thank you so much for your great research work.

    ReplyDelete
  30. Heey,
    wanted to thanks for sharing your work with us. Found your blog and it was very helpful..each and every post. i liked the glass ones, and the ink and paint techniques.. i tried them myself.
    Thanks..will be checking for your updates.

    Great Blog!

    ReplyDelete
  31. hey

    just wanted to say nice work great blog super useful!

    keep 'em comin'

    Your Fellow 3D Voyager

    ReplyDelete
  32. I know this is probably a silly question, but is there a trick that allows you to add the AO pass to the beauty pass while it renders an animation? I was just wondering if there was an easy way to accomplish AO in an animation without having to render the beauty, AO, then using multiply in Photoshop on 1000+ frames.

    ReplyDelete
  33. Hi Ramy,
    My image turned out half right and half wrong! some areas are too bright and the ceiling and some elements are quite black.
    I need to email you the outcome so you can advise on.
    I don't know how to send it to you and appeciate if you let me know how...
    Thanks,
    Al.

    ReplyDelete
  34. Ramy, thank you for making this! In max 2011 my interior AO is very grey. Is yours too?

    ReplyDelete
  35. Great for creating rusty mechanical parts too...!

    ReplyDelete
  36. GR8, much easier than what I learn in class!

    ReplyDelete
  37. This is great information. The results aren't always what you might expect, and may require some work in photoshop, but this technique is still very useful. I notice this post is several years old - thanks for continuing to keep it available!

    ReplyDelete
  38. not works, AO map will be black even with FG GI exposure off. Only the diffuse/complete map is rendered.

    ReplyDelete
    Replies
    1. Be sure you are not using an Environment Map and "Use Map" is off under your Environment settings.

      Delete