Traditional DirectX lighting models define ambient lighting as coming from all directions, and is added as a constant on all surfaces regardless of the geometry. Ambient occlusion acts as a factor to ambient lighting to take into account the cavities and concave areas in a model, or how much a surface is hidden from its environment.
StaticAmbientOcclusion.rar [6.8 Mb] – VB 2005 (VS.NET 2005)
- Two computation modes : Both raytracing (CPU, software) and hemicube rendering (GPU, hardware) modes can be chosen to compute the occlusion data. Hemicube mode is much faster but slightly less accurate.
- Occlusion data saved in TVM : The mesh vertex color information is used to save and use the occlusion data, so it can be generated once and saved along with a TVM.
- Multithreaded raytracing : Even if it’s slower than hemicubes, the raytracing mode has been optimized for multi-core configurations with as many threads as wanted.
- Fully featured shader : A shader is unavoidable to actually show the ambient occlusion when rendering, so I’ve made a proper one. It features 4 lights in SM3 and 2 in SM2 and offset bump-mapping, which makes it pretty much the same as TV3D’s built-in mesh shader.
- Bent normals : The raytracer can compute the bent normal, or “direction of least occlusion”, and stores it in place of the mesh’s normal.
- Tweakable diffuse occlusion factor : A shader parameter allows to set the amount of diffuse occlusion.
- Lyon/Blinn reflection model : The TV3D built-in shader uses the Phong reflection model, but my shader uses a reformulation of Blinn-Phong which leads to a more correct shape of specular highlights.
3 thoughts on “Static Ambient Occlusion”
Superb as always zak.
I was wondering if you could port this simple example on xna ? It’s basically the only sample I found on this technique.
I’m putting together a framework for XNA, so yeah I might do that in the near future. :)