Jump to content
  • Advertisement
Sign in to follow this  
MARS_999

Cascade shadow mapping?

This topic is 4386 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 have been looking for some info on implementing this technique or has anyone tried it themselves? Any background info on it would be great also. Thanks

Share this post


Link to post
Share on other sites
Advertisement
I've implemented it (at least what my interpretation of it was -- as there's not a whole lot out there on it, at least that I could find) with pretty good results.

To me at least, CSM was a lot more straight forward and intuitive in terms of handling its special cases rather than some of the more complicated issues and special cases associated with things like Perspective Shadow Maps or Trapezoidal Shadow Maps.

In essence you can divide your viewing frustum up into several regions -- dedicating a shadow map to each region.

I currently split the frustum into two regions. You can do more, but then it'll require a more complicated shadow caster/receiver determination algorithm -- which could start to get a little crazy. The two region approach essentially gives you a "higher-rez" region closer to the camera and a "lower-rez" region beyond the "high-rez" region's cutoff.

The only real issues at that point are handling the areas of adjacency -- i.e. the border between each region and the regions of light frusta overlap -- as you'll have a "virtual" light frustum bounding each "region".

Share this post


Link to post
Share on other sites
Brian, this sounds interesting. How did you construct the view frustum for those two shadow maps?

Share this post


Link to post
Share on other sites
I got this link around here I think :
http://appsrv.cse.cuhk.edu.hk/~fzhang/pssm_vrcia/shadow_vrcia.pdf
Parallel Split Shadow Mapping, basically what you want, it's quite effective and waste less fillrate and memory (smaller ShadowMaps).

Share this post


Link to post
Share on other sites
did you implement this? I think it is not usable in a game or a game like environment.

Share this post


Link to post
Share on other sites
Quote:
Original post by wolf
did you implement this? I think it is not usable in a game or a game like environment.


Not yet, but I plan on doing it "soon"...

Share this post


Link to post
Share on other sites
Quote:
Original post by wolf
Brian, this sounds interesting. How did you construct the view frustum for those two shadow maps?


I don't know if what I implemented is what is described in that paper -- as I've never seen or read that paper before. When I get a chance I'll take a look at it just to see whether it is or is not what I've done.

As for constructing the two "virtual" light frusta, it's pretty straight forward. As you know, a directional light only needs to use an orthographic projection - no perspective projection required.

In this particular case, you'll be constructing two "virtual" frusta -- one to tightly bound each of the regions of your split viewing frustum.

I believe I actually maintain two separate shadow frusta with the camera's frustum -- one representing each of the two regions.

One of each of those corresponds to the high-rez and low-rez shadow regions in the visible viewing region.

To construct the two "virtual" light frusta I simply build a view matrix using the direction of the light. Then transform each of the eight frustum corners into view space and compute the max/min x, y, and z values (assuming your light view matrix has you looking down the z-axis). Those max/min x/y/z values will then give you all the info you need to build an orthographic projection matrix that tightly bounds that portion of the view frustum. You may want to give yourself a little lee-way on the negative side of the z-axis to allow for you to properly cull/detect off-screen shadow casters that while not "visible" will cast shadows into the viewing region.

At this point, you now have the light's ViewProj matrix for each shadow region, which can be used to render the corresponding shadow depth buffer for each region.

Share this post


Link to post
Share on other sites
Thanks for the info Brian would it be possible to contact you on your method or get a quick tutorial on it? Sounds like a good method... As of now I have frustum culling working for my pathing system, but not sure how to implement that for shadowmapping also??? Thanks

Share this post


Link to post
Share on other sites
Quote:
To construct the two "virtual" light frusta I simply build a view matrix using the direction of the light. Then transform each of the eight frustum corners into view space and compute the max/min x, y, and z values (assuming your light view matrix has you looking down the z-axis). Those max/min x/y/z values will then give you all the info you need to build an orthographic projection matrix that tightly bounds that portion of the view frustum. You may want to give yourself a little lee-way on the negative side of the z-axis to allow for you to properly cull/detect off-screen shadow casters that while not "visible" will cast shadows into the viewing region.

I used pretty much the same method. The problem is that all the viewing frusta have to start at the same line ... so you render a bunch of objects twice or more(... with two maps these are the ones that are in the first slice). I will post a few other thoughts in the next mail ... I just need to make a few figures to show what I mean.

[Edited by - wolf on May 20, 2006 9:32:23 PM]

Share this post


Link to post
Share on other sites
Here is how the sliced view frustum looks like:
Cascaded Shadow Maps / Sliced View Frustum
Figure 1
Here is how the light view frustum calculation is handled:
Cascaded Shadow Maps / Light View Frustum Calculation
Figure 2
Here is the problem with shadows that cross view frustas. This is the reason why all the light view frusta have to start at the same line and the reason for the overdraw.
Cascaded Shadow Maps / A Tree Casts a shadow in the following slice
Figure 3
here is the problem with the tree that is outside the view frusta but should cast a shadow into the scene.
Cascaded Shadow Maps / A Tree is outside the light view frustum but should cast a shadow into the view frustum
Figure 4
And here is the same scenario from a side view. This time I painted two different times of day.
Cascaded Shadow Maps / A Tree is outside the light view frustum but should cast a shadow into the view frustum - side view
Figure 5
The orthographic projection of the lower sun should catch the tree ... if it is not culled?

Let the discussion begin ....

[Edited by - wolf on May 20, 2006 9:57:20 PM]

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!