Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Reorganised shader programs

File size: 1.4 KB
Line 
1#version 150
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
13in vec4 vertex;
14in vec3 normal;
15in vec4 blendIndices;
16in vec4 blendWeights;
17in vec4 uv0;
18
19out vec4 oUv0;
20out vec4 ambientColour;
21
22void main()
23{       
24        mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array);
25
26        float len = length(blendDQ[0]);
27        blendDQ /= len;
28
29        vec3 blendPosition = calculateBlendPosition(vertex.xyz, blendDQ);
30               
31        //No need to normalize, the magnitude of the normal is preserved because only rotation is performed
32        vec3 blendNormal = calculateBlendNormal(normal, blendDQ);
33       
34        gl_Position =  viewProjectionMatrix * vec4(blendPosition, 1.0);
35       
36        // Lighting - support point and directional
37        vec3 lightDir0 = normalize(lightPos[0].xyz - (blendPosition * lightPos[0].w));
38        vec3 lightDir1 = normalize(lightPos[1].xyz - (blendPosition * lightPos[1].w));
39
40        oUv0 = uv0;
41
42        ambientColour = /*gl_FrontMaterial.diffuse **/ (ambient + (clamp(dot(lightDir0, blendNormal), 0.0, 1.0) * lightDiffuseColour[0]) + 
43                (clamp(dot(lightDir1, blendNormal), 0.0, 1.0) * lightDiffuseColour[1]));                       
44}
45
Note: See TracBrowser for help on using the repository browser.