Skip to content

StorageTextureNode: Bypass UV matrix transforms#33545

Merged
sunag merged 1 commit into
mrdoob:devfrom
thelazylamaGit:StorageTextureNode-BypassUVTransform
May 9, 2026
Merged

StorageTextureNode: Bypass UV matrix transforms#33545
sunag merged 1 commit into
mrdoob:devfrom
thelazylamaGit:StorageTextureNode-BypassUVTransform

Conversation

@thelazylamaGit

@thelazylamaGit thelazylamaGit commented May 8, 2026

Copy link
Copy Markdown
Contributor

Since StorageTextureNode extends TextureNode it would inherit it's UV transform path which applies the texture UV matrix to the texture coordinates. This causes the generated WGSL to bring in several mat3x3 uniforms and wrap all textureLoad() / textureStore() texel coordinates in unnecessary mat3x3 transforms.

struct objectStruct {
nodeUniform1 : mat3x3,
nodeUniform3 : mat3x3,
nodeUniform5 : f32,
nodeUniform6 : f32,
nodeUniform10 : mat3x3,
nodeUniform11 : mat3x3,
nodeUniform12 : mat3x3,
nodeUniform13 : mat3x3,
nodeUniform14 : f32,
nodeUniform18 : f32,
nodeUniform19 : mat3x3
};

textureLoad( nodeUniform0, vec2<i32>( ( object.nodeUniform1 * vec3<f32>( vec2<f32>( nodeConst2 ), 1.0 ) ).xy ) );

textureStore( nodeUniform2, vec2<u32>( ( object.nodeUniform3 * vec3<f32>( vec2<f32>( nodeConst2 ), 1.0 ) ).xy ), vec4<f32>( 0.0, 0.0, 0.0, min( 0.0, ( nodeVar0.w + render.nodeUniform4 ) ) ) );

The fix here is simple. Just override the getTransformedUV() call in the StorageTextureNode class.

	/**
	 * Overwrites the default implementation since storage texture
	 * coordinates are texel coordinates and should not be transformed
	 * by the texture uv matrix.
	 *
	 * @param {Node} uvNode - The uv node.
	 * @return {Node} The unmodified uv node.
	 */
	getTransformedUV( uvNode ) {

		return uvNode;

	}

@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 365.32
86.78
365.32
86.78
+0 B
+0 B
WebGPU 656.14
181.31
656.17
181.32
+29 B
+15 B
WebGPU Nodes 654.26
181.03
654.29
181.05
+29 B
+14 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 498.04
121.5
498.04
121.5
+0 B
+0 B
WebGPU 728.21
196.26
728.21
196.26
+0 B
+0 B
WebGPU Nodes 677.43
183.66
677.43
183.66
+0 B
+0 B

@sunag sunag added this to the r185 milestone May 9, 2026
@sunag sunag merged commit fea7baf into mrdoob:dev May 9, 2026
15 of 16 checks passed
@thelazylamaGit thelazylamaGit deleted the StorageTextureNode-BypassUVTransform branch May 11, 2026 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants