-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WebGPURenderer: Fix instance meshes that shares the same count #29066
WebGPURenderer: Fix instance meshes that shares the same count #29066
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
I think the next step would be to use and improve |
@@ -263,7 +263,7 @@ export default class RenderObject { | |||
|
|||
if ( object.count > 1 ) { | |||
|
|||
cacheKey += object.count + ','; | |||
cacheKey += object.count + ',' + object.uuid + ','; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is object.count
still needed in the cache key when we are adding uuid?
On that note, I recently conducted extensive benchmarking on the For example, a slightly complex GLTF scene running with WebGPU takes about 10ms per frame to render: More worryingly, it runs at 30fps with 6-7 frames dropped per loop in the WebGLBackend: In contrast, the exact same setup with the WebGLRenderer takes about 3.5ms per frame (almost 3 times faster than WebGPU) and runs at a steady 144fps+: So far, the culprit appears to be anything related to the use of custom setters/getters, such as I haven't opened an issue yet, as I want to fully explain the current problem and propose a solution. I'm openly brainstorming here, but a GLTF scene with 300-400+ meshes runs 2-3 times slower in both backends compared to the WebGLRenderer. I don't think it's a major issue, just a necessary cleanup to catch up after building so much new content recently! /cc @sunag @Mugen87 |
I think it would be helpful to have some kind of |
Description
Currently, if two InstancedMesh objects have the same count, the second InstancedMesh incorrectly inherits the matrices of the first due to a shared cacheKey. This happens because the cacheKey is solely based on object.count.
Fix:
By incorporating the uuid of the InstancedMesh into the cacheKey, we ensure that each InstancedMesh maintains its own unique cache, preventing the unintended sharing of matrices.
Example for test if needed:
instance_webgpu_issue.glb.zip
This contribution is funded by Utsubo