Sign in to follow this  

Cascaded Shadow Maps

This topic is 4379 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

Hello, I am still wondering how the CSM really work. The only information I can find on this on the net is this: http://www.neeyik.info/pix/csm.gif (how do you post a link btw ?) but this not completely clear to me. So you have to create multiple shadow maps. But how are the multiple shadow maps defined ? (each covering a bigger region, or other region, ..). And do they mean with: for each receiver in the scene compute optimal lightProj * lightView, given EyeView*P. Has this something to do with Frustum-frustum cube clipping, cause I presume you have to use this here as well ? Sorry for the noob question, but I am still trying to find a good outdoor shadow solution. If this result isn't good enough, I might go back to the HalfLife 2 method. Static darkmaps, which can be updates, and dynamic projected textures for dynamic objects (then the shadows at least always look good). Reagrds, Kenzo

Share this post


Link to post
Share on other sites
This thread is quite useful (you prolly seen it tho)
Check the FAQ for info on how to do links.

It seems to me from reading that thread that CSMs work alot like clip maps, basically center a set of progressivly larger and lower res shadow maps around the viewer.
I am going to try and put this in my geo clip-mapping engine cos it sounds like the two techniques would compilment each other perfectly.

Share this post


Link to post
Share on other sites
thx .. I started reading it in the beginning, but lost track of the thread, but ended as a interesting one :) Stupid me.

But from the explenation carmack gives:

Quote:

So the solution I'm looking at for outdoor lighting is a sort of multi-middle, propped mip-map of shadow buffers, where you have your 1k x 1k shadow buffer which renders only, say, the 2000 units nearest you, and it's cropped to exactly cover that area dynamically, then you keep scaling by powers of two on there until you've covered the entire world, which may require rendering five or six shadow buffers depending on how big your outdoor area is. It's not really that big of a deal and ends up being like rendering six views for a single point light for an indoor area. I think that's a pretty solvable problem.


This is simply a multiple shadow map which cover a bigger area each time, and from the other explenations is seam like CSM are multiple shadow maps tiled together to fill up the frustum. The one carmack explains seams easier to implement. Like this, you probably have to render the object from near to far, and some objects end up being rendered mutliple times if they don't fit in the smallest view frustum (stencil testing could also be used here then). But how would you make tileable view frustums for the current camera view for the CSM method. Is there an easy solution to this? And has anyone some extra information regarding the paper: Tiled Shadow Maps, because you have to pay to read it :(

Regards,
Kenzo

Share this post


Link to post
Share on other sites
What I understand from what I have read, is that CSMs are always a set of progressively larger shadow maps (same res, each covering an area 4 times that of the last, i.e. twice the dimensions). The difference is you either center them at the viewer position, or at a determined target point depending on the view direction:

Centered at viewer position
o viewer
|\
| \ view direction
| v
|
c1
[ c [ b [ a ] b ] c ]

OR
Centered at viewer eye direction
o viewer
|\
| \ view direction
| \
| v
| c1
[ c [ b [ a ] b ] c ]






Someone please correct if this is not how it is.

Also I would imagine you could make a choice about which level shadow map to use for each object, and just render it once.

Share this post


Link to post
Share on other sites
Hello,

I roughly implemented the CSS as explained above using only 3 shadow maps so far. One upto 32m, second 64m and third 128m, this works and gives okayish results whn using 2048x2048 textures and a little bit of PCF. Perhaps if I would increase the complexity of my PCF it might look better. The problem is of course, this uses almost 50MB of texture memory !! (btw has anyone tried the Efficient Soft-Edged shadows technique from GPU Gems 2 already? Is it good, because from the sample it seams like it very costly for the GPU).

I presume a cheaper solution would be to render the closest shadow map, render geometry inside this volume. Use the same texture to render from 32 to 64, .. but this of course will increase my rendering cost quite a lot, because I now select which texture to sample depending on the depth calculated in the shader, and then I only have to illuminate once.

When using CSM's like this, is there another possibility to optimize the shadow quality. I presume the best thing to create my view projection matrix is asfollows:
View: place eye pos just outside of box, and lookat at center of box.
Projection: Ortho with dimensions of the box

I am wondering if LiSPSM isn't better than this. Has anyone implemented both?

Regards,
Kenzo

Share this post


Link to post
Share on other sites
my implementation of it is pretty similar to what you've all described, with one "extra" (not much, really, but useful): i'm rendering my shadowmaps into one big map. this enables me to "select" the right tile for the shadow receiver pixel (a conditional with 2 maps, basically), so i dont have to PCF each and every map on a ps2.0 hardware. (because only one sampler is used for the shadowmap(s))

im not really fond of the stencil-selector method, it doesnt work very well with transparent surfaces. (that cant have z values written)

Share this post


Link to post
Share on other sites
Quote:
Original post by Guoshima
I am wondering if LiSPSM isn't better than this. Has anyone implemented both?


the big problem with perspective-warping methods (like lispsm, tsm, or psm) is that there are cases (where light direction is the same or the exact opposite of viewing direction) when they just dont work. the other problem, that all of those methods require some kind of "focus point" to exist - it's not trivial to find the optimal one for a given frame. the third problem is that they constantly change the texel distribution: even minor changes can result in "sparkling" of shadows which is quite disturbing - and when they approach their bad case, it is definitely more than just minor.

Share this post


Link to post
Share on other sites
dont center them on the camera, else half the SMs are gonna be behind the camera thus practically wasted,
instead u typically use the cameras forward vector (disregard y component and renormalize) aim the shadowmaps at points along this vector (perhaps set the y component to the average terrain height)

Share this post


Link to post
Share on other sites
Hi

TSM are quite nice algorithm. There's no as many special case like PSM have.
Facing light cases are enough simple to handle.
The focus point is not a "must" in this algorithm.
It can already give good results without.

Jeckle- kjAPI Team

Share this post


Link to post
Share on other sites
Hi,

thx for the help. I was gonna put my CSM maps into 1 textures, kinde like I do for my pointlight cubemaps (this way I can use Hardware shadow maps).

A few weeks ago or something I tried to implement TSM, but I ran into a stupid problem which you might help me on, cause I would really like to see the result on my scene. Perhaps it looks good enough, if I can use 16 or upto 64 PCF depending on the scene (see GPU Gems 2).

In the original paper at chapter 6, they describe how to create the trapezoidal approximation. Transforming my eye frustum into post perspective space of the light is no problem, and then computing the center line. But i don't really find a good way to do step 3,4,5. And then depending on this calculate the 4 points for the trapezoid. If someone could give me a litte better explenation how to get those 4 points or perhaps better tell what they are, it would be very appriciated. As soon as I have the 4 points I can use the TSM recipe from their site to create the trapezoidal transformation matrix. I presume as soon I have this, it's just standard shadow mapping. (sample code of this is of course always welcome ;))

Regards,
Kenzo

Share this post


Link to post
Share on other sites
well trapezoid computation is not that complicated:
- With the centers you have a line L
- using this line L project all the frutum corners on it and find the min and max resulting points along the line.
- from those two new points compute perpendicular lines to L.
- you have then to find side lines (the hardest point because they are the one that cotrol the quality of the resulting shadows)
mainly a side line (in the most common cases) is one of side lines of the frustum. You can also deals with convex hull algorithm to find it.

The best is to make a drawing of it.

Once you have the 4 points, compute the trapezoid matrix and then it's like standard shadow mapping ( just check the notes about getting the post perspective space Z coordinate instead of the trapezoid one)

Jeckle - kjAPI Team

Share this post


Link to post
Share on other sites

This topic is 4379 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.

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