Skip to content

Conversation

@sunag
Copy link
Collaborator

@sunag sunag commented Nov 11, 2025

Related issue: #30560 (comment), #30560 (comment), #26673 (comment)

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.
    • Integrate shared buffer initially for modelWorldMatrix.
    • 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. WebGPURenderer: Improve cache bindings from node uniforms #32244
    • 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. WebGPURenderer: Add update ranges for bindings #32248
      // Both WebGPU and WebGL backends have UBO max limited to 64kb. Matrix count number bigger than 1000 ( 16 * 4 * 1000 = 64kb ) will fallback to attribute.
      if ( count <= 1000 ) {
      instanceMatrixNode = buffer( instanceMatrix.array, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
      } else {

@github-actions
Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 356.24
86.48
356.24
86.48
+0 B
+0 B
WebGPU 613.34
172.13
614.47
172.52
+1.13 kB
+385 B
WebGPU Nodes 611.95
171.88
613.08
172.27
+1.13 kB
+391 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 488.02
121.25
488.02
121.25
+0 B
+0 B
WebGPU 682.75
187.41
683.88
187.79
+1.13 kB
+380 B
WebGPU Nodes 624.47
170.62
625.6
171
+1.13 kB
+376 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant