#version 330 in vec3 pos; in vec3 unscaledNormal; in vec2 vTexCoord; in ivec4 boneIds; in vec4 boneWeights; uniform mat4 model; uniform mat4 view; uniform mat4 projection; uniform mat4 bones[16 + 1]; out vec3 normal; out vec2 texCoords; out vec3 lightPos, viewPos, worldPos; void main() { texCoords = vTexCoord; mat4 boneTrans = bones[boneIds.x] * boneWeights.x; boneTrans += bones[boneIds.y] * boneWeights.y; boneTrans += bones[boneIds.z] * boneWeights.z; boneTrans += bones[boneIds.w] * boneWeights.w; mat4 bonedModel = model * boneTrans; worldPos = vec3(bonedModel * vec4(pos, 1.f)); normal = mat3(transpose(inverse(bonedModel))) * unscaledNormal; gl_Position = projection * view * bonedModel * vec4(pos, 1.f); }