Controlling Ambient Occlusion Mix
Saturday, March 31  2007
This tutorials goes one step beyond the standard Ambient/Occlusion tutorial. Rather than lighting the scene purely with the Amb/Ocl shading method, we will create view port controls of the Amb/Ocl Samples and control the percentage of influence it has over our existing lighting.

This is typically done by mixing multiple lighting passes in post (usually with Shake, Photoshop, Nuke, Flame, whatever your favourite compositing package is). Sometimes a job is simple enough not to require extensive post-processing.


Example


As you can see, the ability to mix the ambient occlusion with your existing lighting has advantages, especially if you have very specific lighting requests from clients but they're also telling you that 'It doesn't look very real.'

Step 1
Applying your ambient occlusion. Select a unused texture and apply the Mix texture to it, name it 'Global AmbOcl'. In Color #2, apply your Ambient Occlusion shader, and name it something appropriate (AmbOcl is what I've chosen).



Applying the mix shader.


Now return up a level (back to your mix shader) and drag your Mix shader into its own slot. This will now be a shader that you can drag from this slot into the Self-Illum channel of every material in your scene as an Instance.



Dragging the material to its own slot for easier drag/drop instancing.


Why an instance? This allows us to wire only one object rather than 5 (or in a complex scene, hundreds). Obviously, you can have more than one if you need finer control.

Rendering your scene should now still have its original shadows but they'll be very smoothed out due to intense Amb/Ocl being applied.



Over-intense ambient occlusion


Step 2
Setup two viewport manipulators (Helpers --> Manipulators --> Slider)
 


The parameters for the mix.


Plonk it somewhere on your screen. Right click. Wire Paramters, Object (Slider) --> Value. Now click on the object in your scene that's the easiest to click on and also has the instanced ambient map. Find the map to wire to inside the list of wirable sections.



Wiring the Mix amount to the slider.


Step 3
Select the rightward facing arrow. This specifies the direction that controlling data is exchanged. In this particular case, we want the controller to be the primary method of control.



Ensuring one way communication.


Now it is important that your slider has a min/maximum value of 0 and 1 respectively. Despite being expressed as a 3 digit percentage (0 to 100%), the Mix amount is internally stored as a multiplier figure (from 0 to 1). So I've set the snap to 0.1 for the moment so it snaps to the nearest 10%, but you can obviously change this depending on how picky you're likely to be about lighting.

Step 4
Select Manipulate from the tool panel, slide it up and down and do some quick test renders to make sure its working.

Step 5
Make another slider, but this time with a min/max of 0 to 512 and a snap of 16. Name it Amb/Ocl Samples. Apply it as follows...



Wiring samples.


This is more of a quick way to change samples without needing your material editor open. Even for those of us with dual monitors, you'll notice that having the Material Editor (or even Curve editor) open will degrade performance to a degree thats nearly rage-worthy.

Once again, one way control for the Wire.

And Hey Presto! You've got viewport control of your Ambient Occlusion/Diffuse lighting mix and the Ambient Occlusion samples.



 

Download the example Scene File

 

 
  ADVERTISE WITH JTBENTLEY.COM