Apply skinning matrix in vertex shader

This commit is contained in:
Camden Dixie O'Brien committed 2025-10-02 03:59:16 +01:00
1 parent 16c4fe3704
commit 7243b51149
1 file changed
+13 -2
+13 -2
View File
@@ -13,7 +13,18 @@ layout(binding = 0) uniform mvp_t {
mat4 proj;
} mvp;
layout(binding = 1) uniform skeleton_t {
mat4 matrices[32];
} bones;
void main() {
gl_Position = mvp.proj * mvp.view * mvp.model * vec4(position, 1.0);
frag_normal = mat3(mvp.model) * normal;
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;
}