Have ideas to improve npm?Join in the discussion! »

glsl-pcg-prng

1.0.2 • Public • Published

glsl-pcg-prng

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.

References:

Install

npm install glsl-pcg-prng

Usage

Note that glsl-pcg-prng needs OpenGL ES 3.0 (WebGL 2.0).

#pragma glslify: prng require(glsl-pcg-prng) 
 
// Create a seed 
vec4 seed = vec3(1000., 2000., 3000., 4000.);
 
// Return one random number, it takes a float or a vec2 as input 
float r1 = prng(seed.x);
float r2 = prng(seed.xy);
 
// Return three random numbers 
vec3 r3 = prng(seed.xyz);
 
// Return four random numbers 
vec4 r4 = prng(seed.xyzw);

Demo

Install

npm i glsl-pcg-prng

DownloadsWeekly Downloads

3

Version

1.0.2

License

MIT

Unpacked Size

4.52 kB

Total Files

5

Last publish

Collaborators

  • avatar