In this lesson, you will learn how to deploy Virtual Shadow Maps (VSM) to achieve high-resolution, consistent shadow quality across massive, dense environments without the performance overhead of traditional shadow maps.
Why Virtual Shadow Maps?
In large-scale scenes, traditional shadow maps struggle with a trade-off: you either get crisp shadows near the player but blocky, pixelated shadows in the distance, or you incur a massive performance cost by increasing shadow map resolution globally. Virtual Shadow Maps solve this by using a tiled, virtualized approach similar to how Nanite manages geometry. The engine breaks the shadow map into small, fixed-size pages and only renders the ones currently visible to the camera, allowing for constant, high-fidelity shadow detail regardless of the object's distance from the viewer.
Implementation and Configuration
To enable VSMs, you must navigate to Project Settings > Rendering > Shadow Map Method and select Virtual Shadow Maps.
Because VSMs rely heavily on GPU performance, you should monitor the resolution and cache usage. If your scene contains very fine, complex geometry (especially when using Nanite), VSMs ensure that even tiny details—like blades of grass or intricate railings—cast sharp, stable shadows.
You can use the console command r.Shadow.Virtual.Cache.MaxPageCount to balance your memory budget. If you notice shadow flickering or artifacts during rapid camera movement, you may need to adjust the VSM cache to hold more tiles in memory:
// Increase the cache size to accommodate more shadow-casting detail
r.Shadow.Virtual.Cache.MaxPageCount 1024
Best Practices for Fidelity
- Combine with Nanite: VSMs are designed to work in tandem with Nanite. Since Nanite handles high-poly geometry, VSMs ensure those high-poly details don't "lose" their sharpness when casting shadows.
- Avoid Large, Fast-Moving Light Sources: While VSMs are efficient, frequent changes to large light sources (like a flickering sun) force the system to invalidate and re-render many pages, which can cause frame spikes.
- Debug Visualization: Use
r.Shadow.Virtual.Visualize 1to view the page distribution in your viewport; this helps you see which areas of your scene are consuming the most shadow resolution budget.
Key Takeaway: Virtual Shadow Maps provide uniform, high-fidelity shadows by virtualizing the shadow map into tiles, allowing you to maintain sharp detail in complex environments while keeping performance costs predictable.