bitOr
Performs a bitwise OR (|) operation, used to safely combine or 'turn on' multiple state flags within a single integer.
Core Advantages
Provides the correct, atomic method for merging state flags, enabling dynamic composition of complex states directly within the shader without interfering with existing flags. It acts as the 'builder' in bitmasking techniques.
Common Uses
Dynamically building a final material flag from multiple conditions within the shader.
Adding new properties to a state value in a compute shader (e.g., adding an 'infected' state to a cell).
Combining different rendering layer masks.
Accumulating multiple input states (like key presses) into a single state word.
How to adjust
This node combines two integer inputs, and its output is another integer representing the union of the input flags. Adjusting the inputs changes which bits are 'on' in the resulting integer. This output value is typically then used by `bitAnd` to control which combination of visual effects (e.g., texturing, distortion) is active.
Code Examples
1// Calculate individual flags based on conditions
2const textureFlag = mul( enableTexture, FLAG_TEXTURE );
3const distortionFlag = mul( enableDistortion, FLAG_DISTORTION );
4
5// Use bitOr to merge them into a single flags integer
6const finalFlags = bitOr( textureFlag, distortionFlag );