Browse Source

use new hash value

aardgoose 6 years ago
parent
commit
d1e8efae1c
2 changed files with 32 additions and 38 deletions
  1. 4 24
      src/renderers/WebGLRenderer.js
  2. 28 14
      src/renderers/webgl/WebGLLights.js

+ 4 - 24
src/renderers/WebGLRenderer.js

@@ -1463,20 +1463,10 @@ function WebGLRenderer( parameters ) {
 			releaseMaterialProgramReference( material );
 			releaseMaterialProgramReference( material );
 
 
 		} else if ( lightsHash.stateID !== lightsStateHash.stateID ||
 		} else if ( lightsHash.stateID !== lightsStateHash.stateID ||
-			lightsHash.directionalLength !== lightsStateHash.directionalLength ||
-			lightsHash.pointLength !== lightsStateHash.pointLength ||
-			lightsHash.spotLength !== lightsStateHash.spotLength ||
-			lightsHash.rectAreaLength !== lightsStateHash.rectAreaLength ||
-			lightsHash.hemiLength !== lightsStateHash.hemiLength ||
-			lightsHash.shadowsLength !== lightsStateHash.shadowsLength ) {
+			lightsHash.value !== lightsStateHash.directionalLength ) {
 
 
 			lightsHash.stateID = lightsStateHash.stateID;
 			lightsHash.stateID = lightsStateHash.stateID;
-			lightsHash.directionalLength = lightsStateHash.directionalLength;
-			lightsHash.pointLength = lightsStateHash.pointLength;
-			lightsHash.spotLength = lightsStateHash.spotLength;
-			lightsHash.rectAreaLength = lightsStateHash.rectAreaLength;
-			lightsHash.hemiLength = lightsStateHash.hemiLength;
-			lightsHash.shadowsLength = lightsStateHash.shadowsLength;
+			lightsHash.value = lightsStateHash.value;
 
 
 			programChange = false;
 			programChange = false;
 
 
@@ -1584,12 +1574,7 @@ function WebGLRenderer( parameters ) {
 		}
 		}
 
 
 		lightsHash.stateID = lightsStateHash.stateID;
 		lightsHash.stateID = lightsStateHash.stateID;
-		lightsHash.directionalLength = lightsStateHash.directionalLength;
-		lightsHash.pointLength = lightsStateHash.pointLength;
-		lightsHash.spotLength = lightsStateHash.spotLength;
-		lightsHash.rectAreaLength = lightsStateHash.rectAreaLength;
-		lightsHash.hemiLength = lightsStateHash.hemiLength;
-		lightsHash.shadowsLength = lightsStateHash.shadowsLength;
+		lightsHash.value = lightsStateHash.value;
 
 
 		if ( material.lights ) {
 		if ( material.lights ) {
 
 
@@ -1661,12 +1646,7 @@ function WebGLRenderer( parameters ) {
 				material.needsUpdate = true;
 				material.needsUpdate = true;
 
 
 			} else if ( material.lights && ( lightsHash.stateID !== lightsStateHash.stateID ||
 			} else if ( material.lights && ( lightsHash.stateID !== lightsStateHash.stateID ||
-				lightsHash.directionalLength !== lightsStateHash.directionalLength ||
-				lightsHash.pointLength !== lightsStateHash.pointLength ||
-				lightsHash.spotLength !== lightsStateHash.spotLength ||
-				lightsHash.rectAreaLength !== lightsStateHash.rectAreaLength ||
-				lightsHash.hemiLength !== lightsStateHash.hemiLength ||
-				lightsHash.shadowsLength !== lightsStateHash.shadowsLength ) ) {
+				lightsHash.value !== lightsStateHash.value ) ) {
 
 
 				material.needsUpdate = true;
 				material.needsUpdate = true;
 
 

+ 28 - 14
src/renderers/webgl/WebGLLights.js

@@ -117,7 +117,8 @@ function WebGLLights() {
 			spotLength: - 1,
 			spotLength: - 1,
 			rectAreaLength: - 1,
 			rectAreaLength: - 1,
 			hemiLength: - 1,
 			hemiLength: - 1,
-			shadowsLength: - 1
+			shadowsLength: - 1,
+			value: 0
 		},
 		},
 
 
 		ambient: [ 0, 0, 0 ],
 		ambient: [ 0, 0, 0 ],
@@ -331,19 +332,32 @@ function WebGLLights() {
 		state.ambient[ 1 ] = g;
 		state.ambient[ 1 ] = g;
 		state.ambient[ 2 ] = b;
 		state.ambient[ 2 ] = b;
 
 
-		state.directional.length = directionalLength;
-		state.spot.length = spotLength;
-		state.rectArea.length = rectAreaLength;
-		state.point.length = pointLength;
-		state.hemi.length = hemiLength;
-
-		state.hash.stateID = state.id;
-		state.hash.directionalLength = directionalLength;
-		state.hash.pointLength = pointLength;
-		state.hash.spotLength = spotLength;
-		state.hash.rectAreaLength = rectAreaLength;
-		state.hash.hemiLength = hemiLength;
-		state.hash.shadowsLength = shadows.length;
+		var hash = state.hash;
+
+		if ( hash.directionalLength !== directionalLength ||
+			hash.pointLength !== pointLength ||
+			hash.spotLength !== spotLength ||
+			hash.rectAreaLength !== rectAreaLength ||
+			hash.hemiLength !== hemiLength ||
+			hash.shadowsLength !== shadows.length ) {
+
+			state.directional.length = directionalLength;
+			state.spot.length = spotLength;
+			state.rectArea.length = rectAreaLength;
+			state.point.length = pointLength;
+			state.hemi.length = hemiLength;
+
+			hash.stateID = state.id;
+			hash.directionalLength = directionalLength;
+			hash.pointLength = pointLength;
+			hash.spotLength = spotLength;
+			hash.rectAreaLength = rectAreaLength;
+			hash.hemiLength = hemiLength;
+			hash.shadowsLength = shadows.length;
+
+			hash.value++;
+
+		}
 
 
 	}
 	}