pow2
pow2
Efficiently calculates 2 to the power of x ($2^x$), commonly used for HDR exposure control and scenarios requiring exponential scaling.
Core Advantages
Leverages the GPU's optimized `exp2(x)` function, which is faster and more performant than the generic `pow(2, x)`, especially for real-time rendering tasks like exposure adjustment.
Common Uses
HDR Exposure Control & Tone Mapping
Procedural Textures & Fractal Noise
Data Packing & Bitmasking
How to adjust
Control the output by adjusting the single input parameter `x` (the exponent). Each increment of 1 in `x` doubles the output, and each decrement of 1 halves it. This provides an intuitive, exponential method for brightness control that aligns with the concept of photographic exposure stops.
Code Examples
1// Apply exposure control: color * (2 ^ exposure)
2const exposedColor = baseColor.mul( pow2( exposure ) );