github gpujs/gpu.js 2.18.0

latest releases: 2.19.2, 2.19.1, 2.19.0...
7 hours ago

Feature release: reproducible Math.random() via custom seeds.

Added

  • Custom seed for Math.random() (#850). Seed a kernel with kernel.setRandomSeed(seed) or the randomSeed kernel setting:

    const kernel = gpu.createKernel(function() {
      return Math.random();
    }, { output: [64], randomSeed: 42 });

    A seeded kernel draws its per-run GPU seed uniforms from a deterministic stream (mulberry32): consecutive runs differ, but recreating the kernel — or calling setRandomSeed again — with the same seed replays the exact same sequence of runs. Unseeded kernels behave exactly as before.

    Applies to GPU modes (gpu, webgl, webgl2, headlessgl); cpu mode logs a warning and stays unseeded. TypeScript definitions included.

Installing

npm install gpu.js@2.18.0
<script src="https://unpkg.com/gpu.js@2.18.0/dist/gpu-browser.min.js"></script>

Don't miss a new gpu.js release

NewReleases is sending notifications on new releases.