WebGPURenderer: Apply batching matrice before instancing and Expand multiDraw Support #27950
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: #27937
Description
This fix addresses an issue where the batching matrices should be applied before the instancing matrices. It also introduces support for
multiDrawElementsInstancedWEBGL
andmultiDrawArraysInstancedWEBGL
, which offer comparable functionality to the basic multiDraw methods and have the same browser support (95%+).The
WebGPURenderer
andNodes
makes this combination pretty straightforward to achieve and works on both backends, for example this scene is rendered in a single draw call:This enhancement also aims to provide guidance for the
WebGLRenderer
, for example withrenderMultiDrawInstances
.In the future, we might witness the introduction of an
InstancedBatchMesh
or some improvements to theBatchMesh
. The current implementation ofBatchMesh
inefficiently allocates excessive memory by redundantly replicating geometries instead of utilizing a Map for referencing and instancing them.That said, these changes extend to a much wider scope which I do not plan to explore any time soon, unless a bounty or a similar incentive is provided, allowing me the time to do so.
This contribution is funded by Utsubo