1 glsl comment // from OGRE3D's skinningTwoWeightsShadowCasterVp.glsl
2 glsl comment // Example GLSL program for skinning with two bone weights per vertex
4 glsl code attribute vec4 vertex;
5 glsl code attribute vec4 uv0;
6 glsl code attribute vec4 blendIndices;
7 glsl code attribute vec4 blendWeights;
9 glsl comment // 3x4 matrix, passed as vec4's for compatibility with GL 2.0
10 glsl comment // GL 2.0 supports 3x4 matrices
11 glsl comment // Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing
12 glsl code uniform vec4 worldMatrix3x4Array[72];
13 glsl code uniform mat4 viewProjectionMatrix;
14 glsl code uniform vec4 ambient;
18 glsl code vec3 blendPos = vec3(0,0,0);
20 glsl code for (int bone = 0; bone < 2; ++bone)
22 glsl comment // perform matrix multiplication manually since no 3x4 matrices
23 glsl comment // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first
24 glsl code int idx = int(blendIndices[bone]) * 3;
25 glsl comment // ATI GLSL compiler can't handle unrolling the loop so do it manually
26 glsl comment // ATI GLSL has better performance when mat4 is used rather than using individual dot product
27 glsl comment // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign
28 glsl code mat4 worldMatrix;
29 glsl code worldMatrix[0] = worldMatrix3x4Array[idx];
30 glsl code worldMatrix[1] = worldMatrix3x4Array[idx + 1];
31 glsl code worldMatrix[2] = worldMatrix3x4Array[idx + 2];
32 glsl code worldMatrix[3] = vec4(0);
33 glsl comment // now weight this into final
34 glsl code blendPos += (vertex * worldMatrix).xyz * blendWeights[bone];
37 glsl comment // apply view / projection to position
38 glsl code gl_Position = viewProjectionMatrix * vec4(blendPos, 1);
40 glsl code gl_FrontSecondaryColor = vec4(0,0,0,0);
41 glsl code gl_FrontColor = ambient;
42 glsl code gl_TexCoord[0] = uv0;