File: StorageBufferNode.md | Updated: 11/15/2025
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 );
Constructs a new storage buffer node.
value | The buffer data.
---|---
bufferType | The buffer type (e.g. 'vec3'). Default is null.
bufferCount | The buffer count. Default is 0.
The access type of the texture node.
Default is 'readWrite'.
StorageBufferNode sets this property to true by default.
Default is true.
Overrides: BufferNode#global
Whether the node is atomic or not.
Default is false.
Whether the node represents a PBO or not. Only relevant for WebGL.
Default is false.
This flag can be used for type testing.
Default is true.
The buffer struct type.
Default is null.
Enables element access with the given index node.
indexNode | The index node.
---|---
Returns: A node representing the element access.
Generates the code snippet of the storage buffer node.
builder | The current node builder.
---|---
Overrides: BufferNode#generate
Returns: The generated code snippet.
Returns attribute data for this storage buffer node.
Returns: The attribute data.
This method is overwritten since the buffer data might be shared and thus the hash should be shared as well.
builder | The current node builder.
---|---
Overrides: BufferNode#getHash
Returns: The hash.
Overwrites the default implementation to return a fixed value 'indirectStorageBuffer' or 'storageBuffer'.
builder | The current node builder.
---|---
Overrides: BufferNode#getInputType
Returns: The input type.
Returns the type of a member of the struct.
builder | The current node builder.
---|---
name | The name of the member.
Overrides: BufferNode#getMemberType
Returns: The type of the member.
This method is overwritten since the node type from the availability of storage buffers and the attribute data.
builder | The current node builder.
---|---
Overrides: BufferNode#getNodeType
Returns: The node type.
Returns the isPBO value.
Returns: Whether the node represents a PBO or not.
Defines the node access.
value | The node access.
---|---
Returns: A reference to this node.
Defines whether the node is atomic or not.
value | The atomic flag.
---|---
Returns: A reference to this node.
Defines whether this node is a PBO or not. Only relevant for WebGL.
value | The value so set.
---|---
Returns: A reference to this node.
Convenience method for making this node atomic.
Returns: A reference to this node.
Convenience method for configuring a read-only node access.
Returns: A reference to this node.