PCG random number generators ported to an NPM package, so that you can require it from glslify. The code is based (mostly copied) from https://www.shadertoy.com/view/XlGcRh by Mark Jarzynski.
- Mark Jarzynski and Marc Olano, Hash Functions for GPU Rendering, Journal of Computer Graphics Techniques (JCGT), vol. 9, no. 3, 21-38, 2020 Available online http://jcgt.org/published/0009/03/02/
npm install glsl-pcg-prng
Note that glsl-pcg-prng needs OpenGL ES 3.0 (WebGL 2.0).
# prng = require(glsl-pcg-prng)// Create a seedvec4 seed = vec3(1000., 2000., 3000., 4000.);// Return one random number, it takes a float or a vec2 as inputfloat r1 = prng(seed.x);float r2 = prng(seed.xy);// Return three random numbersvec3 r3 = prng(seed.xyz);// Return four random numbersvec4 r4 = prng(seed.xyzw);