Jump to content
  • Advertisement
Sign in to follow this  
mankut

Shadowmapping a big scene

This topic is 1969 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 creating a weird effect where it looks like the shadows are floating above the surface, I tried to just set the light at a fixed location which solved my issue however when the player walks out of this light there is no more shadow, I do not think I can fit the entire terrain onto the shadowmap because the terrain is so large, so how I am supposed to solve this? How do I make the shadowmap only follow the player without the shadows themselves moving with the camera?

Share this post


Link to post
Share on other sites
Advertisement

I am using gluperspective for the projection matrix of the light so I am guessing it is directional?

Share this post


Link to post
Share on other sites

For directional lights you should use orthogonal matrices - at opengl-tutorial they have an article about how to setup shadow map for directional light (e.g. using orthogonal matrix) - http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/

 

For large scenes, you probably want to render shadows in distance, to achieve this you can use cascaded shadow maps - for more information read at least these 2 sources

http://msdn.microsoft.com/en-us/library/windows/desktop/ee416307%28v=vs.85%29.aspx

And MJP's code (it's also commented and easy to understand) - http://mynameismjp.wordpress.com/2009/02/17/deferred-cascaded-shadow-maps/

... you can also google for "cascaded shadow maps" I'm sure that Microsoft's link is one of the first, and there is like a TON of others explaining more or less the same.

 

Also this paper http://visual-computing.intel-research.net/art/publications/sdsm/sdsmLauritzen_I3D2011.pdf from Andrew Lauritzen (I think he was even visiting this forums at some point, although I don't think he is still around...), explains how to further extend CSM (e.g. use better partitioning) to achieve really great results. I still haven't implemented this in my engine, but I've got it on my todo list smile.png.

Share this post


Link to post
Share on other sites

You can combine two methods if your light doesn't rotate. You can generate the lightmap for static scene and use the shadow mapping using an ortho projection for dynamic objects. The best is SDSM, Vilem Otte gave the link of the paper, you can found the demo source who is Direct3D11 based. It's important to notice that SDSM needs compute shader, without compute shader you will need to read back a lot and you will lost performance.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!