Capítulo 486 de 859
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.
StorageBufferNode sets this property to true by default.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 );
Constructor
| Signature |
|---|
| `new StorageBufferNode( value : StorageBufferAttribute |
Properties
| Property | Description |
|---|---|
.access : string | The access type of the texture node. |
.global : boolean | StorageBufferNode sets this property to true by default. |
.isAtomic : boolean | Whether the node is atomic or not. |
.isPBO : boolean | Whether the node represents a PBO or not. Only relevant for WebGL. |
.isStorageBufferNode : boolean (readonly) | This flag can be used for type testing. |
.structTypeNode : StructTypeNode | The buffer struct type. |
Methods
| Method | Description |
|---|---|
.element( indexNode : IndexNode ) : StorageArrayElementNode | Enables element access with the given index node. |
.generate( builder : NodeBuilder ) : string | Generates the code snippet of the storage buffer node. |
.generateNodeType( builder : NodeBuilder ) : string | This method is overwritten since the node type from the availability of storage buffers and the attribute data. |
.getAttributeData() : Object | Returns attribute data for this storage buffer node. |
.getHash( builder : NodeBuilder ) : string | This method is overwritten since the buffer data might be shared and thus the hash should be shared as well. |
.getInputType( builder : NodeBuilder ) : string | Overwrites the default implementation to return a fixed value 'indirectStorageBuffer' or 'storageBuffer'. |
.getMemberType( builder : NodeBuilder, name : string ) : string | Returns the type of a member of the struct. |
.getPBO() : boolean | Returns the isPBO value. |
.setAccess( value : string ) : StorageBufferNode | Defines the node access. |
.setAtomic( value : boolean ) : StorageBufferNode | Defines whether the node is atomic or not. |
.setPBO( value : boolean ) : StorageBufferNode | Defines whether this node is a PBO or not. Only relevant for WebGL. |
.toAtomic() : StorageBufferNode | Convenience method for making this node atomic. |
.toReadOnly() : StorageBufferNode | Convenience method for configuring a read-only node access. |