-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Batching - is an amazing technique, that enables us to create complex scenes in runtime with loads of objects, and still have reduced number of drawcalls, when used tactically with materials.
We use spatial grid with LoD's. And have to batch/re-batch in runtime, as parts of our scenes can change.
But the sync nature of batching, and the fact it runs on CPU, has a significant drawbacks, where it can lead to significant main thread locks.
We would love if batching would be a bit more simplified in terms of data access - currently it heavily relies on VertexIterator, which abstracts away the underlying data. While it brings convenience abstracting away data variability.
But it makes harder to have raw buffers, that we could do a few things with:
- Have a dedicated WebWorker process, that would be able to accept mesh's data, meshInstance's data and batch them in buffers. This would offload main thread, and even allow speeding up batching by running multiple WebWorkers, benefiting from today's multi-core CPUs.
- Explore other capabilities by using GPU for such tasks, potentially TransformFeedback on WebGL2, and Compute Shaders on WebGPU. While combining buffers together is a fast operation, transforming every vertex by world matrix - is the time consuming part, and could be performed once on the GPU.