xor
Performs a 'Bitwise XOR' logical operation. In graphics, it is primarily used for efficiently generating procedural patterns or for low-level bit manipulation, equivalent to the `^` operator in GLSL.
Core Advantages
It can generate complex geometric patterns (like checkerboards) at an extremely low computational cost, and its reversible property, (A ^ B) ^ B = A, makes it ideal for implementing toggleable overlay effects.
Common Uses
Generating checkerboard patterns
Implementing unique 'inversion' blend modes
Procedural randomization and hashing
How to adjust
Changing the integer values input to xor causes discrete, abrupt changes in the output. This adjustment does not produce smooth transitions but is used to alter the frequency or structure of procedural patterns or to achieve 'flipping' effects based on bitwise logic.
Code Examples
1// Convert floating-point coordinates to integers
2const intX = floor( scaledUV.x );
3const intY = floor( scaledUV.y );
4
5// Perform a bitwise XOR on integer coordinates to create a checkerboard pattern
6const checkerPattern = xor( intX, intY );