|Ambient occlusion based on luminance|
Here's a quick shader which will improve the look of your ambient occlusion pass by integrating it more closely with the directional lighting in your scene.
Let's start by setting up a conventional ambient occlusion shader, by taking a 'mib_ambient_occlusion' node, and connecting it to the 'out_color' of a surface shader.
|Basic AO shader|
The next step is to take a ramp node, and the magic ingredient... a 'surfaceLuminance' node, found under the Maya utilities section of the hypershade.
Set the ramp up to be a two colour V ramp, with white on top and black on the bottom. Then middle drag from the 'surfaceLuminance' node onto the ramp. There isn't a standard connection to make so you'll be taken into the Connection Editor to hook things up manually.
All that needs to be done is to connect the 'outValue' output of the surfaceLuminance to the 'uvCoord/vCoord' of the ramp.
Double click on the AO node, then middle drag your ramp into the AO's 'Dark' attribute.
Bingo. Now you have some nice natural AO that takes into account the luminance or light direction of your scene. No more dark occlusion in places where it obviously shouldn't be, for example hard edges which are being exposed to a lot of light.
|The finished light based AO shader|
|Standard AO - shadowing is uniform in all directions|
|Light Based AO - light is coming from the front direction|
|Light is coming from the left|
|Light is coming from the right|
Hope this is useful! :)
Thanks to Soner Unlu for passing on this handy technique.