intBitsToFloat
intBitsToFloat
Bitcasts an integer or integer vector to the corresponding float type with the exact same bit pattern—no numeric conversion.
Core Advantages
Zero‑cost bit reinterpretation that preserves every bit; plugs directly into integer sources (Int32BufferAttribute, uniform(int)), avoiding CPU/GPU round‑trips or precision loss.
Common Uses
Recover float parameters from int vertex/instance attributes (compressed weights, thresholds)
Pair with floatBitsToInt for bit‑twiddling (sign/masks/flags)
Restore 32‑bit floats stored as ints in buffers/textures
Deterministic RNG seeds/hashes via bit reinterpretation
How to adjust
The function has no knobs; adjust the input integer bit pattern instead. Ensure 32‑bit width; invalid patterns may yield NaN/∞. Use floatBitsToInt for the inverse.
Code Examples
1
2// Example: Int32BufferAttribute carries raw 32‑bit float bit patterns
3const encoded = attribute( 'encodedFloatBits', 'int' );
4
5// Reinterpret bits as float on the GPU
6const decoded = intBitsToFloat( encoded );
7
8// Drive opacity or color with the restored value
9material.opacityNode = decoded.saturate();
10// material.colorNode = vec3( decoded.remap( 0.0, 10.0, 0.0, 1.0 ) );
11