Skip to content

Instantly share code, notes, and snippets.

View huntercaron's full-sized avatar
♻️

Hunter Caron huntercaron

♻️
View GitHub Profile
@mattdesl
mattdesl / random.wgsl
Last active June 20, 2025 09:51
high quality deterministic PRNG in WebGPU & WGSL (xorshift128) - MIT licensed
// each pixel is assigned 4 random u32 values per frame
@group(0) @binding(1)
var<storage, read> rnd_state: array<u32>;
// the current state within this pixel
var<private> local_rnd_state:vec4u;
fn random_u32(state:ptr<private,vec4u>) -> u32 {
var st:vec4u = *state;
/* Algorithm "xor128" from p. 5 of Marsaglia, "Xorshift RNGs" */