2.11
Stencils

- 2.11.1. Overview
- 2.11.2. Reserved Bits
- 2.11.3. Allow Bit

2.11.1
Overview
1
The stencil buffer enables per-pixel control over rendering. The r2 package uses the stencil buffer to implement several rendering techniques internally, and also exposes limited control of the stencil buffer to users of the renderer via the allow bit.
2.11.2
Reserved Bits
1
The current stencil buffer layout used by the r2 package is as follows:
2.11.2.2 Reserved bits
3
Bit 0 is used for light clip volumes.
4
Bits 1-2 are reserved for future use.
5
Bits 3-6 are used for groups.
6
Bit 7 is the allow bit.
2.11.3
Allow Bit
1
The r2 package reserves a single bit in the current stencil buffer, known as the allow bit. In all subsequent rendering operations, a pixel may only be written if the corresponding allow bit in the stencil buffer is true.
2
The stencil buffer allow bits are populated via the use of a stencil renderer. The user specifies a series of instances whose only purpose is to either enable or disable the allow bit for each rendered pixel. Users may specify whether instances are positive or negative. Positive instances set the allow bit to true for each overlapped pixel, and negative instances set the allow bit to false for each overlapped pixel.