three.js icon indicating copy to clipboard operation
three.js copied to clipboard

WebGPURenderer: Improve `RenderObject` grouping - WIP

Open sunag opened this issue 2 months ago • 3 comments

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 RenderObject grouping

    • [ ] Add a key related to the object to separate properties relevant to shader creation, such as object.morphTargetInfluences and object.count for filterObjects, RenderObjects.get and RenderObject.getChainArray().
    • [ ] Remove the term RenderObject.instances and leave only RenderObject.objects
    • [ ] Implement the dispose logic
  • [ ] Create shared buffer

    • [ ] Create an extended buffer class designed to couple multiple uniforms.
    • [x] Integrate shared buffer initially for modelWorldMatrix and modelNormalMatrix.
      • [x] Introduce objectIndex
      • [x] Introduce mediumpModelWorldMatrix
      • [x] Introduce mediumpModelNormalMatrix
    • [x] The buffer node 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] buffer does not have an integrated updateRanges range, which can be a problem if used in conjunction with instances since InstanceNode does 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

sunag avatar Nov 11 '25 13:11 sunag