Files
gpu-renderer/vert.glsl
T

34 lines
840 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 view;
mat4 proj;
} 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.proj * vp.view * transform.model * skinning_matrix
* vec4(position, 1.0);
frag_normal = transpose(
inverse(mat3(transform.model * skinning_matrix))) * normal;
}