Skip to content

Variance Shadow Maps (VSM)

Vladislav Kantaev edited this page Dec 6, 2023 · 9 revisions

Motivation

Variance Shadow Maps (VSM) is an alternative to Percentage-Closer Filtering (PCF), which are both used to achieve smooth penumbra.

While PCF works by sampling the shadow map multiple times and averaging the result during lighting computation, VSM blurs the shadow map as a whole. Thus, VSM does not require any complex sampling during the main geometry pass.

Generally, VSM is more expensive. But since it requires less resolution to fight aliasing, it can sometimes be preferred over traditional shadow mapping.

⚠️ Warning: VSM requires a valid background for proper blurring. Make sure to add a shadow-casting ground mesh.

⚠️ Warning: VSM suffers from lack of precision when used with the Half precision mode. Some platforms might not even support full precision for render targets required by VSM. In such cases, it is strongly recommended to use cascades or higher shadow map resolutions to mask the artifacts.

💡 Tip: because shadow acne is not a problem with VSM, positive Normal Bias can be used to fix light bleeding or even give shadows a more stylized "blobby" shape.

VSM

Setup

To enable VSM, Blur should be set to any value other than None in the Shadows/Shadow Maps sub-section of the pipeline asset.

Parameters

Blur Modes

  • Box: 2x2 blur with equal weights;
  • Gaussian Low Quality: a separable Gaussian blur with 3 horizontal and vertical samples;
  • Gaussian High Quality: a separable Gaussian blur with 5 horizontal and vertical samples.

Blur Scatter

Used to make the blur more intensive. Higher values, however, introduce obvious artifacts.

Blur Early Bail (Only With Gaussian High Quality)

Full Gaussian High Quality takes 5 samples. Blur Early Bail makes it skip the remaining two if the average of the first two is below the provided threshold. The higher the threshold, the more values we skip, but it can also cause artifacting.

Light Bleeding Reduction

Low values make the shadows smoother, while high values help preventing light bleeding, which is an very common issue for VSM.