Builtin Library
- ..
- .metadata17 B
- README.md914 B
- bindings.yaml162 B
- shader.wgsl3.3 KB
README.md
compute_particle_update
Reference compute shader for GPU particle simulation. Each particle is 8 floats
[px, py, pz, life, vx, vy, vz, age]; the shader applies velocity, gravity, and
aging every frame — thousands of particles updated entirely on the GPU.
Bindings (see bindings.yaml): particles (read_write array<f32>), params
(read_write array<f32> — [dt, gravity_y, damping, pad]).
damping is the fraction of velocity a particle keeps per 60th of a second, so
the same value produces the same motion whatever rate the shader is dispatched
at: 0.98 keeps 98% of the velocity every 1/60 s at 30 fps and at 144 fps
alike.
Usage: dispatch by identity — it resolves to the shader's stable guid and
auto-compiles on first use (no setup):
compute.dispatch("@builtin::shaders.compute_particle_update", { buffers = { "particles", "params" }, workgroups = { math.ceil(count / 64), 1, 1 } }).