Open mvaligursky opened 2 years ago
I notice we have UniformBuffer
class in the engine now. Can this be closed yet?
Not yet I think. We have Uniform Buffers, but their integration is limited to Scene and Mesh Uniform Buffers, and we still need to implement Material Uniform buffers.
Additionally, this is only WebGPU implementation, and we need WebGL2 implementation using Uniform Buffer Objects.
We could spin up separate tickets for this, but at the moment this covers all this work.
Webgl2 Uniform Buffer Objects support would be great!!
Uniform Buffer Objects let you specify a bunch of uniforms from a buffer. The advantages are:
Also, WebGPU allows uniforms to only be set using uniform buffers.
Basic design: UniformBufferFormat - describes the content of the buffer (similar to VertexFormat) - list of uniforms and their types and so on. UniformBuffer - an actual buffer, storing uniforms in a format described by UniformBufferFormat
WebGPU specifically has API that connects multiple uniform buffers as well as other buffer objects (textures) into a binding, and all of those can be set on a device (assigned to a bind slot) by a single call. The engine will support this as a way of setting up textures and uniform buffers as well. Design: BindGroupFormat - describes the format as an array of uniform buffers / textures. BindGroup - an actual instance of the BindGroupFormat, attaching actual uniform buffers and textures into the bind group. This can then be set on device using a single call.
In general, the engine will use 3 sets of BindGroups: