I had no idea where to put this but let me leave this here as a quick update. @sunag
I found that WebGPURenderer seems to take a long time to compile shaders when it attempts to render models with a large amount of morphs.
It seems the stall is more obvious on Windows (NVIDIA GPU?).
Tested with this model (note that redistribution is prohibited):
Though it’s a VRM file, loading it as a mere glTF file safely reproduces the issue.
webgpu_loader_gltf.html
example should reproduce by modifying the model URL.
On my environment (Core i9 13900HK, RTX 4070 Laptop, Chrome 120 and 121), Loading this model stalls the tab for 6-7 seconds.
One possible solution is that, I’m wondering if it’s possible to use a LoopNode to iterate over morph targets.
We currently iterate over morph targets on JS side, which generates a massive code. I suspect this causes the shader compilation time issue when we have a lot of morphs in the model. Low confidence.
The current r160
MorphNode implementation:
The generated code:
To achieve the WGSL side loop, I think we currently have two problems:
- There is no way to give a uniform array to a shader.
- We don’t have a way to handle arrays in the shader.
- If it’s possible to pass a uniform array, we can iterate over weights on the WGSL side loop.
- TextureNode always creates an implicit variable, and this creates a large number of variables if we iterate over on the JS side.
- I think we can omit the behavior as texture sampling is not the only case that should use temporary variables for performance, and end developers should already know that.