[12115] | 1 | #version 120 |
---|
| 2 | |
---|
| 3 | mat2x4 blendTwoWeightsAntipod(vec4 blendWgt, vec4 blendIdx, vec4 dualQuaternions[24]); |
---|
| 4 | vec3 calculateBlendPosition(vec3 position, mat2x4 blendDQ); |
---|
| 5 | vec3 calculateBlendNormal(vec3 normal, mat2x4 blendDQ); |
---|
| 6 | |
---|
| 7 | uniform vec4 worldDualQuaternion2x4Array[24]; |
---|
| 8 | uniform mat4 viewProjectionMatrix; |
---|
| 9 | uniform vec4 lightPos[2]; |
---|
| 10 | uniform vec4 lightDiffuseColour[2]; |
---|
| 11 | uniform vec4 ambient; |
---|
| 12 | |
---|
| 13 | attribute vec4 vertex; |
---|
| 14 | attribute vec3 normal; |
---|
| 15 | attribute vec4 blendIndices; |
---|
| 16 | attribute vec4 blendWeights; |
---|
| 17 | attribute vec4 uv0; |
---|
| 18 | |
---|
| 19 | void 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 | |
---|