This node is used in context of compute shaders and allows to define a
storage buffer for data. A typical workflow is to create instances of
this node with the convenience functions attributeArray() or instancedArray(),
setup up a compute shader that writes into the buffers and then convert
the storage buffers to attribute nodes for rendering.
const positionBuffer = instancedArray( particleCount, 'vec3' ); // the storage buffer node
const computeInit = Fn( () => { // the compute shader
const position = positionBuffer.element( instanceIndex );
// compute position data
position.x = 1;
position.y = 1;
position.z = 1;
} )().compute( particleCount );
const particleMaterial = new THREE.SpriteNodeMaterial();
particleMaterial.positionNode = positionBuffer.toAttribute();
renderer.computeAsync( computeInit );
export {}Constructor
new StorageBufferNode(value, bufferType?, bufferCount?)| Parameter | Type | Default Value |
|---|---|---|
| value | any | — |
| bufferType? | any | null |
| bufferCount? | number | 0 |
Constructs a new storage buffer node.
| Accessor | Type | |
|---|---|---|
| get type | string | |
Properties
| Property | Type | Default Value | |
|---|---|---|---|
| isStorageBufferNode | boolean | — | |
| structTypeNode | any | — | |
| access | string | — | |
| isAtomic | boolean | — | |
| isPBO | boolean | — | |
| _attribute | any | — | |
| _varying | any | — | |
| Method | Type | |
|---|---|---|
| getHash | (builder: NodeBuilder) => string | |
| getInputType | () => string | |
| element | (indexNode: IndexNode) => StorageArrayElementNode | |
| setPBO | (value: boolean) => StorageBufferNode | |
| getPBO | () => boolean | |
| setAccess | (value: string) => StorageBufferNode | |
| toReadOnly | () => StorageBufferNode | |
| setAtomic | (value: boolean) => StorageBufferNode | |
| toAtomic | () => StorageBufferNode | |
| getAttributeData | () => { attribute: BufferAttributeNode; varying: VaryingNode; } | |
| generateNodeType | (builder: NodeBuilder) => string | |
| getMemberType | (builder: NodeBuilder, name: string) => string | |
| generate | (builder: NodeBuilder) => string | |
Extends
BufferNodeTSL function for creating a storage buffer node.
| Parameter | Type | Default Value |
|---|---|---|
| value | any | — |
| type? | any | null |
| count? | number | 0 |
Returns
StorageBufferNode