ShadowMapping in the year 2015?

Started by
13 comments, last by Alessio1989 9 years, 2 months ago

Gentlemen / gentleladies,

Each time when not taking attention, the 3D-rendering world has been drastically changed, so I wondered what the current / common way of shadowmapping is.

About seven years ago, I implemented "Variance Shadowmapping". Basically rendering a depthMap for each shadow-casting lightsource (spotlights / point lights), and then doing a depthtest to determine whether a given position is shaded or not. And some additional math for the soft edge.

My main issues with doing ShadowMapping this way, are:

  • Got to render a depth-pass (possibly each cycle) for all contributing lights (and more than 1 for point-lights!)
  • Testing which lights actually attribute (directly) can be tricky - in cases where the light is out of sight, but its shadows aren't
  • Looping through lights in a single pass requires either a lot of shadowMap(depth) textures, or all maps being packed in one bigger "atlas" texture
  • Depth-testing requires some margin to avoid banding or self-shading issues. But this margin can also lead to "leaks"
  • Quality suffers over distance due limited texture resolutions (typically my maps are 256, 512 or 1024 ^2)

The distance issue can be partially solved by using cascaded-shadowMaps, but so far I only use that for one "major light" (usually the sun or moon), due its additional complexity. The leaking / accuresy problem might be fixed with 32 bit maps (I only tried 16 bit so far). Don't know if that is standard nowadays.

Is "ShadowMapping" (and the listed problems) still the case? Or are there better/smarter/faster/nicer ways these days? I've been reading bits about "Physically Based Rendering" and "Image Based Lighting", but I don't see how that would solve or improve this problem, as -correct me if I'm wrong!!- IBL is based on (pre)baked probes/nodes/cubeMaps, and PBR is a global term for replacing dirty hacks with a more realistic range of values, parameters, and techniques.

Ciao!

Advertisement


Each time when not taking attention, the 3D-rendering world has been drastically changed, so I wondered what the current / common way of shadowmapping is.

VSM, ESM, EVSM (all derivatives of SM) are being used in current titles I believe.

Some engines like Unity™ (saw in one forum one day) still prefer constantly varying from methods such VSM to PCF with a bunch of blur filters or HW accelerated filters (but I don't know why).

The future of rendering looks like it is path tracing (see here), and until there it will be a lot of possibilities regarding to shadow casting.

It's semi-on topic, so I'm gonna ask the question here: A couple months ago the I saw one or two fresh blog posts about someone who experimented with ray traced shadows on a fairly complex scene (couple million polys). I can't find the blog post anymore. The scene in question was some kind of small village/city surrounded by castle walls. Does anyone know what I'm talking about and could link me to it?

A Sampling of Shadow Techniches from MJP is still very up to date.

No one likes VSM anymore, shadow leaking sucks and evsm is very expensive to fix it. PCF has gotten better with more taps, as well as doing a smart sampling pattern ala Advance Warfare. http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare

Regardless, there are a lot of optimizations for depth targets. Here is a good resource: http://www.cse.chalmers.se/~uffe/publications.htm

"Efficient Virtual Shadow Maps for Many Lights." is a great paper if you think you can afford the overhead, and apparently there will be a new, improved version of such later on this year. Caching shadow maps is also a common idea http://diaryofagraphicsprogrammer.blogspot.com/2008/12/cached-shadow-maps.html You just store the shadow maps from previous frames and re-use them unless something is actually moving within the light's radius.

If you've got a static directional light then scrolling cascaded shadow maps is really good idea: https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2012/08/CSM-Scrolling.pdf it's very similar to caching shadow maps, you just use it for a directional light instead.

This is also useful: https://mediatech.aalto.fi/~ari/Publications/Shadow_Caster_Culling_for_Efficient_Shadow_Mapping.pdf a way to cull things from a directional shadow map if it won't cast shadows to anything on screen.

Sample distribution shadow maps can be used for much higher quality (ideally no aliasing) directional shadow maps: http://visual-computing.intel-research.net/art/publications/sdsm/sdsmLauritzen_I3D2011.pdf the excellent MJP has a sample out with a simplified (lower overhead) implementation that, I believe, is pretty much what is used in the stunning looking The Order 1886, so you can in fact run it in realtime on an actual game.

This: http://www.crytek.com/download/Playing%20with%20Real-Time%20Shadows.pdf offers a good overview of what Crytek did for Crysis 3...

And I guess that's more than enough information to get you going. Epic is experimenting with raytraced shadows accelerated by all their static (non skinned) meshes having generated signed distance fields, but it quickly gets slower than shadow mapping if your scene gets too complex.

Here are my two cents:

I'm using Camera Space Shadow Mapping (CSSM) algorithm, but now with DEPTH HISTOGRAMS to get optimal plane placements (every few frames).

Before I had to specify focus range (like 15-25m) but now that is handled by depth histograms.

In past (as Hodgman mentioned) there was annoying edge flickering (because it was perspective warping approach), but now, with new optimizations this problem is gone.

There were also problems with scenes like "airplane and the ground" where a lot of shadow map space was wasted on empty space between airplane and the ground (if you are in the airplane looking down and there is some shadow on the wing but most of it is on the ground far away). Not anymore.

IN SHORT:

· It is fastest (considering the quality);

· It is most precise;

· It uses smallest shadow map of all the other algorithm and achieves the greatest quality;

· Works for every imaginable case (big or small lights - including omni);

· It's a "one line of code" implementation (not really, but one line of code actually calculates everything, the rest is just passing parameters to the shaders and rendering scene);

· No one knows about it (I suck in PR and every few years I write shameless advertizing post like this one tongue.png).

I should probably write a follow-up paper explaining depth histograms and how they are used to squeeze every little bit of performance and quality from shadow mapping but who has the time these days (plus, convincing reviewer that you've actually created something new is extremely tiresome - they are not game developers - they don't get it - well, some of them do).

Well,it seems like that kind of a writeup would be well received here, if not necessarily in an academic setting (that is what you were talking about, right?)

Eric Richards

SlimDX tutorials - http://www.richardssoftware.net/

Twitter - @EricRichards22

OK.

Basically, difference between regular CSSM and CSSM with Depth Histograms is that every few frames, a depth histogram of the scene is obtained (after few frames of delay).

Now, If you look at the depth histogram, where ever you see a bump that means that there is some geometry on that distance that could have shadow. This helps you with the problem of "space between airplane and the ground" - we could simply ignore that empty space.

Then you integrate depth histogram by view angle which gives you a curved line starting from the bottom of view fostrum to the top of the view frostum (first read the CSSM paper to understand this).

Then you simplify that line to 4-8 segmments that will represent new projection planes of the standard CSSM. This time you don't have to specify focus distance. Now it works even with infinitely large scenes that don't have far clipping plane and quality is always maxed because shadow map texels are only used where they are needed (and distributed optimaly).

You can't get more quality than that - it's an ideal solution for any kind of scene and it works great even with tiny shadow maps.

So, not only that shadow mapping is focused only on visible space (no 50% wastage like with other algorithms - old CSSM introduced that) but now it is focused only on parts of the scene that can have shadow.

Original CSSM paper: https://bib.irb.hr/datoteka/570987.12_CSSM.pdf

Web page with old CSSM demo application: http://free-zg.t-com.hr/cssm/

Let me know if you want me to sketch this out in Paint smile.png

Edit: I've changed "plane" to "airplane" in the "airplane vs ground" example so the people don't get too confused since the term (projection) planes is used a lot.

Thanks everyone! That's a lot of information ... but my head wasn't able to process it today due a little hang-over :p Tomorrow I'll try again hehe.

Camera-Space-ShadowMapping sounds really interesting, and the movie on the webpage looks correct to me. But has it been really applied these days (I don't see it in the Crysis or Warfare papers for example)? I guess there are some "catches"? In my case, lighting is typically indoor. No large distances, but quite a lot local lights. And something I forgot to mention, lighting is often done in background passes as well (for water mirrors, realtime ambient kind of stuff, updating cubeMaps, ...). Currently these background passes also use the same shadowMap(atlas) but simplified techniques (no soft edges) to get a bit extra speed.

Have a look at my implementation of PCF, VSM and ESM for spot, point and directional lights:

screenshot.png
https://github.com/bkaradzic/bgfx/tree/master/examples/16-shadowmaps

You can play with the parameters and get a general impression of what to expect from each of those approaches.

This topic is closed to new replies.

Advertisement