floatBitsToInt
Bitcasts a float or float vector to the corresponding integer type of the same width. No numeric conversion.
Core Advantages
Zero‑cost reinterpret cast. Enables integer/bitwise ops, packing, and low‑level buffer/image I/O while preserving IEEE‑754 payloads (NaN/Inf).
Common Uses
Pack float values as integers for SSBO/image stores or data textures.
Combine with bitwise ops (and/or/xor, shifts, masks) to extract sign, exponent, and mantissa.
Create reproducible integer hashes/seeds or sort keys.
Debug: visualize bit patterns or detect special values (NaN, Inf).
How to adjust
Accepts any float/vecN and returns int/ivecN. To feed float-only slots, convert back with float(...) or normalize; for bit work, compose with bitwise nodes (and/or/xor, shifts). Note: this is a bitcast, not the numeric cast int(...); assumes 32‑bit types; vectors are processed per component. Backend availability depends on the target compiler.
Code Examples
1// Bitcast view‑space normal.x to int and visualize its bit pattern
2const bits = floatBitsToInt( normalView.x );
3// Normalize to [0,1] for display (debug only)
4const normalized = abs( float( bits ) / 2147483647.0 );
5output.color.rgb = vec3( normalized );