WebGLRenderer: Consider skinning / instancing when sorting objects.#28125
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
79a5ace to
d90f2cc
Compare
|
I did not have the opportunity so far to review this change, sorry. At first sight I do not understand why it's necessary to alter the render lists for your use case so this needs some time for testing and debugging. |
|
When you have a scene where the same material is used for instanced and non-instanced geometry, the sorting currently sorts by material only. As a result, you can get your instanced and non-instanced geometry with the same material rendered in any order, like: After the change the order is: The number of program changes is reduced from 7 to 3. With skinned it works the same way. |
|
@Mugen87 This is hanging here for quite a long time. It is a fix of a minor performance issue. Could someone please check it and provide a feedback? |
|
I agree this makes sense so let's give it a try. Sorry that this one got lost. |
|
Thanks for merging this. I understand it is a minor optimization which applies to a situation which is not very common, but the impact was measurable in my scenario. |
Description
Since #20135 a single material may be represented by multiple programs. In my scene I use the same material with instanced and non-instanced geometry. As a result I see frequent
needsProgramChange = trueinWebGLRenderer.setProgram.This PR adds skinning and instancing as a secondary criterion for sorting into the default
painterSortStablejust after the material id.