solving light bleeding when using variance shadow maps

Started by
4 comments, last by AndyTX 16 years, 4 months ago
I love the variance shadow map technique, but its main issue - light bleeding - is a major drawback. I was playing with it lately, and I come up with the following solution to the problem: 1 - when rendering the shadow map, use the red and green components for depth and depth^2 and in the blue component store the depth again. 2 - when blurring the shadow map, compute the red and green components normally (for gaussian blur), but for the blue component apply the max operator. This will compute the maximum depth of the surrounding pixels (for example, if your kernel is 3x3, in the blue component you'll have the maximum depth on a 3x3 surface centered on the current pixel) 3 - when computing the light factor in your pixel shader, compare the blue component with the light depth of the current pixel. If it is lower, then all surrounding pixels are in the shadow, so we set the light factor to 0. I have implemented this modification in my shader and it seems to solve most of the issues with light bleeding. I don't know if this method is new (I haven't seen it anywhere else), I just wanted to share it with you guys for further feedback. Thank you!
2+2=5, for big values of 2!
Advertisement
Gday Dizzy_exe!

Cheers for sharing that with us! You wouldn't happen to have any screenies comparing standard variance shadow mapping with your version do you?
OK, here are some screenshots:

normal vsm:




and with my changes:


2+2=5, for big values of 2!
Yup, using the "depth envelope" technique together with VSMs is pretty common, and usually works out. It should be noted that you need to propagate the envelope data (max depth in this case) throughout the whole filtering process as the hardware will not do it for you (it only filters linearly). This means that you need to do it while blurring, while generating mipmaps and while doing lookups, potentially with trilinear/anisotropic filtering. The latter two are pretty expensive to do manually without hardware support, but it sometimes suffices to simply "ignore" the problem in this case, as I suspect you are currently doing. It's simply harder to notice light bleeding when something is being minified than when it is magnified (as in your images).

The only problem with the technique is that for sufficiently large filter widths (large blurs or mipmapping) you can get discontinuities in the shadow falloff. You'll never see it in simple scenes, but it shows up a bit more frequently in more complex scenes with soft shadows.

That said, it's certainly a good tool to have in the box :)
Hi AndyTX,

Depth envelope - so that is how is called. Unfortunately, I still wasn't able to find any information about it using Google, which is a pity, because I think it should be the main addition to the standard variance shadow maps technique.

I'm not using mipmaps (too much time consumers) and I turned off anisotropic filtering because I pack 4 shadow maps into a single texture and I had weird seems when switching between them (see my other threads about this issue).

I use a larger filter when applying the max operator than for the blur operator so I make sure that I won't destroy the shadow edges with the last step. What kind of discontinuities are you referring to?
2+2=5, for big values of 2!
Quote:Original post by Dizzy_exe
Depth envelope - so that is how is called. Unfortunately, I still wasn't able to find any information about it using Google, which is a pity, because I think it should be the main addition to the standard variance shadow maps technique.

Well that's what I call it. Look up something like "hierarchical shadow maps" with mipmaps or something. It's the same idea in principal.

Quote:Original post by Dizzy_exe
I'm not using mipmaps (too much time consumers) and I turned off anisotropic filtering because I pack 4 shadow maps into a single texture and I had weird seems when switching between them (see my other threads about this issue).

Weird... I'll look up that other thread. It's definitely desirable to use mipmaps and aniso since hardware filtering is one of the main advantages of VSMs!

Quote:Original post by Dizzy_exe
What kind of discontinuities are you referring to?

You can get hard black edges in soft penumbra regions. I wish I had a screenshot handy but I don't unfortunately. Just try getting an object with a silhouette that has convex and concave regions and increasing the filter width a lot. You should see what I mean.

This topic is closed to new replies.

Advertisement