StorageBufferNode

Last modified: Jun 30, 2024

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?)
ParameterTypeDefault Value
valueany
bufferType?anynull
bufferCount?number0

Constructs a new storage buffer node.

AccessorType

Properties

PropertyTypeDefault Value
isStorageBufferNodeboolean
structTypeNodeany
accessstring
isAtomicboolean
isPBOboolean
_attributeany
_varyingany
MethodType

Extends

BufferNode

storage

TSL function for creating a storage buffer node.

ParameterTypeDefault Value
valueany
type?anynull
count?number0

Returns

StorageBufferNode