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 |
Some examples...
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.
Genius, very useful as the standard ao pass is technically incorrect when composited as a multiply over the beauty.
ReplyDeleteIs this basically the same though as compositing the ao as a multiply over the indirect lighting? the
Great Blog!! I get a weird result with this technique when I have any of my lights higher than an intensity of 1. Is there a fix to this or am I doing something wrong? Your response will be greatly appreciated.
ReplyDelete@jlopez to fix that you just need to add a clamp node between the luminance and ao node. so something like luminance>clamp>ao>surface shader.
ReplyDeletehope that helps!
jdbeals.com