Fixing virtual shadow bugs in Unreal Engine 5 and Lumen

Article / 21 October 2023

When creating realtime Arch Viz scenes, you might have run into problems with virtual shadow artifacts.
This is how you fix two of these.:
Disclaimer: Idk if this is the only or best solution for these bugs, if you have better ones, pls comment!

Chunky shadow cutouts

This is an easy one and happens when too much lights are lighting a pixel. use the console command:

r.Shadow.Virtual.OnePassProjection.MaxLightsPerPixel 32


Pixelated blocky shadows

This one is more tricky to fix. 
You want to give the texture lod a small bias to render the full res shadow at larger distances.
The console command would be:

r.Shadow.Virtual.ResolutionLodBiasLocal -2 (or even lower -2.5)

While this fixes the issue, it may introduce a Virtual Shadow Map Page Pool overflow. It is another issue and you may end up with a scene like this:

To fix this, you can enlarge this value in the projects DefaultEngine.ini THIS COMMAND WONT WORK FROM WITHIN THE EDITOR CONSOLE:
Remember, when placing commands in the ini, you have to separate the command from the value with an equal sign "="

r.Shadow.Virtual.MaxPhysicalPages=16384

While the 16k may sound a bit large, it didnt cause any problems for my mobile 4080 GPU and I was able to render away
This will fix now both issues. The blocky shadows as also the Virtual Shadow Map Page Pool overflow.


For your convenience, you might want to put all your changes into your DefaultEngine.ini.
This may look like this:


; fix shadowbugs
r.Shadow.Virtual.MaxPhysicalPages=16384
r.Shadow.Virtual.ResolutionLodBiasLocal=-2
r.Shadow.Virtual.OnePassProjection.MaxLightsPerPixel=32