Browse Source

First stab at skinning in normal map shader.

Don't merge yet, still needs testing.
alteredq 13 years ago
parent
commit
672ae308c2
3 changed files with 42 additions and 4 deletions
  1. 0 0
      build/Three.js
  2. 0 0
      build/custom/ThreeExtras.js
  3. 42 4
      src/extras/ShaderUtils.js

File diff suppressed because it is too large
+ 0 - 0
build/Three.js


File diff suppressed because it is too large
+ 0 - 0
build/custom/ThreeExtras.js


+ 42 - 4
src/extras/ShaderUtils.js

@@ -523,14 +523,30 @@ THREE.ShaderUtils = {
 
 				"varying vec3 vWorldPosition;",
 
+				THREE.ShaderChunk[ "skinning_pars_vertex" ],
 				THREE.ShaderChunk[ "shadowmap_pars_vertex" ],
 
 				"void main() {",
 
+					THREE.ShaderChunk[ "skinbase_vertex" ],
+					THREE.ShaderChunk[ "skinnormal_vertex" ],
+
 					// normal, tangent and binormal vectors
 
-					"vNormal = normalMatrix * normal;",
-					"vTangent = normalMatrix * tangent.xyz;",
+					"#ifdef USE_SKINNING",
+
+						"vNormal = normalMatrix * skinnedNormal.xyz;",
+
+						"vec4 skinnedTangent = skinMatrix * vec4( tangent.xyz, 0.0 );",
+						"vTangent = normalMatrix * skinnedTangent.xyz;",
+
+					"#else",
+
+						"vNormal = normalMatrix * normal;",
+						"vTangent = normalMatrix * tangent.xyz;",
+
+					"#endif",
+
 					"vBinormal = cross( vNormal, vTangent ) * tangent.w;",
 
 					"vUv = uv * uRepeat + uOffset;",
@@ -549,13 +565,35 @@ THREE.ShaderUtils = {
 
 						"} else {",
 
-							"displacedPosition = position;",
+							"#ifdef USE_SKINNING",
+
+								"vec4 skinned  = boneMatX * skinVertexA * skinWeight.x;",
+								"skinned 	  += boneMatY * skinVertexB * skinWeight.y;",
+
+								"displacedPosition  = skinned.xyz;",
+
+							"#else",
+
+								"displacedPosition = position;",
+
+							"#endif",
 
 						"}",
 
 					"#else",
 
-						"displacedPosition = position;",
+						"#ifdef USE_SKINNING",
+
+							"vec4 skinned  = boneMatX * skinVertexA * skinWeight.x;",
+							"skinned 	  += boneMatY * skinVertexB * skinWeight.y;",
+
+							"displacedPosition  = skinned.xyz;",
+
+						"#else",
+
+							"displacedPosition = position;",
+
+						"#endif",
 
 					"#endif",
 

Some files were not shown because too many files changed in this diff