-
Notifications
You must be signed in to change notification settings - Fork 1
/
vStart.glsl
33 lines (26 loc) · 1.06 KB
/
vStart.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
attribute vec3 vPosition;
attribute vec3 vNormal;
attribute vec2 vTexCoord;
varying vec4 position;
varying vec3 normal;
varying vec2 texCoord;
uniform mat4 ModelView;
uniform mat4 Projection;
// Added bone variables for Part 2D.A.
attribute vec4 boneIDs;
attribute vec4 boneWeights;
uniform mat4 boneTransforms[64];
void main() {
// PART 2D.A. Use type casting to convert float to int
mat4 boneTransform = boneWeights[0] * boneTransforms[int(boneIDs[0])] +
boneWeights[1] * boneTransforms[int(boneIDs[1])] +
boneWeights[2] * boneTransforms[int(boneIDs[2])] +
boneWeights[3] * boneTransforms[int(boneIDs[3])];
// Transform the vertex position and vertex normal with boneTransform
vec4 positionTransform = boneTransform * vec4(vPosition, 1.0);
vec3 normalTransform = vec3(boneTransform) * vNormal;
position = positionTransform;
normal = normalTransform;
texCoord = vTexCoord;
gl_Position = Projection * ModelView * positionTransform;
}