0

In my scene, I have a few models rendered under a directional light. I currently have one of the models rotating on it's own axis and translating, but the problem I'm running into is that the shadow on that model is not being projected properly. Only models that aren't rotating have shadows in the correct position. How would I go about updating the light so that it would project correctly?

For my general vertex shader:

gl_Position = MVP * vec4(Translation + (Rotate * vec4(Position, 1.0)).xyz, 1.0);

for my shadow vertex shader:

gl_Position = gWVP * vec4(Position, 1.0);
TexCoordOut = TexCoord;

In my constructor, I initialize the directional light as such:

m_directionalLight.Color = COLOR_DAY_CLEARBLUE; // Light color
m_directionalLight.AmbientIntensity = 0.1f;
m_directionalLight.DiffuseIntensity = 1.005f;
m_directionalLight.Direction = glm::vec3(-1.0f, 1.0, 0.0);

The resulting screenshots as follow:

enter image description here

enter image description here

  • Strangely, the light position almost appears to be rotating along with the object. I can't see the shadows in the image on my monitor, but according to you arrows you've laid out, the shadows _are_ in the right place, considering how the light is interacting with the model. We would need to see more source to figure out what's going on, but I'm almost wondering if you're transforming the lighting position by mistake in your shader! – AudioGL May 11 '14 at 06:11
  • @AudioGL I've already tested it. The shadows seems to only render at compile time and doesn't recalculate its projection in realtime. –  May 11 '14 at 10:18

0 Answers0