From 9790e9dc8dccb27c951cc46fcb83b6e9c1442f79 Mon Sep 17 00:00:00 2001 From: thelazylama <67310144+thelazylamaGit@users.noreply.github.com> Date: Tue, 12 May 2026 10:33:09 +1000 Subject: [PATCH] StorageTextureNode: Set referenceNode & add `.store()` function (#33544) --- src/nodes/accessors/StorageTextureNode.js | 32 ++++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/nodes/accessors/StorageTextureNode.js b/src/nodes/accessors/StorageTextureNode.js index c7d00f83fbea3a..97c3cfcdd77b8b 100644 --- a/src/nodes/accessors/StorageTextureNode.js +++ b/src/nodes/accessors/StorageTextureNode.js @@ -226,6 +226,27 @@ class StorageTextureNode extends TextureNode { } + /** + * Stores a value in this storage texture at the given coordinates. + * + * @param {Node} 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. * @@ -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} uvNode - The uv node. * @param {?Node} [storeNode=null] - The value node that should be stored in the texture. * @returns {StorageTextureNode} @@ -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;