|
@@ -14,9 +14,17 @@ attribute vec2 uv2;
|
|
|
#ifdef VERTEXCOLOR
|
|
|
attribute vec4 color;
|
|
|
#endif
|
|
|
-#ifdef BONES
|
|
|
-attribute vec4 matricesIndices;
|
|
|
-attribute vec4 matricesWeights;
|
|
|
+#if NUM_BONE_INFLUENCERS > 0
|
|
|
+
|
|
|
+ // having bone influencers implies you have bones
|
|
|
+ uniform mat4 mBones[BonesPerMesh];
|
|
|
+
|
|
|
+ attribute vec4 matricesIndices;
|
|
|
+ attribute vec4 matricesWeights;
|
|
|
+ #if NUM_BONE_INFLUENCERS > 4
|
|
|
+ attribute vec4 matricesIndicesExtra;
|
|
|
+ attribute vec4 matricesWeightsExtra;
|
|
|
+ #endif
|
|
|
#endif
|
|
|
|
|
|
// Uniforms
|
|
@@ -32,10 +40,6 @@ uniform mat4 world;
|
|
|
uniform mat4 view;
|
|
|
uniform mat4 viewProjection;
|
|
|
|
|
|
-#ifdef BONES
|
|
|
-uniform mat4 mBones[BonesPerMesh];
|
|
|
-#endif
|
|
|
-
|
|
|
#ifdef POINTSIZE
|
|
|
uniform float pointSize;
|
|
|
#endif
|
|
@@ -60,26 +64,40 @@ varying float fFogDistance;
|
|
|
#endif
|
|
|
|
|
|
void main(void) {
|
|
|
- mat4 finalWorld;
|
|
|
-
|
|
|
#ifdef INSTANCES
|
|
|
- finalWorld = mat4(world0, world1, world2, world3);
|
|
|
+ mat4 finalWorld = mat4(world0, world1, world2, world3);
|
|
|
#else
|
|
|
- finalWorld = world;
|
|
|
-#endif
|
|
|
-
|
|
|
-#ifdef BONES
|
|
|
- mat4 m0 = mBones[int(matricesIndices.x)] * matricesWeights.x;
|
|
|
- mat4 m1 = mBones[int(matricesIndices.y)] * matricesWeights.y;
|
|
|
- mat4 m2 = mBones[int(matricesIndices.z)] * matricesWeights.z;
|
|
|
-
|
|
|
-#ifdef BONES4
|
|
|
- mat4 m3 = mBones[int(matricesIndices.w)] * matricesWeights.w;
|
|
|
- finalWorld = finalWorld * (m0 + m1 + m2 + m3);
|
|
|
-#else
|
|
|
- finalWorld = finalWorld * (m0 + m1 + m2);
|
|
|
-#endif
|
|
|
-
|
|
|
+ mat4 finalWorld = world;
|
|
|
+#endif
|
|
|
+
|
|
|
+#if NUM_BONE_INFLUENCERS > 0
|
|
|
+ mat4 influence;
|
|
|
+ influence = mBones[int(matricesIndices[0])] * matricesWeights[0];
|
|
|
+
|
|
|
+ #if NUM_BONE_INFLUENCERS > 1
|
|
|
+ influence += mBones[int(matricesIndices[1])] * matricesWeights[1];
|
|
|
+ #endif
|
|
|
+ #if NUM_BONE_INFLUENCERS > 2
|
|
|
+ influence += mBones[int(matricesIndices[2])] * matricesWeights[2];
|
|
|
+ #endif
|
|
|
+ #if NUM_BONE_INFLUENCERS > 3
|
|
|
+ influence += mBones[int(matricesIndices[3])] * matricesWeights[3];
|
|
|
+ #endif
|
|
|
+
|
|
|
+ #if NUM_BONE_INFLUENCERS > 4
|
|
|
+ influence += mBones[int(matricesIndicesExtra[0])] * matricesWeightsExtra[0];
|
|
|
+ #endif
|
|
|
+ #if NUM_BONE_INFLUENCERS > 5
|
|
|
+ influence += mBones[int(matricesIndicesExtra[1])] * matricesWeightsExtra[1];
|
|
|
+ #endif
|
|
|
+ #if NUM_BONE_INFLUENCERS > 6
|
|
|
+ influence += mBones[int(matricesIndicesExtra[2])] * matricesWeightsExtra[2];
|
|
|
+ #endif
|
|
|
+ #if NUM_BONE_INFLUENCERS > 7
|
|
|
+ influence += mBones[int(matricesIndicesExtra[3])] * matricesWeightsExtra[3];
|
|
|
+ #endif
|
|
|
+
|
|
|
+ finalWorld = finalWorld * influence;
|
|
|
#endif
|
|
|
gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
|
|
|
|