next up previous contents index
Next: 4.1.6 Blending Up: 4.1 Per-Fragment Operations Previous: 4.1.4 Stencil test

4.1.5 Depth buffer test

 

The depth buffer test discards the incoming fragment if a depth comparison fails. The comparison is enabled or disabled with the generic Enable  and Disable  commands using the symbolic constant DEPTH_TEST. When disabled, the depth comparison and subsequent possible updates to the depth buffer value are bypassed and the fragment is passed to the next operation. The stencil value, however, is modified as indicated below as if the depth buffer test passed. If enabled, the comparison takes place and the depth buffer and stencil value may subsequently be modified.

The comparison is specified with

void DepthFunc ( enum func ) ;

This command takes a single symbolic constant: one of NEVER, ALWAYS, LESS, LEQUAL, EQUAL, GREATER, GEQUAL, NOTEQUAL. Accordingly, the depth buffer test passes never, always, if the incoming fragment's value is less than, less than or equal to, equal to, greater than, greater than or equal to, or not equal to the depth value stored at the location given by the incoming fragment's coordinates.

If the depth buffer test fails, the incoming fragment is discarded. The stencil value at the fragment's coordinates is updated according to the function currently in effect for depth buffer test failure. Otherwise, the fragment continues to the next operation and the value of the depth buffer at the fragment's location is set to the fragment's value. In this case the stencil value is updated according to the function currently in effect for depth buffer test success.

The necessary state is an eight-valued integer and a single bit indicating whether depth buffering is enabled or disabled. In the initial state the function is LESS and the test is disabled.

If there is no depth buffer, it is as if the depth buffer test always passes.



next up previous contents index
Next: 4.1.6 Blending Up: 4.1 Per-Fragment Operations Previous: 4.1.4 Stencil test



David Blythe
Sat Mar 29 02:23:21 PST 1997