Stencil buffer

from Wikipedia, the free encyclopedia

The stencil buffer (engl. Stencil - template buffer - buffer) is in Computer Graphics an addition to the color-buffer and Z-buffer existing part of the frame buffer . A value in the stencil buffer is assigned to each pixel. The task of the stencil buffer is to restrict the transfer of fragments in the framebuffer to regions with certain properties of the stencil values. The property to be fulfilled is set by the stencil function . The way in which the stencil value is modified when processing a fragment is determined by the stencil operation, which can be set differently depending on the outcome of the stencil test and the Z test.

Applications

In the simplest case, the stencil buffer limits the rendering area. This can be used, for example, in a car or flight simulation to mask out the cockpit so as not to render the parts of the scene that are behind the cockpit. Another such area of ​​application is the avoidance of Z-fighting when displaying coplanar planes (triangles). With the help of the stencil buffer, mirrors can also be displayed in which the mirrored scene is only rendered in the original within the mirror frame.

The close interlinking of the stencil and the Z buffer in the graphics pipeline and, in particular, the possibility of being able to set the incrementation or decrementation as a stencil operation, however, also allows the implementation of a number of more complex methods. One of the most important is the shadow volume algorithm for creating shadows from point light sources. Procedures of this type usually require the scene or parts of the scene to be rendered several times in order to be able to use intermediate results in the stencil buffer immediately when creating an image. Therefore, they usually put a lot of stress on the graphics hardware.

history

The stencil buffer in its current form has been around since the beginning of the 1990s with the introduction of SGI Indigo from Silicon Graphics . The first programming interface to support the stencil buffer was the proprietary IRIS GL , followed by OpenGL 1.0 in 1992. Direct3D from version 6.0 contains commands for using the stencil buffer.

Since 1998 the stencil buffer has found its way into graphics hardware designed for the games market, especially with the appearance of the Riva TNT from Nvidia and the Rage 128 from ATI. Since then it has also been supported in all newer such products. Technically, the stencil and Z buffers in these products still occupy the same memory area on the graphics hardware, with a size of 32 bits per pixel. The Z-buffer has a depth of 24 bits per pixel, for the stencil buffer the remaining 8 bits per pixel are lost.

Web links