#version 450 layout(location = 0) in vec3 position; layout(location = 1) in vec3 normal; layout(location = 2) in uvec4 bone_indices; layout(location = 3) in vec4 weights; layout(location = 0) out vec3 frag_normal; layout(binding = 0) uniform mvp_t { mat4 model; mat4 view; mat4 proj; } mvp; layout(binding = 1) uniform skeleton_t { mat4 matrices[32]; } bones; void main() { const mat4 skinning_matrix = weights.x * bones.matrices[bone_indices.x] + weights.y * bones.matrices[bone_indices.y] + weights.z * bones.matrices[bone_indices.z] + weights.w * bones.matrices[bone_indices.w]; gl_Position = mvp.proj * mvp.view * mvp.model * skinning_matrix * vec4(position, 1.0); frag_normal = transpose(inverse(mat3(mvp.model * skinning_matrix))) * normal; }