Conceptually, masking involves selectively ignoring something, usually to isolate something else.
The two main uses I've familiar with are:
- Masking data such as bit fields or flags for bitwise operations.
- Masking images, often for compositing or other effects.
For an example of the first, let's say you have a bit field such as the 6502 status register:
ANDing the register with
01000000 would mask out everything except the overflow flag. So something like
if(R & 01000000) would allow you to check for the overflow condition. Specifically, the logical operation preserves (masks) only the 6th bit for evaluation.
This question examines ways to use an alpha mask to ignore unwanted portions of a texture in order to get a more complex result:
|Addition of a red hexagon sprite
|Result of masking the sprite
In the above example, the mask preserves the portion of the sprite in the round center area. You might use this form of masking to implement a circular field of view in a top down game as it allows the player to see things in the field of view, but not outside it.
It's probably worth mentioning, sometimes it can be a bit ambiguous regarding whether mask is being used to refer to what is kept versus what is discarded.