VSMShadowMap vs PCFSoftShadowMap in Three.js

Choosing the right shadow map type in Three.js is crucial for balancing visual realism and performance in WebGL applications. This article compares VSMShadowMap (Variance Shadow Maps) and PCFSoftShadowMap (Percentage Closer Filtering Soft Shadow Maps), analyzing their rendering techniques, visual quality, performance impact, and ideal use cases to help you make the best choice for your project.

PCFSoftShadowMap: Smooth, Multi-Sampled Shadows

PCFSoftShadowMap uses Percentage Closer Filtering (PCF) to soften the edges of shadows. Instead of a binary check (shadowed or not) for each pixel, it samples the surrounding area of the shadow map and averages the results.

Pros of PCFSoftShadowMap

Cons of PCFSoftShadowMap


VSMShadowMap: Variance-Based Soft Shadows

VSMShadowMap utilizes Variance Shadow Mapping. Instead of just storing the depth of the geometry, VSM stores the depth and the depth-squared values. This mathematical approach allows Three.js to estimate the probability of a pixel being in shadow, enabling smooth filtering and blurring.

Pros of VSMShadowMap

Cons of VSMShadowMap


Direct Comparison

Feature PCFSoftShadowMap VSMShadowMap
Shadow Edge Quality Soft, but can become grainy Extremely smooth and naturally blurred
Performance (Small Blurs) Moderate to Good Moderate
Performance (Large Blurs) Poor (highly resource-intensive) Excellent
Artifacts Shadow acne (manageable with bias) Light bleeding (inherent to the math)
Memory Usage Standard High (requires 32-bit float textures)

Which One Should You Choose?

Select PCFSoftShadowMap if your project features complex, close-up geometry, indoor environments, or layered objects where light bleeding would ruin the realism. It is the safer, more robust choice for general-purpose 3D rendering.

Select VSMShadowMap if you are rendering vast outdoor environments, scenes with large distances between shadow casters and receivers, or projects where highly stylized, ultra-soft shadows are preferred and light bleeding can be managed through careful layout design.