#version 330 core layout (location = 0) in vec3 a_position; layout (location = 1) in vec2 a_texcoord; layout (location = 2) in vec3 a_normal; layout (location = 3) in ivec4 a_bone_ids; layout (location = 4) in vec4 a_bone_weights; const int MAX_BONES = 240; const int MAX_BONE_INFLUENCE = 4; uniform mat4 u_bone_transforms[MAX_BONES]; uniform mat4 u_vp; uniform mat4 u_model; // out vec3 v_fragpos; out vec2 v_texcoord; out vec3 v_normal; void main() { mat4 bone_transform = mat4(0.0); for (int i = 0; i < MAX_BONE_INFLUENCE; i++) { if (a_bone_ids[i] == -1) continue; bone_transform += u_bone_transforms[a_bone_ids[i]] * a_bone_weights[i]; } vec4 pos_l = bone_transform * vec4(a_position, 1.0); vec4 fragpos4 = u_model * pos_l; gl_Position = u_vp * fragpos4; // v_fragpos = vec3(fragpos4); v_texcoord = a_texcoord; vec4 normal_l = bone_transform * vec4(a_normal, 0.0); v_normal = normalize((u_model * normal_l).xyz); }