Wednesday, January 13, 2010

Occlusion Algorithm, in a Nutshell

In this image-less post I wanted to go over the basics of the algorithm used to calculate occlusion for a scene. The goal here is to quickly approximate which objects in a scene will not be visible so that we can skip rendering them. The project involved two phases: the setup phase and the rendering phase.

The setup phase occurs when objects are loaded into the scene. In this phase we need to determine which objects make good occluders and mark them as such. Not every object in the scene will make a good occluder. It is also beneficial to use low-poly versions of object as their occlusion models. How you determine a good occluder is not automatic and for now I manually pick objects I know will be good occluders. Automatically picking occluders is a good area of future research.

The rendering phase occurs each frame, before sending that frame to the video card to be processed. There are a number of steps involved in this phase.

  1. Walk octree and collect occluders which lie within the viewing frustum
  2. Sort occluders based on maximum occlusion heuristic (involves distance to camera and approximate size of the object).
  3. Render occluders into the software z-buffer until an arbitrary triangle limit is reached.
  4. Walk octree collecting visible nodes passing two criteria:
    1. The node passes the view frustum test
    2. The node's octant (the leaf octree node it is a member of) has at least 1 pixel pass the depth test when its bounding box is rendered to the software z-buffer

No comments:

Post a Comment