#version 450 layout (binding = 0) uniform UniformBufferObject { mat4 viewProj; } ubo; layout (push_constant) uniform PushConstant { mat4 model; vec3 color; } constant; #ifdef BONE layout (set = 1, binding = 0) uniform UniformBufferBone { mat4 trans[96]; } bone; #endif layout(location = 0) in vec3 inPosition; layout(location = 1) in vec2 inTexCoord; layout(location = 2) in vec3 inNormal; layout(location = 3) in vec3 inTangent; #ifdef BONE layout(location = 4) in vec3 boneWeight; layout(location = 5) in uvec4 boneIndex; #endif layout(location = 0) out vec3 fragColor; layout(location = 1) out vec2 fragTexCoord; void main() { #ifdef BONE vec4 weights; weights.x = boneWeight.x; weights.y = boneWeight.y; weights.z = boneWeight.z; weights.w = 1.0 - weights.x - weights.y - weights.z; vec3 posL = vec3(0, 0, 0); vec3 normalL = vec3(0, 0, 0); vec3 tangentL = vec3(0, 0, 0); for(int i = 0; i < 4; ++i) { posL += weights[i] * (bone.trans[boneIndex[i]] * vec4(inPosition, 1.0)).xyz; normalL += weights[i] * (mat3(bone.trans[boneIndex[i]]) * inNormal); tangentL += weights[i] * (mat3(bone.trans[boneIndex[i]]) * inTangent); } //inPosition = posL; //inNormal = normalL; //inTangent = tangentL; #else vec3 posL = inPosition; #endif gl_Position = ubo.viewProj * constant.model * vec4(posL, 1.0); fragColor = constant.color; fragTexCoord = inTexCoord; }