레퍼런스 createStorage()

createStorage()

This feature requires the p5.webgpu.js addon.
이 API는 실험적입니다

향후 p5.js 버전에서 동작이 변경될 수 있습니다.

Creates a p5.StorageBuffer, which is a block of data that shaders can read from, and compute shaders can also write to. This is only available in WebGPU mode.

To read or write the data inside a shader, use uniformStorage(). To update its contents from JavaScript, call .update() on the result with new data.

Pass an array of objects to store a list of items, each with named properties. The properties can be numbers, arrays of numbers, vectors created with createVector(), or colors created with color(). Inside the shader, each item is accessed by index, and its properties are available by name.

You can also store a plain list of numbers by passing an array of numbers. Inside the shader, each number is accessed by index directly. To create an empty list to be filled in by a compute shader, pass a count instead.

예제

구문

createStorage(dataOrCount)

매개변수

dataOrCount
Number|Array|Float32Array|Object[]: Either a number specifying the count of floats, an array/Float32Array of floats, or an array of objects describing struct elements.

반환값

p5.StorageBuffer: A storage buffer.
Notice any errors or typos? Please let us know. Please feel free to edit src/core/p5.Renderer3D.js and open a pull request!

관련 레퍼런스