I am converting a random number generator from GLSL to WGSL, and it uses the function uintBitsToFloat
. What's the equivalent in WGSL? Example use, from https://www.shadertoy.com/view/Mt3cRX:
uint Hash_Wang(uint key) {
key = (key ^ 61u) ^ (key >> 16u);
key = key + (key << 3u);
key = key ^ (key >> 4u);
key = key * 0x27D4EB2Du;
key = key ^ (key >> 15u);
return key;
}
float UniformUintToFloat(uint u) {
// IEEE-754: 2^-32 = 0x2F800000
return float(u) * uintBitsToFloat(0x2F800000u);
}