StorageTextureNode

Last modified: Jun 30, 2024

This special version of a texture node can be used to write data into a storage texture with a compute shader.

const storageTexture = new THREE.StorageTexture( width, height );

const computeTexture = Fn( ( { storageTexture } ) => {

	const posX = instanceIndex.mod( width );
	const posY = instanceIndex.div( width );
	const indexUV = uvec2( posX, posY );

	// generate RGB values

	const r = 1;
	const g = 1;
	const b = 1;

	textureStore( storageTexture, indexUV, vec4( r, g, b, 1 ) ).toWriteOnly();

} );

const computeNode = computeTexture( { storageTexture } ).compute( width * height );
renderer.computeAsync( computeNode );
export {}

This node can only be used with a WebGPU backend.

Constructor

new StorageTextureNode(value, uvNode, storeNode?)
ParameterTypeDefault Value
valueStorageTexture
uvNodeNode<vec2|vec3>
storeNode?null | Nodenull

Constructs a new storage texture node.

AccessorType

Properties

PropertyTypeDefault Value
storeNodenull | Node
mipLevelnumber
isStorageTextureNodeboolean
accessstring
MethodType

Extends

TextureNode

storageTexture

TSL function for creating a storage texture node.

ParameterTypeDefault Value
valueStorageTexture
uvNodeNode<vec2|vec3>
storeNode?Node

Returns

StorageTextureNode

textureStore

TODO: Explain difference to storageTexture().

ParameterTypeDefault Value
valueStorageTexture
uvNodeNode<vec2|vec3>
storeNode?null | Nodenull

Returns

StorageTextureNode