Main repository of MikuMikuStudio
Revision | a3912f1cf39ec16fccf16d607407ad30f7e420ea (tree) |
---|---|
Time | 2013-05-28 06:29:35 |
Author | shadowisLORD <shadowisLORD@75d0...> |
Commiter | shadowisLORD |
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10633 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -11,56 +11,62 @@ attribute vec4 inBoneIndex; | ||
11 | 11 | uniform mat4 m_BoneMatrices[NUM_BONES]; |
12 | 12 | |
13 | 13 | void Skinning_Compute(inout vec4 position){ |
14 | + if (inBoneWeight.x != 0.0) { | |
14 | 15 | #if NUM_WEIGHTS_PER_VERT == 1 |
15 | - position = m_BoneMatrices[int(inBoneIndex.x)] * position; | |
16 | + position = m_BoneMatrices[int(inBoneIndex.x)] * position; | |
16 | 17 | #else |
17 | - mat4 mat = mat4(0.0); | |
18 | - mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x; | |
19 | - mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y; | |
20 | - mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z; | |
21 | - mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w; | |
22 | - position = mat * position; | |
18 | + mat4 mat = mat4(0.0); | |
19 | + mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x; | |
20 | + mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y; | |
21 | + mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z; | |
22 | + mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w; | |
23 | + position = mat * position; | |
23 | 24 | #endif |
25 | + } | |
24 | 26 | } |
25 | 27 | |
26 | 28 | void Skinning_Compute(inout vec4 position, inout vec3 normal){ |
29 | + if (inBoneWeight.x != 0.0) { | |
27 | 30 | #if NUM_WEIGHTS_PER_VERT == 1 |
28 | - position = m_BoneMatrices[int(inBoneIndex.x)] * position; | |
29 | - normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz, | |
30 | - m_BoneMatrices[int(inBoneIndex.x)][1].xyz, | |
31 | - m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal); | |
31 | + position = m_BoneMatrices[int(inBoneIndex.x)] * position; | |
32 | + normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz, | |
33 | + m_BoneMatrices[int(inBoneIndex.x)][1].xyz, | |
34 | + m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal); | |
32 | 35 | #else |
33 | - mat4 mat = mat4(0.0); | |
34 | - mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x; | |
35 | - mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y; | |
36 | - mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z; | |
37 | - mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w; | |
38 | - position = mat * position; | |
36 | + mat4 mat = mat4(0.0); | |
37 | + mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x; | |
38 | + mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y; | |
39 | + mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z; | |
40 | + mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w; | |
41 | + position = mat * position; | |
39 | 42 | |
40 | - mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz); | |
41 | - normal = rotMat * normal; | |
43 | + mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz); | |
44 | + normal = rotMat * normal; | |
42 | 45 | #endif |
46 | + } | |
43 | 47 | } |
44 | 48 | |
45 | 49 | void Skinning_Compute(inout vec4 position, inout vec3 tangent, inout vec3 normal){ |
50 | + if (inBoneWeight.x != 0.0) { | |
46 | 51 | #if NUM_WEIGHTS_PER_VERT == 1 |
47 | - position = m_BoneMatrices[int(inBoneIndex.x)] * position; | |
48 | - tangent = m_BoneMatrices[int(inBoneIndex.x)] * tangent; | |
49 | - normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz, | |
50 | - m_BoneMatrices[int(inBoneIndex.x)][1].xyz, | |
51 | - m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal); | |
52 | + position = m_BoneMatrices[int(inBoneIndex.x)] * position; | |
53 | + tangent = m_BoneMatrices[int(inBoneIndex.x)] * tangent; | |
54 | + normal = (mat3(m_BoneMatrices[int(inBoneIndex.x)][0].xyz, | |
55 | + m_BoneMatrices[int(inBoneIndex.x)][1].xyz, | |
56 | + m_BoneMatrices[int(inBoneIndex.x)][2].xyz) * normal); | |
52 | 57 | #else |
53 | - mat4 mat = mat4(0.0); | |
54 | - mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x; | |
55 | - mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y; | |
56 | - mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z; | |
57 | - mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w; | |
58 | - position = mat * position; | |
58 | + mat4 mat = mat4(0.0); | |
59 | + mat += m_BoneMatrices[int(inBoneIndex.x)] * inBoneWeight.x; | |
60 | + mat += m_BoneMatrices[int(inBoneIndex.y)] * inBoneWeight.y; | |
61 | + mat += m_BoneMatrices[int(inBoneIndex.z)] * inBoneWeight.z; | |
62 | + mat += m_BoneMatrices[int(inBoneIndex.w)] * inBoneWeight.w; | |
63 | + position = mat * position; | |
59 | 64 | |
60 | - mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz); | |
61 | - tangent = rotMat * tangent; | |
62 | - normal = rotMat * normal; | |
65 | + mat3 rotMat = mat3(mat[0].xyz, mat[1].xyz, mat[2].xyz); | |
66 | + tangent = rotMat * tangent; | |
67 | + normal = rotMat * normal; | |
63 | 68 | #endif |
69 | + } | |
64 | 70 | } |
65 | 71 | |
66 | 72 | #endif |
\ No newline at end of file |