1 | GAME ENGINE FRIENDLY OCCLUSION CULLING
|
---|
2 | ======================================
|
---|
3 |
|
---|
4 | This programn is a demonstration of the CHC++ algorithm
|
---|
5 | described in the chapter "Game Engine Friendly Occlusion Culling" of the book ShaderX 7.
|
---|
6 |
|
---|
7 | Copyright and Disclaimer:
|
---|
8 |
|
---|
9 | This code is copyright Vienna University of Technology, 2008.
|
---|
10 |
|
---|
11 | Please feel FREE to COPY and USE the code to include it in your own work,
|
---|
12 | provided you include this copyright notice.
|
---|
13 | This program is distributed in the hope that it will be useful,
|
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
16 |
|
---|
17 | Author of this demo:
|
---|
18 |
|
---|
19 | Oliver Mattausch (matt@cg.tuwien.ac.at)
|
---|
20 |
|
---|
21 | Authors of the book chapter:
|
---|
22 |
|
---|
23 | Jiri Bittner (bittner@cg.tuwien.ac.at)
|
---|
24 | Oliver Mattausch (matt@cg.tuwien.ac.at)
|
---|
25 | Michael Wimmer (wimmer@cg.tuwien.ac.at)
|
---|
26 |
|
---|
27 |
|
---|
28 | Date: June 20, 2008
|
---|
29 |
|
---|
30 | ----------
|
---|
31 | Input
|
---|
32 | ----------
|
---|
33 |
|
---|
34 | Help for keybord and mouse is available with F1.
|
---|
35 |
|
---|
36 | You can switch between different known occlusion modes using the
|
---|
37 | SPACE key (view-frustum culling, hierarchical stop and wait, coherent hierarchical culling, chc++).
|
---|
38 |
|
---|
39 | A bird eye view visualization of the culling algorithm from can be shown by pressing 'F2' on the keyboard.
|
---|
40 | Pressing 'F8' switches between using / not using the glFinish command, which causes slightly slower frame rates but brings more reliable fps measurements.
|
---|
41 |
|
---|
42 | ----------
|
---|
43 | The scene
|
---|
44 | ----------
|
---|
45 |
|
---|
46 | 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.
|
---|
47 |
|
---|
48 | 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.
|
---|
49 |
|
---|
50 | ---------------
|
---|
51 | The algorithm
|
---|
52 | ---------------
|
---|
53 |
|
---|
54 | 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
|
---|
55 |
|
---|
56 |
|
---|
57 | --------------
|
---|
58 | The engine
|
---|
59 | -------------
|
---|
60 |
|
---|
61 | 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").
|
---|
62 |
|
---|
63 |
|
---|
64 | ----------
|
---|
65 | Installation
|
---|
66 | ----------
|
---|
67 |
|
---|
68 | A binary for Win32 and a solution for visual studio 2005 and 2003 included. The program should work under XP and Windows Vista.
|
---|
69 |
|
---|
70 |
|
---|
71 | ----------
|
---|
72 | Structure
|
---|
73 | ----------
|
---|
74 |
|
---|
75 | 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.
|
---|
76 |
|
---|
77 | 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.
|
---|
78 |
|
---|
79 | The main routine is implemented in chcdemo.cpp. Also it contains the OpenGl setup code, glut stuff, and setups of the scene hierarchy.
|
---|
80 |
|
---|
81 | 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).
|
---|
82 |
|
---|
83 | The tool employs some free 3rd party libraries:
|
---|
84 |
|
---|
85 | DevIL for texture loading / unloading
|
---|
86 | glfont2 (http://students.cs.byu.edu/~bfish/glfont2.php) for the antialiased fonts of the HUD. Thanks to the author Brad Fish.
|
---|
87 |
|
---|
88 | Thanks to Ralf Habel for providing me the code for computing the sun illumination and Pretham model.
|
---|
89 | Thanks to Alexander Kusternig for providing me his code for the SSAO shader.
|
---|
90 |
|
---|
91 | The deferred shading algorithm features a
|
---|
92 | If you find any problem with the code or have any comments, please feel free to ask us at any time. |
---|