-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Description
Description
At the moment we hand each uniform over to the shaders individually. For more complex tasks it is desirable to do this with storageBuffers and structs. Bundling a lot of uniforms in a storageBuffer and then sending them to the GPU in one go is more efficient. By working on the indirectStorageBufferAttribute, I saw how the bindings are created with _getWGSLStructBinding in the WGSLNodeBuilder. I don't think we need any major changes if we generate the struct content with a structBuilder like in my codePen example.
Solution
I have a codePen here that shows how it could work
Link: https://codepen.io/Spiri0/pen/XWvpVWP?editors=0011
Normally in an app I would just update the values of the uniforms, not create new objects everywhere in the update, as is the case here. Forgive me, my main concern here is struct and the array function. @sunag the pointer you created would probably have to point to the struct in the case of a struct.
I use this code directly in my three.webgpu.js and export and import struct and array. However, it is still unsuitable for a PR because the node system integrates significantly more scope with the other uniforms. Since I haven't dealt with the uniforms that intensively yet, I'd like to ask what you think of the approach. @RenauldRohlinger you will probably be interested in this too.
Of course I will continue to work on it, but if the current status inspires you to make good additions or you see better solutions then let me know.
Alternatives
Hand over all uniforms individually to shader like now
Additional context
No response
