ambiant occlusion (obscurances)

Hi,
hello, has anybody implemented the ambiant occlusion in opengl?. can somebody send me a sample code as how to implement it.

It would be greatful if somebody help me out. I will be most thankful.

regards and thanks in adwance,
srinivas reddy

the NVIDIA SDK has an example.

Not a very practical approach, though, unless you just want to render still images.

To make the technique useful for realtime rendering, you’d need to precompute the ambient occlusion term. You can do this by shooting rays in random directions away from the surface, and counting the percentage of them that are occluded by the surface itself. You could store this information per vertex, but you’d need very fine tessellation to make this look good. It’s better to store it in a texture, but that implies that you need a unique UV mapping on your mesh.

If you go this route, the actual rendering part is just simple texture mapping, so it’s very fast.

– Tom

If you need a piece of code that computes a static per-vertex ambient occlusion term using Opengl, you can look at the sources of ShadeVis tool that is available under GPL at

http://vcg.sourceforge.net/tiki-index.php?page=ShadeVis

As explained by Tom Nuydens the most common techniques to compute ambient occlusion is based on shooting rays from each surface element to evaluate the quantity of light that reach it. Shadevis tools use OpenGL to accellerate this process by simply rendering the scene ortographically from a set of uniformely distributed directions and checking against the zbuffer if each vertex is occluded or not.

The Shadevis tool is oriented to handle rather large, finely tessalated, meshes; we have successfully used it on a 8M triangle mesh of the David on a 512Mb machine.

P.