shiftRight
Provides access to the GPU's native 'bitwise right shift' instruction, used to efficiently extract data (unpack) from an integer or perform integer division by a power of 2, equivalent to the `>>` operator in GLSL.
Core Advantages
It maps directly to hardware instructions for extremely fast execution. It is far more efficient than traditional floating-point operations when performing 'divide by a power of 2' or unpacking data from a single integer.
Common Uses
Data Unpacking
Efficient integer division
Reading Flags
How to adjust
Adjusting input 'a' (the dividend) and 'b' (which determines the divisor 2^b) is essentially performing efficient integer division, producing discrete, stepped results suitable for creating pixelated effects or extracting different levels of information from data.
Code Examples
1// Perform a bitwise right shift operation: a >> b
2// 20 >> 2 => 10100 >> 2 => 101 (binary) => 5 (decimal)
3const shiftNode = shiftRight( a, b );