GAME ENGINE FRIENDLY OCCLUSION CULLING ====================================== This programn is a demonstration of the CHC++ algorithm described in the chapter "Game Engine Friendly Occlusion Culling" of the book ShaderX 7. Copyright and Disclaimer: This code is copyright Vienna University of Technology, 2008. Please feel FREE to COPY and USE the code to include it in your own work, provided you include this copyright notice. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Author of this demo: Oliver Mattausch (matt@cg.tuwien.ac.at) Authors of the book chapter: Jiri Bittner (bittner@cg.tuwien.ac.at) Oliver Mattausch (matt@cg.tuwien.ac.at) Michael Wimmer (wimmer@cg.tuwien.ac.at) Date: June 20, 2008 ---------- Input ---------- Help for keybord and mouse is available with F1. You can switch between different known occlusion modes using the SPACE key (view-frustum culling, hierarchical stop and wait, coherent hierarchical culling, chc++). A bird eye view visualization of the culling algorithm from can be shown by pressing 'F2' on the keyboard. Pressing 'F8' switches between using / not using the glFinish command, which causes slightly slower frame rates but brings more reliable fps measurements. ---------- The scene ---------- The scene used in this program is model of the city Vienna, which has a long history in the visibility research comunity as a scene to test and showcase various algorihms. The hierarchical structure is a bounding volume hierarchy which was precomputed (using Surface Area Heuristics) in order to not pollute the demo with lenghty construction code not relevant to the algorithm to keep the demo as simple and educationional as possible. Note that the original construction would also not take more than some seconds. --------------- The algorithm --------------- The CHC ++ algorithm is build on the CHC alorithm and removes most of it's shortcomings while maintaining simplicity. By playing with the parameters and moving around, the user can explore situtations where occlusion culling is extremly useful, and where it is not (because the objects are too sparse or there is too much to see from this viewpoint). One can observe that the CHC++ algorithm provides good frame rates even in these difficult cases, even when the CHC algorithm breaks down and falls behind view frustum culling in terms of performance -------------- The engine ------------- We use a simple OpenGL based engine which was designed to be as simple as possible while providing the necessary feature list to simulate the behaviour of full-fledged game engines like Ogre3D. The engine supports simple material sorting mainly based on the texture format, avoiding the mix of different texture formats, which according to various sources induces one of the costliest state change. We demonstrate the integration of the culling algorithm into the engine, and show how occlusion cullig and state sorting are possible within one framework, two paradigms that were previously considered to be cancelling out each other ("either you do front-back-sorting or material sorting"). ---------- Installation ---------- A binary for Win32 and a solution for visual studio 2005 and 2003 included. The program should work under XP and Windows Vista. ---------- Structure ---------- This demo is written in C++. We make heavy use of stl classes, like priority_queue. The program expects the GL_ARB_occlusion_query extension. The rendering core of the engine is provided by the class RenderTraverser, which provides front to back scene traversal based on a priority queue. It's subclasses implement the various culling algorithms. The new algorithm is represented by the class CHCPlusPlusTraverser. The main routine is implemented in chcdemo.cpp. Also it contains the OpenGl setup code, glut stuff, and setups of the scene hierarchy. The project is separated into one section containing supportive code (utils), the traversal algorithms (traversal), and the basic engine classes like Camera, Geometry, Material, or RenderState (rendering). The tool employs some free 3rd party libraries: DevIL for texture loading / unloading glfont2 (http://students.cs.byu.edu/~bfish/glfont2.php) for the antialiased fonts of the HUD. Thanks to the author Brad Fish. Thanks to Ralf Habel for providing me the code for computing the sun illumination and Pretham model. Thanks to Alexander Kusternig for providing me his code for the SSAO shader. The deferred shading algorithm features a If you find any problem with the code or have any comments, please feel free to ask us at any time.