Skip to content

Better shadow maps #5554

@Usnul

Description

@Usnul

Shadow maps in three are pretty good, but in terms of technology behind them they are stuck in 1978-ish (Percentage Closer Filtering: L. Williams, Casting Curved Shadows on Curved Surfaces, Computer Graphics 12, 3 (August 1978), 270-274. )

Shadow maps as they are have many problems:

  • peterpanning
    peter panning
  • acne
    shadow acne
  • perspective aliasing (resolution distortion)
    perspective aliasing
  • underestimated penumbra, overestimated umbra
    umbra penumbra
  • light bleeding
    bleeding
    to name a few.

MS has a good article on this, i'm sure many of you have seen it:
http://msdn.microsoft.com/en-us/library/windows/desktop/ee416324(v=vs.85).aspx

Many of these issues can be avoided through use of stencil shadow maps, but these require geometry shaders which we don't have yet in webgl in order to be effective. Stencil shadows have their own set of problems, for one - they are dependent on scene geometry complexity a great deal and so add an exponential factor to performance overhead of a renderer (complex scenes will now take even longer to render proportional to their complexity).

Since we are somewhat stuck with shadow maps, there are a few things that shadow maps have picked up over the years to reduce aforementioned artifacts:

in fact, this paper on Variance Soft Shadow Mapping addresses most of the issues:
http://web4.cs.ucl.ac.uk/staff/j.kautz/publications/VSSM_PG2010.pdf

For a decent overview on recent methods of shadowmapping, here are 2 good presentation:
http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf
http://advancedgraphics.marries.nl/presentationslides/18_variance_soft_shadow_mapping.pdf

Based on what i've seen/read, i believe a variant of VSM is needed. To deal with perspective aliasing, we need a robust support for CSM (cascaded shadow maps). In r69 (current release to date of writing this) CSMs are broken in three, even if they were not - there are many restrictions for them in three:

  • no more than 3 maps
  • manual tweaking to set up each shadow and its respective bias/dakness/near-far planes etc.

The reasons i believe these to be important:

  • light and shadow play massive role in perception of 3d scenes, so majority of mainstream graphics engines have a plethora of tools to assist lighting/shadowing and automate it where possible.
  • shadows are notoriously difficult to get looking "okay" in three, this serves as a barrier to many people.
  • currently if you have a large plane you want to receive shadows - you are out of luck pretty much. Shadow settings are too dependent on scene currently.

For a game engine the shadows that three has to offer are lacking, i don't believe it has to be so. If we have a robust shadow mapping implementation with few parameters and CSM on by default - everyone who uses shadowmaps will benefit automatically, and new users will find it pleasing to be able to get amazing shadows with little-to-no tweaking out of the box.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions