Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
add comment

1 Answer 1

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: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/

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: http://www.gamedev.net/topic/462238-swimming-shadow-edges-can-they-be-eliminated/

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
add comment

Your Answer

 
discard

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.