Skip to content

Commit 140dba7

Browse files
committed
WebGLRenderer: Sort by material.id first. See #5077.
webgl_sandbox goes from ~30.000 to ~7.000 calls.
1 parent 12f07e9 commit 140dba7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/renderers/WebGLRenderer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3197,7 +3197,13 @@ THREE.WebGLRenderer = function ( parameters ) {
31973197

31983198
function painterSortStable ( a, b ) {
31993199

3200-
if ( a.z !== b.z ) {
3200+
if ( a.material.id !== b.material.id ) {
3201+
3202+
// sort by material first (save on state changes)
3203+
3204+
return b.material.id - a.material.id;
3205+
3206+
} else if ( a.z !== b.z ) {
32013207

32023208
return b.z - a.z;
32033209

0 commit comments

Comments
 (0)