Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL120/DualQuaternion.glsl @ 12323

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

Changed folder structure, deletet some unused files and cleaned up code

File size: 1.4 KB
Line 
1#version 120
2
3mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, vec4 dualQuaternions[24]);
4vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ);
5vec3 calculateBlendNormal(vec3 normal, mat2x4 blendDQ);
6
7uniform vec4 worldDualQuaternion2x4Array[24];
8uniform mat4 viewProjectionMatrix;
9uniform vec4   lightPos[2];
10uniform vec4   lightDiffuseColour[2];
11uniform vec4   ambient;
12
13attribute vec4 vertex;
14attribute vec3 normal;
15attribute vec4 blendIndices;
16attribute vec4 blendWeights;
17attribute vec4 uv0;
18
19void main()
20{       
21        mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array);
22
23        float len = length(blendDQ[0]);
24        blendDQ /= len;
25
26        vec3 blendPosition = calculateBlendPosition(vertex.xyz, blendDQ);
27               
28        //No need to normalize, the magnitude of the normal is preserved because only rotation is performed
29        vec3 blendNormal = calculateBlendNormal(normal, blendDQ);
30       
31        gl_Position =  viewProjectionMatrix * vec4(blendPosition, 1.0);
32       
33        // Lighting - support point and directional
34        vec3 lightDir0 = normalize(lightPos[0].xyz - (blendPosition * lightPos[0].w));
35        vec3 lightDir1 = normalize(lightPos[1].xyz - (blendPosition * lightPos[1].w));
36
37        gl_TexCoord[0] = uv0;
38
39        gl_FrontColor = gl_FrontMaterial.diffuse * (ambient + (clamp(dot(lightDir0, blendNormal), 0.0, 1.0) * lightDiffuseColour[0]) + 
40                (clamp(dot(lightDir1, blendNormal), 0.0, 1.0) * lightDiffuseColour[1]));                       
41}
42
Note: See TracBrowser for help on using the repository browser.