Apply skinning matrix in vertex shader
This commit is contained in:
1 parent
16c4fe3704
commit
7243b51149
1 file changed
+13
-2
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user