random
Function
Returns an f32 in the range [0, 1) hashed from an f32, vec2 or vec3 seed, emitted as fract(sin(dot(seed, k)) * 43758.5453123).
The signature and the sentence under each name are the compiler's own text at commit 26de7be8.
Syntax
declare function random(seed: f32 | vec2 | vec3): f32Parameters
Return value
Description
One seed is one value in the IR and NOT on a GPU: WGSL bounds sin to 2^-11 absolute error on [-PI, PI] and not at all outside it, which is where this hash lives, so the driver decides the answer (surface section 55 has the measurements; #181 replaces the hash with an exact integer one). There is no unseeded form: Math.random() without a seed does not compile.