Section C.4. Cull Unseen Geometry


C.4. Cull Unseen Geometry

If your application is geometry limited, a good way to avoid bottlenecks, or at least reduce their effects, is to send less geometry to OpenGL in the first place.

Performance-conscious applications commonly perform frustum culling to avoid sending geometry outside the view volume to OpenGL. The six view volume planes can be derived trivially from the projection and model-view matrices whenever the view changes. To cull, simply test a bounding sphere against those planes.

In some instances, geometry is inside the view volume but still not visible. Imagine an automobile design application rendering a model of a car, in which the engine is modeled with complex geometry. The car body occludes the engine, so the application can gain performance by not rendering it. Because it's within the view volume, however, frustum culling alone is insufficient.

OpenGL provides the occlusion query feature for this situation, which appendix A, "Other Features," describes in brief. Note that occlusion queries return data to the application. This in itself can be the cause of performance problems. To avoid stalling the rendering pipe, issue occlusion queries during rendering, but obtain occlusion query results only at the end of the frame. Use the results when you render the next frame. This technique works well for frame-coherent applications, but for initial frames or sudden changes in views, your application will need to assume that everything is visible and issue a new set of queries for use in successive frames.

Another popular technique for optimizing occlusion queries is to arrange your geometry so that frames are rendered in front-to-back (or outside-to-inside) order. This maximizes the chance for occlusion to occur.




OpenGL Distilled
OpenGL Distilled
ISBN: 0321336798
EAN: 2147483647
Year: 2007
Pages: 123
Authors: Paul Martz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net