Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Reorganised shader programs

File size: 1.2 KB
Line 
1#version 150
2
3mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, vec4 dualQuaternions[24]);
4vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ);
5
6uniform vec4 worldDualQuaternion2x4Array[24];
7uniform vec4 scaleM[72];
8uniform mat4 viewProjectionMatrix;
9uniform vec4   ambient;
10
11in vec4 vertex;
12in vec4 blendIndices;
13in vec4 blendWeights;
14
15out vec4 ambientColour;
16
17void main()
18{       
19        //First phase - applies scaling and shearing:
20        int blendIndicesX = int(blendIndices.x) * 3;
21        int blendIndicesY = int(blendIndices.y) * 3;
22       
23        mat3x4 blendS = blendWeights.x*mat3x4(scaleM[blendIndicesX], 
24                scaleM[blendIndicesX + 1], scaleM[blendIndicesX + 2]);
25       
26        blendS += blendWeights.y*mat3x4(scaleM[blendIndicesY],
27            scaleM[blendIndicesY + 1], scaleM[blendIndicesY + 2]);
28
29        mat4x3 blendF = transpose(blendS);
30
31        vec3 pass1_position = blendF * vertex;
32
33        //Second phase
34        mat2x4 blendDQ = blendTwoWeightsAntipod(blendWeights, blendIndices, worldDualQuaternion2x4Array);
35
36        blendDQ /= length(blendDQ[0]);
37
38        vec3 blendPosition = calculateBlendPosition(pass1_position, blendDQ);
39       
40        gl_Position =  viewProjectionMatrix * vec4(blendPosition, 1.0);
41
42        ambientColour = ambient;                       
43}
44
Note: See TracBrowser for help on using the repository browser.