Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/trunk/programs/skinningTwoWeightsShadowCasterVp.glsl @ 8580

Last change on this file since 8580 was 7708, checked in by dafrick, 14 years ago

Merging cleanup branch. You will need to update your data repository as well as your local copy of the code.

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// Example GLSL program for skinning with two bone weights per vertex
2
3attribute vec4 blendIndices;
4attribute vec4 blendWeights;
5
6// 3x4 matrix, passed as vec4's for compatibility with GL 2.0
7// GL 2.0 supports 3x4 matrices
8// Support 24 bones ie 24*3, but use 72 since our parser can pick that out for sizing
9uniform vec4 worldMatrix3x4Array[72];
10uniform mat4 viewProjectionMatrix;
11uniform vec4 ambient;
12
13void main()
14{
15        vec3 blendPos = vec3(0,0,0);
16
17        for (int bone = 0; bone < 2; ++bone)
18        {
19                // perform matrix multiplication manually since no 3x4 matrices
20        // ATI GLSL compiler can't handle indexing an array within an array so calculate the inner index first
21            int idx = int(blendIndices[bone]) * 3;
22        // ATI GLSL compiler can't handle unrolling the loop so do it manually
23        // ATI GLSL has better performance when mat4 is used rather than using individual dot product
24        // There is a bug in ATI mat4 constructor (Cat 7.2) when indexed uniform array elements are used as vec4 parameter so manually assign
25                mat4 worldMatrix;
26                worldMatrix[0] = worldMatrix3x4Array[idx];
27                worldMatrix[1] = worldMatrix3x4Array[idx + 1];
28                worldMatrix[2] = worldMatrix3x4Array[idx + 2];
29                worldMatrix[3] = vec4(0);
30                // now weight this into final
31                blendPos += (gl_Vertex * worldMatrix).xyz * blendWeights[bone];
32        }
33
34        // apply view / projection to position
35        gl_Position = viewProjectionMatrix * vec4(blendPos, 1);
36       
37        gl_FrontSecondaryColor = vec4(0,0,0,0);
38        gl_FrontColor = ambient;
39        gl_TexCoord[0] = gl_MultiTexCoord0;
40}
Note: See TracBrowser for help on using the repository browser.