Sign in to follow this  
Harry Hunt

Shaow mapping and frustum mapping

Recommended Posts

Hi again ;-) I have the following situation: i have a map which is statically lit using lightmaps and a couple of dynamic objects which are lit using per-pixel lighting and which cast dynamic shadows using uniform shadow mapping. In each map, for simplicity reasons a single light source is marked as "shadow light" making it the only light source in the scene that produces dynamic shadows. The light source is then then treated like a directional light, so the camera for rendering the light depth map uses orthographic projection. Since only dynamic objects will cast shadows, I only render those into the light depth map. Now I figured that since my light source is directional, I could move it around with the player camera to improve shadow quality. I came up with the following idea: For each dynamic object Test if its inside the player's view frustum If it's not, discard the object Create a bounding box around the remaining objects, adjust the light's camera settings to best capture the bounding box and set the near and far clipping plane appropriately. Move the camera back a little and re-adjust near clipping plane to capture potential occluders that are outside the player's view frustum. I dunno if this is a good idea or if someone has already come up with a good solution for this problem. I don't want to go for PSM or LiSPSM yet, because I fear the complexity ;-) So I'd like to hear your opinion and/or suggestions from you. Thanks a lot in advance!

Share this post


Link to post
Share on other sites

You could have objects behind the player casting a shadow into the view frustum (e.g. monsters sneaking up on them from behind)

Share this post


Link to post
Share on other sites
Thanks for your reply and good point. I know that my "solution" could lead to issues with objects that are outside the player's view frustum and which are casting shadows into the view frustum without themselves being visible. However, since I won't have very large dynamic objects, I figured that moving the light's camera backwards a little and then rendering all dynamic geometry that is inside the light's frustum into the depth texture should account for most situations like the one you've described. But again, I don't know if that'll work since I have yet to try it. I'd just like to hear if my idea could work at all or if there's better solutions that have already proven themselves.

Share this post


Link to post
Share on other sites
Just an idea:
Instead of adjusting the light´s frustum to contain all the dynamic objects in the player´s frustum and then adjusting it a bit:
Adjust the light´s frustum so that it completely contains the player´s frustum. Then check which dynamic objects are inside the light´s frustum and finally adjust the light´s frustum (scale it down to get better resolution) so that it contains all these dynamic objects.
That way you should capture _all_ dynamic objects that can cast a shadow into the player´s frustum, no matter how small or big they are:

- Adjust the light frustum so that it contains the player´s frustum completely
- For each dynamic object
- discard if not inside light´s frustum
- Create bounding box for remaining objects
- adjust light´s frustum to the bounding box

Which is your idea mostly, just switched from player´s frustum to light´s frustum for the visibility check after adjusting the light´s frustum a bit.

Hope that helped

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this