Browse Source

WebGLRenderer: Sort by material.id first. See #5077.
webgl_sandbox goes from ~30.000 to ~7.000 calls.

Mr.doob 11 years ago
parent
commit
140dba7529
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/renderers/WebGLRenderer.js

+ 7 - 1
src/renderers/WebGLRenderer.js

@@ -3197,7 +3197,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	function painterSortStable ( a, b ) {
 
-		if ( a.z !== b.z ) {
+		if ( a.material.id !== b.material.id ) {
+		
+			// sort by material first (save on state changes)
+
+			return b.material.id - a.material.id;
+
+		} else if ( a.z !== b.z ) {
 
 			return b.z - a.z;