On the World tab, there’s an Ambient Occlusion setting that allows you to sort of add indirect lighting to the scene. The manual says that this effect can also be applied on a per-shader basis using the Ambient Occlusion node.
The node in question has a Color and an AO output, and I understand that these can be used to create cavity masks and such. However… how exactly do I use this node to replicate the “add indirect lighting” effect of the Ambient Occlusion setting on the World tab?
More precisely, how would one go about integrating the Ambient Occlusion node into an existing material in order to replicate the World Ambient Occlusion setting (Factor + Distance) on a per-shader basis?
That is indeed an interesting question. Take my answer with caution, as there might be something I missed and there is a better answer.
Playing around with it a bit, it seems what can be equivalent is adding emission to the object (meaning: use an add shader taking the original material and an emission shader). The strength of the emission is connected to AO then.
The tricky part might be to determine the color/texture of the emission, then, which you would have to pick up from the original material somehow. Could work with using color mix nodes to mix the colors of the individual shaders with the same factors that any mix shaders in the tree use.
I think you’re right. Just tested this myself with a simple Suzanne scene. World Ambient Occlusion with factor 0.1 seems to be roughly equivalent to the following setup:
I figured out the 0.08 value in the Multiply node through experimentation. Looks like there’s no simpler way to determine that value straight from the World Ambient Occlusion factor
In my experience, adding emission to a material can cause fireflies in cavities, whereas the extra brightness from World Ambient Occlusion seems to be immune to fireflies. That makes me wonder to what extent Ambient Occlusion node + Emission node is affected by fireflies… Unfortunately, this problem is hard to reproduce with simple test scenes.