Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions src/nodes/accessors/StorageTextureNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,27 @@ class StorageTextureNode extends TextureNode {

}

/**
* Stores a value in this storage texture at the given coordinates.
*
* @param {Node<vec2|vec3>} uvNode - The storage texture coordinates.
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
* @return {StorageTextureNode} A storage texture node representing the store operation.
*/
store( uvNode, storeNode ) {

const node = this.clone();

node.referenceNode = this.getBase();
node.uvNode = uvNode;
node.storeNode = storeNode;

if ( storeNode !== null ) node.toStack();

return node;

}

/**
* Generates the code snippet of the storage texture node.
*
Expand Down Expand Up @@ -280,7 +301,7 @@ export const storageTexture = /*@__PURE__*/ nodeProxy( StorageTextureNode ).setP
*
* @tsl
* @function
* @param {StorageTexture} value - The storage texture.
* @param {StorageTexture|StorageTextureNode} value - The storage texture.
* @param {Node<vec2|vec3>} uvNode - The uv node.
* @param {?Node} [storeNode=null] - The value node that should be stored in the texture.
* @returns {StorageTextureNode}
Expand All @@ -291,18 +312,15 @@ export const textureStore = ( value, uvNode, storeNode ) => {

if ( value.isStorageTextureNode === true ) {

// Derive new storage texture node from existing one
node = value.clone();
node.uvNode = uvNode;
node.storeNode = storeNode;
node = value.store( uvNode, storeNode );

} else {

node = storageTexture( value, uvNode, storeNode );

}
if ( storeNode !== null ) node.toStack();

if ( storeNode !== null ) node.toStack();
}

return node;

Expand Down