레퍼런스 buildComputeShader()

buildComputeShader()

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 or createStorageList to construct initial data. Connect your iteration function to the storage by passing the storage into uniformStorage.

Often, compute shaders are paired with instances(count) to draw one instance per object in the storage, and a shader that uses instanceIndex to position each instance.

예제

구문

buildComputeShader(callback, [scope])
buildComputeShader(hooks, [scope])

매개변수

callback
Function: A function building a p5.strands compute shader.
scope
Object: An optional scope object passed to .modify().
hooks
Object: An object specifying p5.strands hooks in WGSL.

반환값

p5.Shader: The compute shader.

관련 레퍼런스