Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1] 2 3 ... 6
  Print  
Author Topic: Parallel Split Shadow Mapping  (Read 11341 times)
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« on: April 20, 2008, 08:42:03 AM »

Hey there!

I've been working on Parallel Split Shadow Mapping (aka Cascaded Shadow Mapping) for some time and I finally got something to show ya. For those who don't know what that is, take a look:

http://appsrv.cse.cuhk.edu.hk/~fzhang/pssm_project/
http://hax.fi/asko/PSSM.html
http://appsrv.cse.cuhk.edu.hk/~fzhang/pssm_vrcia/




Basically, the scene cameras view frustum gets split into a few parts and each split gets its own Shadow Map. Note that my frustum splits got scaled a bit to reduce border specific errors. The idea behind that is that the nearer a split is, the higher the shadow map resolution is. In other words: Shadow Maps near the viewer have a higher resolution to obtain a better qualitity. This thingy is good for large scenes, eg. the game Crysis (which also uses PSSM in combination with Variance Shadow Mapping -> PSVSM).

There are a few differences between my implementation and the techniques proposed in the paper.

I don't use "geometry approximation", that is the light camera only encloses a frustum split, not only the shadow caster within that split.

I also don't use the far plane configuration yet. This means the far plane of the cameras view frustum gets clamped to the scenes bounding box, to remove empty space on the Shadow Maps - but thats easy to do.

The paper also proposes to use one shadow map pass per split and additional final passes to render the scene. This is required to let pixels have access to the correct Shadow Map. In other words: A four splitted frustum requires 4 * Shadow Map Passes + 4 * Scene Passes = Hell of alot passes. Nevertheless, this is possible with Truevision3D, but sh**ty, cause you'd need to render on the main buffer many times in a single frame. This would screw up the Z-Buffer and also the FPS statistics, cause TVEngine.Clear(true) does some FPS computations. Another variant would be to render the final scene passes to another Render Surface and draw it later on on the main buffer, which means one additional pass - yuck.

I came up with the idea to spare the 3 scene passes by selecting the good Shadow Map within the shader. This requires more shader instructions, but spares the additional frustum culling operations and geometry renderings on the CPU side - Which is faster, belive me! Smiley Actually, all my techniques use four frustum splits. The paper propses to use one texture per Shadow Map, but I had the idea to "merge" all Shadow Maps into a single one. Since I only use a split count with the power of 2 its possible. This requires less memory, less shader instructions (just a few, 23->19 in PS), but requires large texture resolutions. It would also be good to store each depth map into an ARGB channel, but I'm planning to implement Variance Shadow Mapping (http://forum.beyond3d.com/showthread.php?p=975976), which requires two channels per Depth Map, so I left that idea on my way.

This is how the "normal" way looks like:



But I did it that way:



Note that both textures are A16R16G16B16F, but I later used R32F cause my card supports it. Some people say that the first one is hardware filtered, but I its not over here on an "old" Geforce 7800 GTX.

I also did some benchmarking between both techniques - you may be interested in:





Both results are from a 1280*1024 Scene and without Anti Aliasing. Both Shadow Maps were R32F on this test. This shows, that my technique is a bit faster, but keep in mind that there are FOUR Shadow Maps in the other technique. Also note that there is no filtering (PCF/VSM) at the moment.

Aww.. and before I forget it:


Thats with the highest settings, but without filtering it truly sucks Cheesy

I plan to optimize a few things, like the far plane configuration and the geometry approximation and maybe the code itself. I'll keep you up to date!





Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
newborn
Customers
Community Member
*****
Posts: 2437


WWW
« Reply #1 on: April 20, 2008, 09:54:40 AM »

wo!?  Shocked
Logged

Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #2 on: April 20, 2008, 10:52:44 AM »

wo?  Huh
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Raine
Customers
Community Member
*****
Posts: 1189


« Reply #3 on: April 20, 2008, 11:08:23 AM »

Very interesting, keep us updated
Logged

Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #4 on: April 20, 2008, 12:10:01 PM »

That is AMAZING! Grin

Congratulations, I've been really eager to see one of those fancy space partitioning methods done in TV3D. And it looks like you've really taken your time to make it right.

I'll be much looking forward to a demo!

Edit: One thing I am slightly worried about is that VSM will be hard to do right, since it applies blurring to the shadow maps and your shadow map "parts" touch each other. So I hope this won't get bleeding near the frustum edges...
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
GD
Customers
Community Member
*****
Posts: 364


« Reply #5 on: April 20, 2008, 12:35:03 PM »

Excellent work! Some extra nice ideas you got there.

Just I can't believe the part with using more shader instructions instead of additional frustum cull. Please explain me, I'm little slow.
Logged

tvsm.co.cc - TVSceneManager
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #6 on: April 20, 2008, 02:25:37 PM »

Edit: One thing I am slightly worried about is that VSM will be hard to do right, since it applies blurring to the shadow maps and your shadow map "parts" touch each other. So I hope this won't get bleeding near the frustum edges...
That is correct, but I have an idea, that may work. What about:

TVViewport.SetTargetArea(0, 0, 256, 256)
TVScreenImmediate2D.DrawFullscreenQuadWithShader(0, 0, 1023, 1023)

Thus the blurred area can be limited, but I'm not sure if this works. To be honest: I never got Variance Shadow Maps to work with a proper gaussian blur Roll Eyes But I will get into it when the time has come.


EDIT: lol, 100 posts in alomst four years Grin
« Last Edit: April 21, 2008, 12:26:37 AM by Mietze » Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #7 on: April 21, 2008, 11:08:25 AM »

Just I can't believe the part with using more shader instructions instead of additional frustum cull. Please explain me, I'm little slow.
Actually its not only the frustum culling methods, which are normally very fast, but what do i say? You're the TVSceneManager guy, you know that better than me Smiley But also take a look about the geometry. 4 final scene renders also mean 4 times triangles per frame - better reason? Smiley
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #8 on: April 23, 2008, 12:44:06 PM »

All small update Smiley I've been fixing a few small bugs, like this:



The "red" area was out of range. The sampler is set to AddressUVW = Border, BorderColor = Red to visualize this.

Now this is how it actually looks like:



Note the quality difference between the red and green split Smiley I have been optimizing the frustum enclosement, which actually increases the quality a bit:



Now its perfectly enclosed Smiley
« Last Edit: April 23, 2008, 12:46:58 PM by Mietze » Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
AriusEso
Customers
Community Member
*****
Posts: 376

Esoteric


« Reply #9 on: April 23, 2008, 12:49:14 PM »

Very very cool. Wink
Logged

Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #10 on: April 23, 2008, 01:49:12 PM »

Great job Mietze!
By the way, which language did you use for this, C#? 2005 or 2008?
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #11 on: April 24, 2008, 12:24:59 AM »

Great job Mietze!
By the way, which language did you use for this, C#? 2005 or 2008?
Ya, its C# 2.0, but developed under MSVS 2008. I haven't got into 3.5 as that much, so I left it at 2.0 Smiley
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #12 on: April 24, 2008, 08:56:12 AM »

So this baby seems to work correct and fast now. I'm now going to take a look at the (Summed Area) Variance Shadow Mapping. I'll keep you informed if I got something to present Cool
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #13 on: April 24, 2008, 09:13:37 AM »

Some links that could help... While at GDC 2008 I attended a conference by nVidia which presented the most recent filtering methods for shadow-maps, which included Convolution Shadow Maps and Exponential Shadow Maps. Looks like they're good alternatives to VSMs.

CSM : http://www.mpi-inf.mpg.de/~tannen/papers/egsr_07.pdf
ESM : http://www.mpi-inf.mpg.de/~tannen/papers/gi_08_esm.pdf
The conference presentation : http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf

Edit : Oh and they mentioned Layered VSMs too!
http://forum.beyond3d.com/showthread.php?t=47427
http://www.punkuser.net/lvsm/lvsm.pdf
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #14 on: April 24, 2008, 10:01:39 AM »

Thank you a lot for those links! I havent even heard about LVSM yet Smiley Looks like I'll have to study them a bit... hoping theyre not to expensive Smiley
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #15 on: April 25, 2008, 10:30:40 AM »

Hmm.. I've got problems with my projection/view matrices. It seems like TV3D inverses it in a very weird way and I don't know how.. ARGH
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Zaknafein
Customers
Community Member
*****
Posts: 2670


WWW
« Reply #16 on: April 25, 2008, 11:49:01 AM »

Two things that might help :
- TVCamera.GetMatrix() actually returns the inverse view matrix
- If you're using OpenGL documentation for your implementation, all matrices in OpenGL are transposed
Logged

zaknafein.
>> the instruction limit : my blog & samples repository! <<
GD
Customers
Community Member
*****
Posts: 364


« Reply #17 on: April 25, 2008, 01:45:28 PM »

Actually its not only the frustum culling methods, which are normally very fast, but what do i say? You're the TVSceneManager guy, you know that better than me Smiley But also take a look about the geometry. 4 final scene renders also mean 4 times triangles per frame - better reason? Smiley

I see and I agree with you. Keep up the good work!

Convolution Shadow Maps kinda suck but damn these ESM look great! Haven't read the paper yet, but sure will. Shame no demos are available online.
Logged

tvsm.co.cc - TVSceneManager
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #18 on: April 28, 2008, 09:55:40 AM »

I make it short: It seems like I'm to dumb to get Variance Shadow Mapping and Exponential Shadow Maps to work properly. I've read both papers carefully and read it over and over again, but.. see it yourself:

VSM:


ESM:

Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Mietze
Community Member
*
Posts: 277

Pleeease, don't let it crash!


WWW
« Reply #19 on: April 30, 2008, 12:19:15 PM »

So this is Percentage Closer Soft Shadows:



I'm afraid that the result isn't as that good as expected. To be honest, it also sucks. I think I will end up with simple anisotropic-filtered shadow projection. This isn't the result I was aiming at, but it looks like its the only way to get acceptable shadows with PSSM.
Logged

Check out my blog at www.e-studioz.de - The finest in gross trash Wink
Pages: [1] 2 3 ... 6
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks