Open
Description
Description
When using the WebGPURenderer
with { forceWebGL: true }
, the instancedArray.element()
function in Three.js TSL always returns the same value, regardless of the index passed. This breaks dynamic indexing in shaders.
Only occurs with WebGPURenderer
using the WebGL backend (i.e., { forceWebGL: true }
).
Affected expressions (all return the same result):
instancedArray.element(instanceIndex)
instancedArray.element(0)
instancedArray.element(1)
instancedArray.element(int(1))
instancedArray.element(float(1))
Expected behavior:
Each index should return the corresponding element from the array.
Reproduction steps
- Set the
WebGPURenderer
to{ forceWebGL: true }
- Create an instancedArray with multiple elements
- Use instancedArray.element() with different index parameters in a compute shader
- Observe that all calls return the same element regardless of index
Expected: Different indices should return different array elements
Code
const array = instancedArray(1000, "vec3");
Fn(() => {
const a = array.element(0);
const b = array.element(1);
const c = array.element(instanceIndex);
// All three return the same value in WebGL
});
Live example
This is a modified version of the official WebGPU compute points example, using { forceWebGL: true }
. Replacing instanceIndex
with any constant still yields the same result:
🔗 https://jsfiddle.net/fzjbs1a6/
Screenshots
No response
Version
r177
Device
Desktop
Browser
Chrome
OS
Linux