Screen-Space Ambient Occlusion with Composite Nodes

Yet another Fake ambient occlusion (AO) in Blender using composite nodes. First, let me introduce to you what AO is: Regular scene with flatshading.  No AO - Regular scene with flatshading: Render time: 1 second
REAL ray-traced AO - REAL ray-traced AO: Render time: 300 seconds
screenspace AO (Fake) - Now, this is the fake screenspace AO: Render time: 5 seconds. Notice the high image quality and the almost instant rendering time.

Sample Files

[DOWNLOAD] Demos nodes and samples v1. Several scenes are placed in different layers of the sample file, use the top-row number keys to access them in Blender.

Techniques and Limitations

0. Input 1. The Z buffer is sharpened. This step is optional but usually provides sharper result with a bit of cartoony edge. 2. The Z buffer is clipped from 0 to infinite (reduces artifact) 3. The Z-buffer is blurred. The radius of the blur controls the distance fall-off of the AO effect. 4. The blurred Z-buffer is subtracted from the non-blurred Z-buffer, resulting in a ‘difference map’ - the effect is similar to that of a high pass filter. 5. The resulting image is again clipped to 0 - 2 to reduce artifact. It is also optionally scaled. - the scaling factor is directly related to the intensity (darkness) of the AO effect. 6. The AO pass is subtracted from the original image. Works like the real ‘SUB’ AO setting - The subtract ‘Fac’ value also controls the intensity of the AO. 7. Done!
Limitations:
  • NOT physically accurate! Only yields good results when used lightly in combination with textures.
  • Huge Z differences cause problem. This can be seen at edges where the mesh meets the sky.
  • Intensity is entirely dependent on the difference in Z value and not the normal rotation of the face.

Advantages:
  • Very generalized setup that works relatively well for all scenes.
  • Several hundred times faster than ray-traced AO.
  • No other setup required other than the nodes.
  • Independent with camera clip values
  • Polygon count independent: can process a scene with 10 million polygon in 1 second.

More images using the fake AO method:

fast screen-space ambient occlusion flat shaded(above)
fast screen-space ambient occlusion composite AO (above)
fast screen-space ambient occlusion flat shaded(above)
fast screen-space ambient occlusion composite AO (above)
Download Sample Blender file
This method, screen-space ambient occlusion with composite nodes, is also known as z buffer ambient occlusion, or depth buffer occlusion, or image based ambient occlusion, or 2d shadow.

Comments

On May 13, 2008, Ellri Nidhogg Said:
yu can use the z buffer depth to mix materials so as to cut down rendering time while increasing detail when the camer is close to an object


A Mike Pan Design.