next up previous contents
Next: 18.4.3 Optimizing Texture Mapping Up: 18.4.2 Minimizing Per-Pixel Calculations Previous: 18.4.2.2 Use Simple Fill

18.4.2.3 Use the Depth Buffer Efficiently

Any rendering operation can become fill-limited for large polygons. Clever structuring of drawing can eliminate or minimize per-pixel depth buffering operations. For example, if large backgrounds are drawn first, they do not need to be depth buffered. It is better to disable depth buffering for the backgrounds and then enable it for other objects where it is needed.

Games and flight simulators often use this technique. The sky and ground are drawn with depth buffering disabled, then the polygons lying flat on the ground (runway and grid) are drawn without suffering a performance penalty. Finally, depth buffering is enabled for drawing the mountains and airplanes.

There are many other special cases in which depth buffering might not be required. For example, terrain, ocean waves, and 3D function plots are often represented as height fields (X-Y grids with one height value at each lattice point). It's straightforward to draw height fields in back-to-front order by determining which edge of the field is furthest away from the viewer, then drawing strips of triangles or quadrilaterals parallel to that starting edge and working forward. The entire height field can be drawn without depth testing provided it does not intersect any piece of previously-drawn geometry. Depth values need not be written at all, unless subsequently-drawn depth buffered geometry might intersect the height field; in that case, depth values for the height field should be written, but the depth test can be avoided by calling glDepthFuncGL_ALWAYS(GL_ALWAYS).


next up previous contents
Next: 18.4.3 Optimizing Texture Mapping Up: 18.4.2 Minimizing Per-Pixel Calculations Previous: 18.4.2.2 Use Simple Fill
David Blythe
1999-08-06