Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSL: use vec3 for DataArrayTexture UV coordinates #30583

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

zonkypop
Copy link
Contributor

Description

When using DataArrayTexture with the WebGLBackend, TSL's generateUV by default uses only the .xy for sampling textures, this causes shader compile errors when using a texture node with an DataArrayTexture. This is a simple fix which makes the uvSnippet use a vec3 instead when we have a DataArrayTexture.

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.65
78.39
336.65
78.39
+0 B
+0 B
WebGPU 522.23
144.94
522.28
144.96
+50 B
+20 B
WebGPU Nodes 521.7
144.84
521.75
144.85
+50 B
+20 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 465.64
112.24
465.64
112.24
+0 B
+0 B
WebGPU 592.61
160.56
592.66
160.58
+50 B
+22 B
WebGPU Nodes 547.74
150
547.79
150.02
+50 B
+20 B

@zonkypop
Copy link
Contributor Author

Looks like this breaks a lot 😱

A reproducible example is running: https://threejs.org/examples/?q=webgpu#webgpu_textures_2d-array

In fallback/GL mode with:

material.colorNode = texture( map, coord )

instead of:

material.colorNode = texture( map, coord ).depth( oscLayers ).r.remap( 0, 1, - .1, 1.8 );

adding: .depth( oscLayers ) will fix any compile errors.

I'm not sure if adding the depth there is expected / intentional, or if it is supposed to work with a vec3?

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.

1 participant