I’ve adopted the learnopengl.com tutorial on skeletal animation, but it surely doesn’t apply shadow on the animated mannequin.
Right here is my try: shadow seems too quickly on some elements of the mannequin, and doesn’t seem as a straight line because it ought to.
Right here is the vertex shader that’s used to show the character. I believe that FragPosLightSpace shouldn’t be calculated correctly, because it’s the one variable that’s used solely to calculate the shadow within the fragment shader (if different variables have been flawed, I believe the mannequin would not show correctly).
#model 330 core
format(location = 0) in vec3 aPos;
format(location = 1) in vec3 aNormal;
format(location = 2) in vec2 aTexCoords;
format(location = 3) in ivec4 boneIds;
format(location = 4) in vec4 weights;
uniform mat4 projection;
uniform mat4 view;
uniform mat4 mannequin;
const int MAX_BONES = 100;
const int MAX_BONE_INFLUENCE = 4;
uniform mat4 finalBonesMatrices[MAX_BONES];
uniform mat4 lightSpaceMatrix;
// Output
out vec3 FragPos;
out vec3 Regular;
out vec2 TexCoords;
out vec4 FragPosLightSpace;
void predominant()
{
mat4 boneTransform = finalBonesMatrices[boneIds[0]] * weights[0];
boneTransform += finalBonesMatrices[boneIds[1]] * weights[1];
boneTransform += finalBonesMatrices[boneIds[2]] * weights[2];
boneTransform += finalBonesMatrices[boneIds[3]] * weights[3];
vec4 totalPosition = boneTransform * vec4(aPos, 1.0);
gl_Position = projection * view * mannequin * totalPosition;
TexCoords = aTexCoords;
vec4 NormalL = boneTransform * vec4(aNormal, 0.0);
Regular = (mannequin * NormalL).xyz;
FragPos = (mannequin * totalPosition).xyz;
FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
}
Thanks for any assist!