#version 150 in vec3 position; in vec2 texCoord; in vec3 normal; in vec4 tangent; in vec4 color; in vec4 boneID; in vec4 boneWeight; #define BONE_COUNT_MAX 120 uniform mat4 projectionTransform; uniform mat4 viewTransform; uniform mat4 modelTransform; uniform mat3 normalMatrix; uniform vec4 materialColor; layout (std140) uniform boneTransformBlock { mat4 boneTransforms[BONE_COUNT_MAX]; }; out vec3 vertPosition; out vec2 vertTexCoord; out vec3 vertNormal; out vec4 vertColor; void main() { vec4 weightedPositions[4]; vec3 weightedNormals[4]; weightedPositions[0] = boneTransforms[int(boneID.x)] * vec4(position, 1.0) * boneWeight.x; weightedPositions[1] = boneTransforms[int(boneID.y)] * vec4(position, 1.0) * boneWeight.y; weightedPositions[2] = boneTransforms[int(boneID.z)] * vec4(position, 1.0) * boneWeight.z; weightedPositions[3] = boneTransforms[int(boneID.w)] * vec4(position, 1.0) * boneWeight.w; vec4 weightedPosition = weightedPositions[0] + weightedPositions[1] + weightedPositions[2] + weightedPositions[3]; vertPosition = vec3(modelTransform * weightedPosition); weightedNormals[0] = mat3(boneTransforms[int(boneID.x)]) * normal * boneWeight.x; weightedNormals[1] = mat3(boneTransforms[int(boneID.y)]) * normal * boneWeight.y; weightedNormals[2] = mat3(boneTransforms[int(boneID.z)]) * normal * boneWeight.z; weightedNormals[3] = mat3(boneTransforms[int(boneID.w)]) * normal * boneWeight.w; vec3 weightedNormal = weightedNormals[0] + weightedNormals[1] + weightedNormals[2] + weightedNormals[3]; vertNormal = normalMatrix * weightedNormal; vertTexCoord = texCoord; vertColor = color * materialColor; gl_Position = projectionTransform * viewTransform * modelTransform * weightedPosition; }