In this lesson, you will learn how to configure Virtual Shadow Maps (VSM) to achieve high-fidelity, pixel-perfect shadow quality that maintains performance across sprawling, massive open-world environments.
Understanding Virtual Shadow Maps
Traditional shadow maps use a fixed-resolution texture, which forces a trade-off: shadows look crisp near the player but become blocky and pixelated as they extend into the distance. Virtual Shadow Maps solve this by breaking shadow maps into a grid of tiny "pages." The engine only renders the specific pages required for the current view, allowing for effectively infinite shadow resolution that doesn’t choke your GPU.
When working with massive landscapes using World Partition, VSMs are essential because they decouple shadow resolution from the scene's scale. Unlike standard Cascaded Shadow Maps (CSM), which suffer from "shadow shimmering" or "popping" as the camera moves, VSMs provide stable, high-detail contact shadows regardless of how far the light source is from the object.
Configuration for Performance
To enable this, navigate to Project Settings > Rendering > Shadow Map Method and select Virtual Shadow Maps.
Once active, you must balance the memory footprint. Because VSMs use a large cache on the GPU, you can monitor the performance of your streaming setup using the console command r.Shadow.Virtual.Cache.FreePhysicalPages.
If you notice performance hits in dense foliage areas (managed by your Hierarchical Instanced Meshes), you can optimize the VSMs by adjusting the shadow quality settings on your light sources. For example, disabling "Cast Shadow" on small, distant decorative props can significantly reduce the number of pages the VSM system needs to track:
// Example: C++ logic to disable shadow casting for distant foliage
// to prevent VSM overdraw during heavy streaming
if (DistanceToCamera > MaxShadowDistance) {
FoliageActor->SetCastShadow(false);
}
By ensuring only essential geometry casts shadows within the VSM cache, you maintain crisp, stable edges even at the extreme edges of your open-world terrain, keeping your visuals consistent with your Nanite and Lumen setups.
Key Takeaway: Virtual Shadow Maps provide uniform, high-resolution shadows by virtualizing the shadow buffer into dynamic pages, eliminating the distance-based degradation found in traditional shadow mapping.