A ColorMask is an Enum which describes which color channels should be affected by a particular material. This is present in many materials and allows for a material to only affect a specific R/G/B/A channel, or to allow a material to have no effect on color at all such as for depth or stencil buffer effects.
It can take on the following possible values
- RGBA - (Default) All color channels are affected
- None - No color channels are affected
- A - Only Alpha is affected
- B - Only the Blue channel is affected
- G - Only the Green channel is affected
- R - Only the Red channel is affected
- RGB - All color channels are affected, but Alpha is excluded
Usage
Most of the time the RGBA mode will be used, however another common use for the ColorMask is to exclude color information entirely for Stencil effects.
For a material writing to the stencil buffer, the ColorMask would usually be set to None which ensures that only the stencil value is modified, the effect of which is that this material becomes completely invisible, whereas usually the material reading the stencil buffer will also write to some color channel so that it has a visual effect in area that is desired.