3DMark06, Cascaded Shadow Maps (CSM)

Started by
34 comments, last by wolf 18 years, 1 month ago
Just a couple of quick questions Wolfgang:

- Do you partition the frustum in the way that the original poster suggested?
- How do you "focus" the shadow maps on their specific region to be as tight and also as fast as possible?

PS: Love your books :)
Advertisement
That was me above... forgot to login :|

Some more questions :)

- Also... are there no problems with "dueling frusta" cases? As far as I understand this approcah, performance could be much worse if the light and the camera are looking at each other as you render everything ~5 times. If they are perpendicular you only have to render it ~1 more time (as each SM covers 1/5th of your frustum).

- Do put all 5 SMs into the pixel shader and then decide which one to choose? May I ask what is your criteria as pixel shader instrucions are quite expensive :)
I sketched my implementation on the thread http://www.gamedev.net/community/forums/topic.asp?topic_id=372261, but didn't get any feedback, so I'll repeat it here (still hoping for feedback or a much better implementation ;-). It's a simple yet robust way of first creating a shadow texture with black/white color information that can be used in lighting shaders later on.

1. Divide the view frustum into five adjacent (but not overlapping) frustums along the viewer's z-Axis.
2. For each frustum - starting with the most distant one - do:
2.1. Clear screen z-buffer (but don't clear the color)
2.2. Create a standard shadow map for the current frustum
2.3. Apply this shadow map to the scene for the current frustum (this means to create a projection matrix with the z extends of the current frustum. This solves the "which shadow map for which objects and where" problem) such that a black and white image for shadowed and non-shadows regions is drawn. The color information for frustums closer to the viewer overlap that of more distant ones (kind of painter algorithm).
3. Use the screen as a texture and render the scene using real materials and that shadow information


I wouldn't say my implementation is better than everyone else's implementation. It is just one way that works. I have the impression that other people have much more sophisticated implementations like yours.
I have up to four shadow maps and each has its own view frustum. The near and far clipping plane of each light/shadow map view frustum just slices the view frustum in four parts.
The transition between two shadow maps is difficult, but by overlapping them a bit you only see the transition when you know where to look for as long as they are proberly tuned.
Frustum culling takes care, that we render into each shadow map only the objects that are in the shadow map frustum.
I might change this a bit in the future, but this is how it is done in the moment.

- Wolf
but if you're allocation 4 shadow maps of 2K x 2K you already 'waste' quite a lot video memory no? Isn't it more effecient to reuse the shadow maps, and render to a RGBA texture the black and white afterwards, which is then used during the shading part. The RGBA texture is in view space (so can be blurred) and can also contain shadow information of other point lights perhaps. Like this you can easily render multiple lights which cast shadow in a single pass. Which is nice. (I presume this is the technique you are using krausest)

I still have a question regarding the subdivision. Do you take the center of all frustum the current camera position, and extend the frustum in all directions, or only in the view direction. View direction would off course be more efficient, but object lying behind you which cast shadow are culled like this ..
camera direction is viewed from right to left the pyrimid (im using using 3 SM frustums)
http://uk.geocities.com/sloppyturds/CC/2005_04_26A.jpg
u do need someover lap between the frustums
dont center them on the camera or else nearlt half the SM is going to waste
Guoshima you are absolutely right :-).

<<<
The RGBA texture is in view space (so can be blurred) and can also contain shadow information of other point lights perhaps.
<<<
You mean in screenspace? Yep that is cool. Did anyone else do it this way?

I have one other question: how do you project in the shadow map ... or in other words, how do you construct the frustums? Any reference?
I did it on my own, but would love to see how others did it.

- Wolf

[Edited by - wolf on February 11, 2006 12:06:47 AM]
<<<
- Also... are there no problems with "dueling frusta" cases? As far as I understand this approcah, performance could be much worse if the light and the camera are looking at each other as you render everything ~5 times. If they are perpendicular you only have to render it ~1 more time (as each SM covers 1/5th of your frustum).

- Do put all 5 SMs into the pixel shader and then decide which one to choose? May I ask what is your criteria as pixel shader instrucions are quite expensive :)
<<<
Dueling frusta might be 1.5 km aways on the fifth map ... so you do not really see it.
You choose shadow maps based on view distance ...
if(viewdistance < StartSecondShadowMap)
DrawIntoShadowMap1;
if(viewdistance > StartSecondShadowMap && viewdistance < StartThirdShadowMap)
DrawIntoShadowMap2;

Works quite well as long as the dynamic branches in the pixel shader do not kill you :-). In case they kill you can try a texture atlas.
But I like the idea of rendering everything into a screenspace texture more ...
zedeck:
<<<
dont center them on the camera or else nearlt half the SM is going to waste
<<<
so where do you center the light frustum then ... do you have a threshold value to move the frustum a bit in front?

Anonymus poster:
currently I look at the view frustum and calculate the light view frustum as an orthographic projection that gets its min values from the view frustum. I end up with a quad as the far and near plane. I wonder if this is the best way to do it. I would think that having an orthographic frustum that follows exactly the view frustum would be better.
hmm i know CSM for a while now but i still don't really understand what it is that makes them so good. Ok they have less aliasing problems but at what costs? you have to render 5 times only for the shadow maps and they consume much memory. So what are the advantages of CSM in comparison to other shadow map techniques like TSMs(which,as far as i understood, result in less aliasing problems on spots that are farer away from the camera)?

regards,
m4gnus
"There are 10 types of people in the world... those who understand binary and those who don't."

This topic is closed to new replies.

Advertisement