Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

@typegpu/noise

🚧 Under Construction 🚧

A set of noise/pseudo-random functions for use in WebGPU/TypeGPU apps.

import { randf } from '@typegpu/noise';

const time = root.createUniform(f32);

const mainFrag = tgpu
  .fragmentFn({
    in: { pos: builtin.position },
    out: vec4f,
  })((input) => {
    randf.seed2(add(input.pos.xy, vec2f(time.$)));

    const val = randf.sample(); // => number
    const normal = randf.onUnitSphere(); // => v3f
    const dir = randf.inUnitCircle(); // => v2f
  });