#version 450

layout(push_constant) uniform constants {
    mat4 lightSpaceMatrix;
};

layout(std430, set = 0, binding = 0) readonly buffer JointBuffer {
    mat4 jointMatrices[];
};

layout(location = 0) in vec3 aVertexPos;
layout(location = 1) in uvec4 aVertexJoint;
layout(location = 2) in vec4 aVertexWeight;


void main() {
    mat4 skinMat =
		aVertexWeight.x * jointMatrices[aVertexJoint.x] +
		aVertexWeight.y * jointMatrices[aVertexJoint.y] +
		aVertexWeight.z * jointMatrices[aVertexJoint.z] +
		aVertexWeight.w * jointMatrices[aVertexJoint.w];

	gl_Position = lightSpaceMatrix * skinMat * vec4(aVertexPos, 1.0f);
}
