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

Updated skinning shader chunks to use the bind matrices.

Ian Kerr 11 жил өмнө
parent
commit
083a42ca20

+ 4 - 1
src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl

@@ -1,5 +1,8 @@
 #ifdef USE_SKINNING
 
+	uniform mat4 bindMatrix;
+	uniform mat4 bindMatrixInverse;
+
 	#ifdef BONE_TEXTURE
 
 		uniform sampler2D boneTexture;
@@ -41,4 +44,4 @@
 
 	#endif
 
-#endif
+#endif

+ 4 - 3
src/renderers/shaders/ShaderChunk/skinning_vertex.glsl

@@ -2,11 +2,11 @@
 
 	#ifdef USE_MORPHTARGETS
 
-	vec4 skinVertex = vec4( morphed, 1.0 );
+	vec4 skinVertex = bindMatrix * vec4( morphed, 1.0 );
 
 	#else
 
-	vec4 skinVertex = vec4( position, 1.0 );
+	vec4 skinVertex = bindMatrix * vec4( position, 1.0 );
 
 	#endif
 
@@ -15,5 +15,6 @@
 	skinned += boneMatY * skinVertex * skinWeight.y;
 	skinned += boneMatZ * skinVertex * skinWeight.z;
 	skinned += boneMatW * skinVertex * skinWeight.w;
+	skinned  = bindMatrixInverse * skinned;
 
-#endif
+#endif

+ 2 - 1
src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl

@@ -5,6 +5,7 @@
 	skinMatrix += skinWeight.y * boneMatY;
 	skinMatrix += skinWeight.z * boneMatZ;
 	skinMatrix += skinWeight.w * boneMatW;
+	skinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;
 
 	#ifdef USE_MORPHNORMALS
 
@@ -16,4 +17,4 @@
 
 	#endif
 
-#endif
+#endif