Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to shadowmap a large terrain, I position my light that it is always at the position of the player and looking at the player, the problem is that the shadows now move with the player, I tried to set the position to 0 1000 500 and look at the player always and its a good improvement however the player moves out of the light there are now no shadows :(

How am I supposed to make the light so it covers the entire terrain and everything has shadows all the time without the shadow moving effect?

I am really stuck right now, do I need to somehow calculate scene bounds? would that help at all?

share|improve this question
up vote 2 down vote accepted

It'd be helpful if we knew what API or engine you're using.

If your shadows are from the Sun, you should be using a directional light, not a point or spot light. This means using an orthographic projection matrix when rendering to your shadowmap, as explained here:

If your terrain is very large, you may want to confine your shadowmap to a small region centered on the player. This is done through via the view and projection matrices used to render to the shadowmap. If you take this approach, you will encounter a "swimming" artifact discussed here:

share|improve this answer
I am using OpenGL + C++ with my own engine, Why should I use an orthographic viewport? is there any difference? I don't think I am getting swimming using that method, I am getting the effect where the shadows move with the camera causing the shadow to appear elevated. – user1040769 Apr 27 '13 at 19:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.