If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.
![]() |
|
|
#1 |
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Hello again all. I promised to post the updated D3D10 demo of variance shadow maps, so here it is!
Since the original summed-area variance shadow maps thread and demo, I've done a decent bit of work. In particular, the application has been ported to D3D10, improved in several ways, and new techniques, features, and a new scene have been added. A summary of the available techniques:
Shadow MSAA makes a *huge* difference in motion (use "animate light" checkbox). It really has to be seen to be believed, but even for really large minimum filter widths, swimming is still somewhat visible without MSAA. With even 4x MSAA swimming is drastically reduced or eliminated. int32 is also really awesome for summed-area tables, and is the preferred implementation. Two things make this the case: the extra bits of precision over fp32, and the overflow behavior in D3D10. The latter works because overflow is wrapped in D3D10 which means that we only need to waste W*H bits of the SAT for accumulation where WxH are the dimensions of the maximum filter width. This maximum filter width can be bounded fairly conservatively (ex. 64x64 is plenty - probably overkill for most implementations). The results of int32 make numeric precision a non-issue again, and save a ton of memory bandwidth since there's no need to distribute precision into 4 components. Parallel-split variance shadow maps are also really cool, especially with the new, larger "convoy" scene. Three 512x512 variance shadow map splits with 4x MSAA and a bit of blurring looks fantastic and has excellent performance, and the quality can go up from there if necessary. Note that this implementation is relatively unoptimized; it's more of a "proof of concept". In particular, the shadow split locations could be chosen a lot more sensibly, and even some basic frustum culling would greatly improve the performance of rendering the different shadow map splits. There's a few details that come up with PSVSM that I thought you guys may be interested in as well. Feel free to skip over the next few paragraphs if not. First to get consistent blurring over the different shadow splits one needs to scale the blur kernel size by the ratio of texel sizes between the current split and the full shadow frustum. This is fairly easy to do and very nicely hides the split locations as well, even in motion (see screenshots below). Note that in this demo I round the scaled filter widths to the nearest integer for simplicity; quality could certainly be improved further by allowing non-integer blur kernels. The second detail is the "fun" one: the splits are rendered into a texture array and the applicable split is computed in the fragment shader when shading the scene. This split index is used to choose the appropriate projection matrix and texture array element. This poses a problem, however, for computing texture coordinate derivatives and LOD, since different pixels in the same quad may choose different slices, resulting in unrelated texture coordinates and nonsensical derivatives/LOD. Other implementations have not noticed this problem because without variance shadow maps (and proper shadow filtering), there *is* no LOD computation as things are at best bilinearly sampled. To solve this problem we really want to arbitrarily choose one of the two split indices and make sure they are consistent across the quad (note that I'm assuming only two split indices in a quad, but this turns out to be completely reasonable). After some head scratching I came up with the following code: Code:
// GLOBAL
const int SplitPowLookup[8] = {0, 1, 1, 2, 2, 2, 2, 3};
// IN FRAGMENT SHADER:
...
// Compute which split we're in
int Split = dot(1, Input.SliceDepth > g_Splits);
// Ensure that every fragment in the quad choses the same split so that
// derivatives will be meaningful for proper texture filtering and LOD
// selection.
int SplitPow = 1 << Split;
int SplitX = abs(ddx(SplitPow));
int SplitY = abs(ddy(SplitPow));
int SplitXY = abs(ddx(SplitY));
int SplitMax = max(SplitXY, max(SplitX, SplitY));
Split = SplitMax > 0 ? SplitPowLookup[SplitMax-1] : Split;
...
Ugly trick, I know, but it works like a charm! It's also less ugly than my first idea which was to compute which pixel the current fragment is in the quad using vpos % 2 Anyways grab the demo here: Variance Shadow Maps Demo (April 26, 2007) Source will be released with GPU Gems 3, and the accompanying chapter covers pretty much everything you ever wanted to know about variance shadow maps and shadow map filtering in general. Please note the requirements (as detailed in the included Readme):
Some screenshots: SAVSM: ![]() PSVSM: Note that this quality level is greatly superior to stock PSSM/CSM, even when the latter have much larger shadow maps and more splits. Check out the PSSM demos if you don't believe me. ![]() PSVSM Splits: Zoom in and note that pixel quad trick at work. ![]() VSM for the same scene: Note how much poorer it looks compared to the above - the effect is even more pronounced in motion, and for lower resolution shadow maps. ![]() In any case, go pick up a copy of Gems 3 when it comes out and enjoy the chapter. I'm pretty happy with it so far, and I think anyone interested in real-time shadowing algorithms will find that it contains a lot of useful information. Plus I'm sure that the rest of Gems 3 will be at least as good, if not better than my chapter, so it's worth it in any case To summarize though: - For constant filter-widths, variance shadow maps + all the filtering and MSAA the hardware can give you + blurring is amazing and super-fast. - For variance filter-widths (plausible soft shadows algorithms), summed-area variance shadow maps with int32 + MSAA also looks amazing and is quite fast as well, especially compared to the alternatives. Also, if anyone happens to be going to I3D 2007 next week, come check out my poster; I'd love to chat!. Enjoy, Andrew Lauritzen University of Waterloo / RapidMind Inc. PS: Some people have asked about a 360/PS3 demo of variance shadow maps. I'd love to do it, but I don't have access to the necessary hardware and dev kits right now. Of course if anyone can help on that front... :P [EDIT] Updated demo to include Readme. Last edited by Andrew Lauritzen; 27-Apr-2007 at 02:50. |
|
|
|
|
|
#2 | ||
|
ಠ_ಠ
|
My eye-sockets are clearly not big enough right now.
Btw, there's no readme in the rar file. Quote:
Quote:
|
||
|
|
|
|
|
#3 |
|
Hello :-)
|
Ok this is a random thought, you mention problems on the quad level with splits differing between quads - on the 360 shader implementation there are special attributes for if branches that make them operate at the quad level, an 'ifall' and 'ifany' style. Could these possibly be used for a more elegant solution? (these are exposed in XNA)
Looks very good |
|
|
|
|
|
#4 | ||
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Whoops, sorry... I went to all the trouble of updating it and then forgot to include it
Quote:
Quote:
|
||
|
|
|
|
|
#5 |
|
Hello :-)
|
Actually I think I might be wrong.
The official documentation is a bit less clear... http://msdn2.microsoft.com/en-us/library/bb313968.aspx Code:
ifAll Executes the conditional part of an if statement when the condition is true for all threads on which the current shader is running. ifAny Executes the conditional part of an if statement when the condition is true for any thread on which the current shader is running. [edit] *HOOT HOOT* this may be even better: http://msdn2.microsoft.com/en-us/library/bb313942.aspx Code:
getCompTexLOD2D For 2D textures, gets the LOD for all of the pixels in the quad at the specified coordinates. |
|
|
|
|
|
#6 |
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
No dice - it takes the texture coordinates as a parameter and thus will have the same problem for different splits. I'm pretty sure that the only way one can solve this (other than my current solution) is if there was some instruction that forced - arbitrarily - the four pixels in a quad to go down the same control flow path, or choose the same value.
Last edited by Andrew Lauritzen; 26-Apr-2007 at 00:59. |
|
|
|
|
|
#7 |
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
First, thanks for the front-page link!
Second, I'd just like to mention that there's nothing preventing one from doing summed-area variance shadow maps with parallel-split (or cascaded) shadow maps (PSSAVSM? 1) PSSM generally only needs smaller shadow maps (3 512x512's is usually plenty) which are significantly cheaper to generate SATs with and have less numeric problems to boot (although with int32, numerics are pretty much fine even for large shadow maps). 2) The texel ratio scaling can cause some large filter widths in some cases which can get expensive with standard blurred VSMs. This wouldn't be a problem at all with SAVSM. The filtering techniques and projection splitting/warping techniques are entirely orthogonal, and I would have implemented them this way in the demo if not for the absolute inadequacy of HLSL/Fx for doing that sort of abstraction and encapsulation. Thus the only reasons why I only implemented PSVSM are time and laziness PSSAVSM would indeed be very cool. Why not even throw in some soft shadows using PCSS and get parallel-split soft summed-area variance shadow maps (PSSSAVSM? Last edited by Andrew Lauritzen; 26-Apr-2007 at 17:51. |
|
|
|
|
|
#8 |
|
Member
Join Date: Apr 2003
Posts: 741
|
I just wondered why it's so damn crowded in 3d T&A all of a sudden.
|
|
|
|
|
|
#9 |
|
Registered
Join Date: Apr 2007
Posts: 7
|
Hi there.First to thank AndyTX's VSM source code.VSM is a decent way to take care of shadow map.No doubt that Variance Shadow Maps can be continually improved along with Hardware upgrading.The new techniques in your VSM demo for D3D10 is awesome.It will be more meaningful and effective if you put those new techniques back for D3D9.Keep good working
Attaching some screenshots for my VSM test running on Virtools 3.5 with D3D9/ShaderModel2.0. Shadow based on VSM 1 ![]() http://img243.imageshack.us/img243/8...70427b1ak0.jpg 2 ![]() http://img132.imageshack.us/img132/1...70427b2wm1.jpg 3 ![]() http://img227.imageshack.us/img227/1...70427b3bd5.jpg 4 ![]() http://img221.imageshack.us/img221/3...70427b4hh0.jpg |
|
|
|
|
|
#10 |
|
Registered
Join Date: Apr 2007
Posts: 7
|
512x512
img224.imageshack.us/img224/5228/devr200704275121qv2.jpg 1024x1024 img228.imageshack.us/img228/8459/devr2007042710241pe5.jpg Parallel-split researching... img172.imageshack.us/img172/6964/devr2007042714530623tx5.jpg Above all are 4xAA screenshots. |
|
|
|
|
|
#11 |
|
Registered
Join Date: Apr 2007
Posts: 7
|
|
|
|
|
|
|
#12 | |
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Quote:
Thanks for sharing the screenshots! Shadows are nice, and I'm looking forward to seeing the fully-shaded scenes. One minor note about the code in the second window - with respect to VSM epsilon while I originally modified that variance as you have done there, recently I've just been clamping the minimum variance to some value, which seems to work pretty well and is a bit simpler. Either way should be fine though, just thought I'd mention. |
|
|
|
|
|
|
#13 |
|
Registered
Join Date: Aug 2003
Location: Carlsbad, CA, USA
Posts: 9
|
Hey Andy,
great looking screenshot. The idea of using a distribution of shadow samples based on probability is great. The main problem with Variance shadow maps are the light bleeding artefacts. It seems like some people found ways to get around those by choosing a different probability equation (covered in ShaderX6 Did you use a trick to get rid of light bleeding in your plain variance shadow map implementation? After having solved depth aliasing / light bleeding artefacts and after we have found ways to blur the penumbra with hardware, the next frontier is probably how to construct the light view frustum in the most efficient way to save more cycles by using smaller maps. Additionally low-res shadow maps start flickering when you move around the camera. This is also an interesting area of research. Did you look into light view frustum construction a bit ... any advice? - Wolfgang |
|
|
|
|
|
#14 | ||||||
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Quote:
Quote:
I actually briefly sketch a proof in the Gems 3 chapter that one can't perfectly reconstruct the visibility function without being able to fall back on brute-force PCF in the worst case. An adaptive algorithm based on VSM is straightforward and may be one way of doing that in the future. Unfortunately this implies that there is no silver bullet to visibility, however what we'd like to find is an efficient approximation. VSM actually works rather well for only two pieces of information, but it would be nice to have a way to extend it if one is willing to sacrifice more storage/performance for better quality. More moments is an obvious extension since they are trivial to compute, but as I mentioned above a suitable approximating function that uses them would have to be found. Quote:
Quote:
Quote:
To this end, I encourage you to check out the demo. Use the "Convoy" scene, PSVSM with 3 or 4 slices, 4x shadow MSAA and set the softness just high enough to eliminate any flickering or swimming (shouldn't take much). Quote:
Anyways thanks for your input and interest. I'd definitely be interested in discussing/reviewing any pertinent chapters for ShaderX6, so please PM or e-mail me when you get the chance. Cheers! Andrew |
||||||
|
|
|
|
|
#15 | |
|
Nutella Nutellae
Join Date: Feb 2002
Location: San Francisco, CA
Posts: 4,210
|
Quote:
Adding a third moment basicly gets you the same results of VSM without using any bias (just cause skewness gives you information about asymmetries in the Z distribution), adding a fourth moment ameliorate things a bit but the results are too instable and the fair amount of data and computation needed in a such model makes it a no go, imho. If you postulate a distribution a priori (sum of 2 or more dirac's deltas, or a mixture of 2 gaussians..) you can then try to fit your moments to the related cumulative distribution function (and get rid of Cheb's inequality) and get some nice results where your Z distribution fits these models and some supercrappy stuff in any other case
__________________
[my blog] Isn't it enough to see that a garden is beautiful without having to believe that there are fairies at the bottom of it too? [Douglas Adams] The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way |
|
|
|
|
|
|
#16 | |||
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Quote:
Quote:
Quote:
The other ideas that I played with are using several depth layers similar to depth peeling so that each distribution would contain only two delta functions. However in the straightforward implementations one has to sacrifice either inner or outer penumbrae, and in the more complicated case it degenerates into something which is arguable just as much work as just biting the bullet and doing full deep shadow maps. It doesn't seem like an easy problem to solve efficiently, which is why I'm particularly interested in the work that wolfgang mentioned. PS: It sounds like you've experimented with VSMs quite a bit nAo. Is that true or is this all theoretical? |
|||
|
|
|
|
|
#17 | |
|
Nutella Nutellae
Join Date: Feb 2002
Location: San Francisco, CA
Posts: 4,210
|
Quote:
__________________
[my blog] Isn't it enough to see that a garden is beautiful without having to believe that there are fairies at the bottom of it too? [Douglas Adams] The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way |
|
|
|
|
|
|
#18 | |
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Quote:
|
|
|
|
|
|
|
#19 |
|
Registered
Join Date: Apr 2007
Posts: 7
|
To andy
No pay doesn't mean no value.It is unfair all the time when people creat huge value without reasonable reward.It is abnormal so that need someone to do meaningful thing to correct it.That is also my driving force to keep going. Actually there are lots of ways to make shadow,I've tried some clumsy ways to achieve soft shadow like I ever used shadow system in virtools plus some post-process effect. 1 ![]() http://img223.imageshack.us/img223/7958/hls1df5.jpg 2 http://img213.imageshack.us/img213/8619/hls2th9.jpg But they are used in Virtools only.There will be different story to creat Shadows based on VSM that means I can incorporate them into other engines when it is necessary.VSM is great! "I'm looking forward to seeing the fully-shaded scenes" I think you have to wait until my fully-shaded scene done 1 ![]() http://img135.imageshack.us/img135/2...5044175ng8.jpg 2 http://img155.imageshack.us/img155/5...5052667wi2.jpg 3 http://img155.imageshack.us/img155/4...5075120tg0.jpg 4 http://img91.imageshack.us/img91/861...6294512sh2.jpg 5 http://img179.imageshack.us/img179/1...6301935qs3.jpg 6 compatiable to ATI card http://img224.imageshack.us/img224/9...2371109et7.jpg 7 compatiable to ATI card http://img153.imageshack.us/img153/7...2371626fa4.jpg 8 http://img153.imageshack.us/img153/7...2432170ft3.jpg 9 http://img151.imageshack.us/img151/7...2453890vh6.jpg 10 http://img245.imageshack.us/img245/3350/nova03us3.jpg 11 http://img82.imageshack.us/img82/4973/nova04fo2.jpg |
|
|
|
|
|
#20 |
|
Meh
Join Date: Mar 2004
Location: New York
Posts: 8,509
|
|
|
|
|
|
|
#21 | |
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Quote:
That said, the article is less offensive to me than most, although their comments about "techy information" are a bit bizarre; were they honestly surprised that I was going to discuss the technical parts when it's new research, and posting a technical site like B3D?? Sigh |
|
|
|
|
|
|
#22 |
|
Member
Join Date: Feb 2007
Location: Irvine, CA
Posts: 219
|
Nice job Andy, the demo looks beautiful!
The SAVSM's look great, although I'm more than happy with the results I've been getting with just standard VSM + 4x MSAA + 5x5 Blur (great shadow quality with minimal swimming, and good performance on my 8800 GTS). Fits in nicely with deferred rendering, too. I may try out something similar to your parallel-split VSM implementation, as I've been having a bit of trouble getting the shadows to look good for large outdoor scenes with directional lighting from the sun. |
|
|
|
|
|
#23 | |
|
Regular
|
Quote:
Jawed |
|
|
|
|
|
|
#24 | |
|
AndyTX
Join Date: May 2004
Location: British Columbia, Canada
Posts: 1,090
|
Thanks!
Quote:
I highly recommend looking into PSSM, as it's very simple to implement and tweak and has great results even compared to perspective warping techniques (although the two can actually be used together). Works very nicely with VSMs as well since the latter can actually hide a lot of the artifacts of PSSM (visible edge splits, swimming on camera movement, etc). |
|
|
|
|
|
|
#25 |
|
Naughty Boy!
Join Date: Jan 2002
Posts: 3,266
|
Although I have no idea how this demo looks like (still on XP with a NV45), I have to commend you Andy on your VSM work. Just thought I'd drop a reminder of my post almost exactly one year ago.
__________________
Reverend Dev Anon : Best game ever? Hmm... you mean other than anything from us? (2005) |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|