View Full Version : ambiant occlusion (obscurances)
08-24-2004, 04:30 AM
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,
08-24-2004, 04:45 AM
the NVIDIA SDK has an example.
08-24-2004, 07:11 AM
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.
08-24-2004, 04:51 PM
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
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.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.