2
0
Эх сурвалжийг харах

handle normal matrix for InstancedMesh

WestLangley 5 жил өмнө
parent
commit
853a1812a8

+ 8 - 1
src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js

@@ -3,7 +3,14 @@ vec3 transformedNormal = objectNormal;
 
 
 #ifdef USE_INSTANCING
 #ifdef USE_INSTANCING
 
 
-	transformedNormal = mat3( instanceMatrix ) * transformedNormal;
+	// this is in lieu of a per-instance normal-matrix
+	// shear transforms in the instance matrix are not supported
+
+	mat3 m = mat3( instanceMatrix );
+
+	transformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );
+
+	transformedNormal = m * transformedNormal;
 
 
 #endif
 #endif