three.js
three.js copied to clipboard
WebGPURenderer: Improve `RenderObject` grouping - WIP
Related issue: https://github.com/mrdoob/three.js/issues/30560#issuecomment-3510462194, https://github.com/mrdoob/three.js/issues/30560#issuecomment-3514757943, https://github.com/mrdoob/three.js/issues/26673#issuecomment-3293683760
Description
This is a WIP.
The basic idea is to group the RenderObject so that we can handle similar objects.
Today we have a lot of redundant calls between similar objects in the rendering call that could be resolved in just one Backend.draw().
-
[ ] Improve
RenderObjectgrouping- [ ] Add a key related to the object to separate properties relevant to shader creation, such as
object.morphTargetInfluencesandobject.countforfilterObjects,RenderObjects.getandRenderObject.getChainArray(). - [ ] Remove the term
RenderObject.instancesand leave onlyRenderObject.objects - [ ] Implement the dispose logic
- [ ] Add a key related to the object to separate properties relevant to shader creation, such as
-
[ ] Create shared buffer
- [ ] Create an extended
bufferclass designed to couple multiple uniforms. - [x] Integrate shared buffer initially for
modelWorldMatrixandmodelNormalMatrix.- [x] Introduce
objectIndex - [x] Introduce
mediumpModelWorldMatrix - [x] Introduce
mediumpModelNormalMatrix
- [x] Introduce
- [x] The
buffernode is not being shared properly when shared with other materials, causing the buffer to be updated more than once in the same render call. https://github.com/mrdoob/three.js/pull/32244 - [x]
bufferdoes not have an integratedupdateRangesrange, which can be a problem if used in conjunction withinstancessinceInstanceNodedoes not distinguish it with an attribute. https://github.com/mrdoob/three.js/pull/32248 https://github.com/mrdoob/three.js/blob/8173be8f500b1a8369c6d6aa25a0a0b700b4cafb/src/nodes/accessors/InstanceNode.js#L120-L126
- [ ] Create an extended