33 lines
828 B
GLSL
33 lines
828 B
GLSL
#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(push_constant) uniform vp_t {
|
|
mat4 transform;
|
|
} vp;
|
|
|
|
layout(binding = 0) uniform transform_t {
|
|
mat4 model;
|
|
} transform;
|
|
|
|
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 = vp.transform * transform.model * skinning_matrix
|
|
* vec4(position, 1.0);
|
|
frag_normal = transpose(
|
|
inverse(mat3(transform.model * skinning_matrix))) * normal;
|
|
}
|