# How to apply shadows on an animated model

I have followed the learnopengl.com tutorial on skeletal animation, but it does not apply shadow on the animated model.

Here is the vertex shader that is used to display the character. I suspect that FragPosLightSpace is not calculated properly, as it's the only variable that is used only to calculate the shadow in the fragment shader (if other variables were wrong, I suspect the model wouldn't display properly).

#version 330 core

layout(location = 0) in vec3 aPos;
layout(location = 1) in vec3 aNormal;
layout(location = 2) in vec2 aTexCoords;
layout(location = 3) in ivec4 boneIds;
layout(location = 4) in vec4 weights;

uniform mat4 projection;
uniform mat4 view;
uniform mat4 model;

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 Normal;
out vec2 TexCoords;
out vec4 FragPosLightSpace;

void main()
{
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 * model * totalPosition;

TexCoords = aTexCoords;

vec4 NormalL = boneTransform * vec4(aNormal, 0.0);

Normal = (model * NormalL).xyz;

FragPos = (model * totalPosition).xyz;

FragPosLightSpace = lightSpaceMatrix * vec4(FragPos, 1.0);
}


FragPosLightSpace = lightSpaceMatrix * model * totalPosition;