OSDN Git Service

* Fixed bug where verts uninfluenced by bones would not work correctly in hardware...
authorshadowisLORD <shadowisLORD@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 27 May 2013 21:29:35 +0000 (21:29 +0000)
committershadowisLORD <shadowisLORD@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Mon, 27 May 2013 21:29:35 +0000 (21:29 +0000)
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10633 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

engine/src/core-data/Common/ShaderLib/Skinning.glsllib

index 6452b34..399e9e3 100644 (file)
@@ -11,56 +11,62 @@ attribute vec4 inBoneIndex;
 uniform mat4 m_BoneMatrices[NUM_BONES];\r
  \r
 void Skinning_Compute(inout vec4 position){\r
+    if (inBoneWeight.x != 0.0) {\r
 #if NUM_WEIGHTS_PER_VERT == 1\r
-    position = m_BoneMatrices[int(inBoneIndex.x)] * position;\r
+        position = m_BoneMatrices[int(inBoneIndex.x)] * position;\r
 #else\r
-    mat4 mat = mat4(0.0);\r
-    mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x;\r
-    mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y;\r
-    mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z;\r
-    mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w;\r
-    position = mat * position;\r
+        mat4 mat = mat4(0.0);\r
+        mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x;\r
+        mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y;\r
+        mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z;\r
+        mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w;\r
+        position = mat * position;\r
 #endif\r
+    }\r
 }\r
  \r
 void Skinning_Compute(inout vec4 position, inout vec3 normal){\r
+    if (inBoneWeight.x != 0.0) {\r
 #if NUM_WEIGHTS_PER_VERT == 1\r
-    position = m_BoneMatrices[int(inBoneIndex.x)] * position;\r
-    normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz,\r
-                   m_BoneMatrices[int(inBoneIndex.x)][1].xyz,\r
-                   m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal);\r
+        position = m_BoneMatrices[int(inBoneIndex.x)] * position;\r
+        normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz,\r
+                       m_BoneMatrices[int(inBoneIndex.x)][1].xyz,\r
+                       m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal);\r
 #else\r
-    mat4 mat = mat4(0.0);\r
-    mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x;\r
-    mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y;\r
-    mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z;\r
-    mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w;\r
-    position = mat * position;\r
+        mat4 mat = mat4(0.0);\r
+        mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x;\r
+        mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y;\r
+        mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z;\r
+        mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w;\r
+        position = mat * position;\r
 \r
-    mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);\r
-    normal = rotMat * normal;\r
+        mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);\r
+        normal = rotMat * normal;\r
 #endif\r
+    }\r
 }\r
  \r
 void Skinning_Compute(inout vec4 position, inout vec3 tangent, inout vec3 normal){\r
+    if (inBoneWeight.x != 0.0) {\r
 #if NUM_WEIGHTS_PER_VERT == 1\r
-    position = m_BoneMatrices[int(inBoneIndex.x)] * position;\r
-    tangent = m_BoneMatrices[int(inBoneIndex.x)] * tangent;\r
-    normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz,\r
-                   m_BoneMatrices[int(inBoneIndex.x)][1].xyz,\r
-                   m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal);\r
+        position = m_BoneMatrices[int(inBoneIndex.x)] * position;\r
+        tangent = m_BoneMatrices[int(inBoneIndex.x)] * tangent;\r
+        normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz,\r
+                       m_BoneMatrices[int(inBoneIndex.x)][1].xyz,\r
+                       m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal);\r
 #else\r
-    mat4 mat = mat4(0.0);\r
-    mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x;\r
-    mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y;\r
-    mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z;\r
-    mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w;\r
-    position = mat * position;\r
+        mat4 mat = mat4(0.0);\r
+        mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x;\r
+        mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y;\r
+        mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z;\r
+        mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w;\r
+        position = mat * position;\r
 \r
-    mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);\r
-    tangent = rotMat * tangent;\r
-    normal = rotMat * normal;\r
+        mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz);\r
+        tangent = rotMat * tangent;\r
+        normal = rotMat * normal;\r
 #endif\r
+    }\r
 }\r
 \r
 #endif
\ No newline at end of file