uint
Converts data from other types, such as floats or booleans, into an unsigned integer (uint). This operation is achieved by truncating (discarding) the fractional part and is fundamental for performing bitwise operations, array indexing, or any shader operation that requires integer inputs.
Core Advantages
Unlocks integer-exclusive operations in GLSL, such as bitwise shifts (leftShift), AND (and), and OR (or), which are crucial for implementing techniques like data packing, status flagging, and advanced procedural effects.
Common Uses
Packing data using bitwise operations
Calculating indices for arrays or texture arrays
Implementing procedural patterns based on integer math
How to adjust
The uint node itself has no parameters to adjust. Its output is controlled by manipulating the input node. For example, multiplying a continuous signal in the 0-1 range (like uv().x) by a factor (e.g., 10) before the uint conversion will transform the smooth gradient into 10 discrete integer steps. A larger factor creates more, denser steps.
Code Examples
1// Convert a float value to a uint for integer operations
2const myUint = uint( myFloatNode );
3
4// Perform a bitwise operation on it (not possible with floats)
5const result = myUint.leftShift( uint( 1 ) );