bitAnd
Performs a bitwise AND (&) operation, primarily used to efficiently check and extract multiple state flags packed into a single integer.
Core Advantages
Saves uniform resources and data bandwidth by packing multiple boolean states into one integer, while leveraging high-performance native GPU bitwise operations.
Common Uses
Dynamically toggling material properties (e.g., enabling/disabling texture maps, emission).
Selecting different rendering paths within an Uber-Shader.
Unpacking composite data from a single integer (e.g., extracting a tile ID and its state from one value).
Checking game logic states in the shader to trigger specific visual effects (e.g., 'is invincible').
How to adjust
This node produces a binary (on/off) logical result, not a gradual visual change. By modifying the input 'flags' integer (often a uniform), you can enable or disable different logic branches or visual effects, like flipping switches. Different integer values allow for various combinations of enabled effects.
Code Examples
1// Check the 'use texture' flag
2if ( bitAnd( flags, 1 ).greaterThan( 0 ) ) {
3 finalColor = texture( myMap, uv() ).rgb;
4}