This feature requires the p5.webgpu.js addon.
此 API 是实验性的
其行为可能在 p5.js 的未来版本中发生变化。
Create a new compute shader using p5.strands.
A compute shader lets you run many calculations all at once on your GPU. They are similar to a compute() and passing the shader in, along with the number of iterations in up to three dimensions. Use the index vector inside of your iteration function to refer to the current iteration of the loop. The x, y, and z properties will count up from zero to the count in each dimension passed into compute.
A compute shader will read from and write to storage, which is often an array of numbers or objects. Use createStorage to construct initial data. Connect your iteration function to the storage by passing the storage into uniformStorage.
Often, compute shaders are paired with model(myGeometry, count) to draw one instance per object in the storage, and a shader that uses instanceID() to position each instance.
示例
语法
buildComputeShader(callback)