buffer
A storage buffer of count records of a struct type, zero-filled.
buffer(type: StructType, count: ScalarArg, opts: {max?: number} = {}): BufferInput
Import buffer from shaders/std.
Kernels name it in their WGSL to read and write it (stars[index].pos). count may be a prop (with max the most it can grow to); only the first count records are processed each frame.
Parameters
| Name | Type | Notes |
|---|---|---|
type | StructType | |
count | ScalarArg | |
opts | {max?: number} | Optional. Default {}. |
Example
const Star = struct('Star', {pos: 'vec2f', vel: 'vec2f'})
inputs: {
stars: buffer(Star, p('count'), {max: 65536}),
move: kernel(wgsl`stars[index].pos += stars[index].vel * dt;`, {over: 'stars'}),
},