What is occlusion culling? Let’s break it down.
Occlude: to stop, close up, or obstruct.
Cull: to select from a large quantity.
Occlusion culling is a concept that is crucial to 3D graphics. It is the use of algorithms to select from a large selection of polygons what geometry should be occluded, obscured.
Why?
Let’s take a look at a conventional 3D pipeline.
- Application / Scene
- Scene/Geometry database traversal
- Movement of objects, and aiming and movement of view camera
- Animated movement of object models
- Description of the contents of the 3D world
- Object Visibility Check including possible Occlusion Culling
- Select Level of Detail (LOD)
- Geometry
- Transforms (rotation, translation, scaling)
- Transform from Model Space to World Space (Direct3D)
- Transform from World Space to View Space
- View Projection
- Trivial Accept/Reject Culling
- Back-Face Culling (can also be done later in Screen Space)
- Lighting
- Perspective Divide - Transform to Clip Space
- Clipping
- Transform to Screen Space
- Triangle Setup
- Back-face Culling (or can be done in view space before lighting)
- Slope/Delta Calculations
- Scan-Line Conversion
- Rendering / Rasterization
- Shading
- Texturing
- Fog
- Alpha Translucency Tests
- Depth Buffering
- Antialiasing (optional)
- Display
Note: this is but one example of a conventional 3D pipeline. Pipelines can vary.
As you can see, the conventional 3D pipeline contains a lot of science, math, logic, and engineering that we take for granted. We’re going to be dealing with but one area of this today, and that is the one that has been highlighted: “Object Visibility Check including possible Occlusion Culling”.
Let’s say you have modeled a Dodge Viper in Maya, and it contains roughly one-hundred thousand polygons. You may be inclined to think that one-hundred thousand polygons isn’t too difficult for a modern computer to render in real time, and in thinking so you would be right. However, what if you want ten of your Dodge Viper models onscreen at once? You are now sending one million polygons to your rendering pipeline.
Without the aid of occlusion culling, your hardware would be rendering one million polygons. This can be a strain depending on the hardware you’re dealing with. Either way, this is considerably more computationally intensive and time consuming than say rending three-hundred thousand polygons.
Occlusion culling mitigates the overhead involved in rendering a scene such as this. While algorithms may vary, a simple solution can be imagined with the following pseudo-code:
- Determine the camera’s (user’s) field of view.
- From the camera, project a vector towards every point within the its field of view.
- If that vector comes into contact with a polygon, mark that polygon as visible.
- Render all visible polygons.
Instead of rendering all polygons, whether visible or not, only visible polygons are rendered. This process adds an overhead of its own, however the performance gained offsets this overhead considerably.
This technology is available to all sorts of mediums: film, video games, and research to name a few. Now the next time you are working with or enjoying something that involves 3D graphics, you can truly appreciate the science and hard work that have gone into such prolific technology.
I shall leave you with this: Umbra Software’s occlusion culling tech demo — quite impressive.