Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSL150/skinningTwoWeightsShadowCasterVp.glsl @ 12083

Last change on this file since 12083 was 12083, checked in by wiesep, 6 years ago

Reorganised shader programs

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