#version 300 es precision mediump float; 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 weightedPosition = boneTransforms[int(boneID.x)] * vec4(position, 1.0) * boneWeight.x; weightedPosition += boneTransforms[int(boneID.y)] * vec4(position, 1.0) * boneWeight.y; weightedPosition += boneTransforms[int(boneID.z)] * vec4(position, 1.0) * boneWeight.z; weightedPosition += boneTransforms[int(boneID.w)] * vec4(position, 1.0) * boneWeight.w; vertPosition = vec3(modelTransform * weightedPosition); vec3 weightedNormal = mat3(boneTransforms[int(boneID.x)]) * normal * boneWeight.x; weightedNormal += mat3(boneTransforms[int(boneID.y)]) * normal * boneWeight.y; weightedNormal += mat3(boneTransforms[int(boneID.z)]) * normal * boneWeight.z; weightedNormal += mat3(boneTransforms[int(boneID.w)]) * normal * boneWeight.w; vertNormal = normalMatrix * weightedNormal; vertTexCoord = texCoord; vertColor = color * materialColor; gl_Position = projectionTransform * viewTransform * modelTransform * weightedPosition; }