Panda3D Manual: Color Write Masks
  <<prev top next>>     

Color Write Masks

Color write masks enable you to block writes to the Red, Green, Blue, or Alpha channels of the framebuffer. This is not a frequently-used capability, but it does have a few applications:

  • When using red-blue 3D glasses, you might want to render the red image, then the blue image.
  • Battletech Battle Pods connect 3 black-and-white monitors to a single R,G,B video card output (really!) With the help of color write masks, you could update an individual monitor.
  • Sometimes, one wants to store data in the alpha-channel of the framebuffer. Using a color mask can avoid accidentally overwriting that data.

Using a color write-mask is not free. During normal rendering, each pixel written to the frame buffer requires a memory write. With a color-mask active, a memory read-modify-write cycle is needed, which is more expensive.

By default, color write masks are off.

Turning on the Color Mask

To enable writes to all the channels of the framebuffer, use this:

bits = ColorWriteAttrib.CAlpha
bits |= ColorWriteAttrib.CRed
bits |= ColorWriteAttrib.CGreen
bits |= ColorWriteAttrib.CBlue
nodePath.setAttrib(ColorWriteAttrib.make(bits))

To disable writes to one or more channels, omit that bit. You can also use:

nodePath.setAttrib(ColorWriteAttrib.make(ColorWriteAttrib.COff))

To enable all bits. This may be more efficient than specifying all the bits manually.

  <<prev top next>>