Ambient Occlusion Shading

Updates

12-28-2003: This method's become more popular in the past year.

Collection of tutorials exploring artistic uses of occlusion shading:


Depth Map Based Ambient Occlusion Lighting
Surface Shading: Basic Occlusion
Ambient Occlusion, Image-Based Illumination, and Global Illumination. PhotoRealistic RenderMan Application Note #35
Ambient Occlusion


RayDiffuse occlusion shading utility. Uses monte-carlo method. Package includes Maya plug-ins, shaders for other packages, and texture baking utility.
An example with roll-overs to illustrate ambient occlusion & directional lighting.

Papers:
Image-Based Diffuse Lighting Using Visibility Maps. Ivan Neulander.
Image-Based Diffuse Lighting Using Visibility Maps: Additional Notes. Ivan Neulander.
Radiance Maps: An Image-Based Approach to Global Illumination. Philipp Slusallek, Wolfgang Heidrich, Christian Vogelgsang, Matthias Ott, and Hans-Peter Seidel
Extended Ambient Term. Francesc Castro, L´aszl´o Neumann, Mateu Sbert.

7-24-2002: I realized today that this entire lighting computation can be performed in linear time using a method that's laughably simplistic compared to the current implementation. It's just a matter of twisting your mind sideways to see how it can be done. There may be some special cases I haven't foreseen, but the problem is simplified a great deal by the new method. This method is unprecedented, so I'm planning on publishing either a magazine article or journal paper about it. So until then, I leave you in suspense.

2-11-2002: After showing these screenshots to some coder buddies and gauging their response, I realized that the significance of this method isn't readily apparent. The thing to keep in mind is: the program which generated the textured models you see in these screenshots only requires a bare model as input. That is, I didn't place any lights into these scenes, nor did I texture them beforehand. Yes the pictures look a bit off, but that's only due to the texture filtering effects at polygon seams due to the naive polypacking algorithm I used. This algorithm adds realism to any scene in a matter of seconds with no user intervention. Maybe I'll put up some before & after shots.

Introduction

This method is significantly faster than other global illumination schemes (i.e. radiosity) while achieving similar results. But as with any method that relies on hardware acceleration, some extra work is required to get the lightmaps to look correct. The drawback of the original method is that the scene must be static due to the time required to recalculate illumination (however, these static computations take a few minutes). I've developed another algorithm that uses features in newer 3D accelerators to achieve the same effect in real-time. This would effectively yield visuals that simulate real-time radiosity.

Lightmap texture mapping is the most challenging aspect of this algorithm. I generated groups of abutting coplanar polygons and then aligned the lightmaps corresponding to these groups to the same orientation. Another approach is to project the union of the polygons in each group onto the axis which causes the least distortion (compare the surface normal and the axis plane's normal), and map the lightmap in the axis's plane. This results in skewing, but the degree of skew is bounded by some known constant (something involving a root of two, no doubt).

The visual artifacts in these screenshots are caused by:

  1. 3D Model Tessellation: The 3d modelling software inverted surface normals at random, and generated a poorly formed, screwed-up mesh. A great deal of these tessellation errors are due to the way the package handles curved objects when tessellating and exporting to another format. Note that this isn't a flaw of the algorithm used.
  2. Lightmap Texture Mapping: Lightmaps are essentially a rectangular grid of polygons overlaid onto whatever surface texture is already present on a polygon. Because of this, extra thought is required to devise a means of reducing aliasing errors. If two polygons abut and their lightmaps are aligned at different angles and with different offsets, it is likely that the "crease edge" between them will be apparent. To solve this, group the polygons that "touch" a specific polygon and have the same normal, then align their lightmaps to share the same grid.
  3. Sampling Error: Samples may be obscured or "contained" inside the "solid", non-hollow parts of the geometry. If any part of the rectangle represented by the "inside" sample lies "outside" of the geometry, it will be visible and most likely will have an incorrect intensity. This results in lighting that "creeps" underneath walls and corners.
  4. Sampling Rate: This program used the same resolution for every lightmap, and assigned a unique lightmap to every polygon. Instead of increasing the resolution of the lightmap for larger polygons, it scaled the lightmap to fit the dimensions of the polygon.

The algorithm can be improved by:

  1. Hemicube Sampling: Utilize graphics hardware instead of costly brute-force ray-tracing to find nearby surfaces.
  2. Projected Mapping: We'll have to live with a small skewing effect, but the algorithm is a lot simpler this way.

See Also:
Global vs. Local Algorithms
Texture Baking