I do admit to being a bit wary of using hardware linear filtering (trilinear, aniso, MSAA, bilinear) on a ln-space ESM since it isn't really "correct". I suspect if you're doing some ln-space blurring then this won't be noticable in most cases (you've arbitrarily clamped the minimum filter width, putting most of the support now on the filter that is computed correctly), but it seems like mip-transitions (trilinear) and aniso cases will become more obviously over-darkened. Hard to say though as I haven't fully implemented it myself though.I also played around with exponents of the distance term a while ago, but didn't look at pre-filtering because I think correct anisotropic filtering and mipmapping are more important. Philosophically, I guess I'm in the same boat as Andy.
Indeed the "adaptive sampling" approach is the only one that will get complex filter regions "right", but after some conversations with Marco and some further playing around I came up with something that seems promising. I was going to write it up a bit more formally in a tech report, but I'd rather get some feedback here since we're on the topic.In the end, I think the most bulletproof solution for shadow maps is Andy's suggestion of using VSM to see what the variance is, and if it's high enough fall back to many-sample PCF. It's much better than other methods of skipping samples in non-penumbra regions.
My recent work with "layered" variance shadow maps (to be published @ GI 2008) is a useful generalization based on the observation that warping the depth function monotonically will still produce "correct" upper bounds, but can affect how tight they are in light bleeding cases, etc. In the layered stuff I used simple linear warps to reduce or eliminate light bleeding, but unfortunately the technique requires good layer positions to be effective. Even though these can be determined fairly well automatically, the "light bleeding reduction potential" of the technique scales approximately like convolution shadow maps with storage, which is to say - badly
Since light bleeding is worst when the ratio of distances between objects 2-1 (d_a) and 3-2 (d_b) is large, one way to look at layered VSMs is a method of clamping d_a, ideally to zero. An alternative approach however is to determine a warping function which makes d_a small relative to d_b. exp(c*x) does exactly this. Thus exponentially warping the depth function, but still using 2 moments/Chebyshev as with VSM will greatly reduce the light bleeding associated with VSM and works really well in practice.
But you can go further... the exponential warp actually kind of messes up cases when the receiver is non-planar (or there are multiple receivers) as Marco notes. While these cases can't be done "correctly" in a soft-shadows sort of way without storing multiple shadow map projections, we just want to do something reasonable and "smooth". To that end, using the "dual" of the above warping -exp(-c*x) makes d_a large relative to d_b and thus makes the shadows on any intermediate objects much more like the "smooth" shadow on d_b.
In my brief experimentation, using these two duals together (just taking the min) works really well, and fits nicely into 4 components. If C could be arbitrarily large, I suspect the results would be extremely good. As it stands, there are only really artifacts in places where both duals have artifacts (i.e. non-planar receivers AND light bleeding). I have to work through some of the math and implementation details, but it seems promising, and thus I was interested in whether or not you guys have experimented with anything similar. I can post some screenshots later if people are interested.
In any case with ESM, Layered VSM, CSM and this latest stuff (that I'm calling Exponential VSM for now), there are a lot of options out there with various trade-offs. They're all actually pretty similar fundamentally, which is what makes all of this so interesting I'm glad people have really run with the VSM idea in any case... I can't wait to see what people continue to come up with!
Great presentation Marco, and I'm curious to see what the CSM people have come up with their "Exponential Shadow Maps" paper coming up at GI. Maybe they have solved all of these problems already, which would be fantastic
Last edited by a moderator: