The three most popular shadowing techniques for real time applications are:

Shadow maps

Advantages:

  • Fast
  • "Simple"

Disadvantages:

  • Numerical limitations lead to artifacts and jaggy shadows
  • You only get the information of the first object hit by the light, not the last (important for more photorealistic effects)

Volume shadows

Advantages:

  • Almost no numerical instability

  • Hardware built-in support through stenciling

Disadvantages:

  • Slower than shadow maps

  • Finding the last object that the light hits isn't easy

Volumetric rendering

Advantages:

  • Analytic precision
  • Allows for great photorealistic shadows
  • Finding the last object hit by the light is trivial

Disadvantages:

  • SLOW, VERY SLOW
  • Has an awful asymptotic running time for ray intersection calculations (linear in the number of primitives without hashing)

Are there any new experimental shadowing techniques that can improve on the advantages of any of these while eliminating some of the disadvantages?

  • 1
    The answer to this is a large list of things, but SSAO algorithms fall into this group. PCF shadow sampling as well (making the sampled shadow maps look nicer). Purely ray based shadows can give nice soft edges if you take enough samples per pixel. Another technique is to render a shadow map from a random spot on the light source every frame and let something like temporal anti aliasing integrate the correct result over time. – Alan Wolfe Feb 7 at 0:45
  • 1
    Some minor comments: Shadow maps: The main disadvantage is not so much numerical limitations but sampling rate. It's hard to get this above the required Nyquist rate for the final image (without excessively sampling other areas), leading to frequent aliasing artefacts. Shadow Volumes: I don't understand the "finding the last object" problem. One problem that sometimes crops up is keeping the volume closed when clipping against the front clip plane, but there are several ways to avoid this problem. – Simon F Feb 8 at 16:01

There’s an interesting technique that’s been used in demoscene and Shadertoy projects for a while, and an analogue of which recently made it into Unreal Engine 4: using signed-distance fields and raymarching to produce high-quality soft shadows with accurate penumbras.

example distance-field shadows in Unreal Engine 4

There’s a good writeup of the idea, with some visual examples, by Íñigo Quílez here—I’m not sure whether he invented the technique or was just one of the first to write about it:

The trick is to think what happens when a shadow ray doesn't hit any object, but was just pretty close to do so. Then, perhaps, you want to put that point you are shading under penumbra. Probably, the closest your point was to hit an object, the darker you want to make it. Also, the closest this happened from the point you are shading, the darker too. Well, it happens that as we raymarched our shadow ray, both these distances were available to us! … So, we can simply compute a penumbra factor for every step point in our marching process and take the darkest of all penumbras.

The documentation on the corresponding Unreal feature is here; their description of the technique is a little vaguer, but still helpful.

To calculate shadowing, a ray is traced from the point being shaded through the scene's Signed Distance Fields (SDF) toward each light. The closest distance to an occluding object is used to approximate a cone trace for about the same cost as the ray trace. It allows for high-quality area shadowing from spherical light source shapes.

The main advantage of this approach is its high visual quality—most other techniques don’t handle varying penumbras well, and it doesn’t suffer as much from the aliasing problems of shadow maps. The main disadvantage is needing a distance-field representation of your scene geometry to trace rays through; unless you built it that way in the first place (there’s a fascinating talk about how the team behind “Dreams” did exactly that), you’ll need a way to construct the SDFs out of your mesh geometry, which is an expensive and sometimes error-prone operation.

UE4 handles the SDF generation by building them offline beforehand and then stamping them into a volume around the camera at runtime (more information on that here), but it’s not a cheap process so UE’s approach is only viable on high-end hardware for now. That said, if you do already have your scene geometry in SDF form, it’s quite easy to implement—see this Shadertoy for an example.

  • This is very interesting indeed, but it seems like it would suffer a lot for varying geometry scenes – Makogan Feb 7 at 21:35
  • It depends—as long as the transformations you make on individual objects don’t involve deformation (i.e. moving a thing around as opposed to bending it), you can keep using the original volume texture for each object and just apply an appropriate inverse transformation when you’re sampling it. But yes, this approach isn’t as helpful for deformable geometry like animated characters. – Noah Witherspoon Feb 7 at 21:39
  • That's not the only thing I am thinking of, imagine objects appearing and disapearing from your scene (projectiles for example), this seems like it would have a problematic scaling time for something like that – Makogan Feb 7 at 21:47
  • 1
    You could replace the SDF with a cube map. Nvidia's GPU Gems has a chapter about this. developer.nvidia.com/gpugems/GPUGems3/gpugems3_ch17.html This would result in a lower quality but it is easy to generate and a lot cheaper than SDF to generate, especially when things are animated. – bram0101 Feb 8 at 7:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.