Improving Virtual Shadow Map Distance/Quality

Hello all. With virtual shadow maps, I’m having trouble getting detailed shadows to stay visible as I move the camera further from mesh geometry. This is just with a single directional light, movable.


As this picture tries to show, moving a slight distance forward towards this mesh results in a much more dark and detailed shadow appearing under the bricks. That’s working as intended, I understand, as part of the clip map system. However, I’m just a little confused as to how close you have to be to have those detailed shadows appear, and how abruptly the shadows just disappear as you get farther away.

Here’s an example of how this is killing me as I create my environments. Simple doorway geometry. Shadows from the sun overhead. As you recede just a hundred feet away or so, the shadows start to break down, tear away from the overhang and then just disappear. Where’s my crisp, dark, fine shadows in the distance as shown in the epic VSM doc?

I feel I’ve played with every setting I can to no avail. Does anyone else have this issue? Or know any ways to fine tune the LOD/draw distance system for the virtual shadow maps?

Hey @Apgar426! So this question get’s asked a bunch, and I’ve got just the thread for you.

Take a look at the top post there, the poster actually compiles a ton of useful console commands as well as other scalability settings and documentation to do just this! Just be wary about the performance hits you could take if you have tons of geometry and everything is rendering shadows from large distances. Hope this helps!

1 Like

Thank you for the link, but that thread is from 2014, well before the age of virtual shadow maps, which are default for UE5. Those commands have no effect now. I can find scant information on VSM issues and fixes. It’s as if it’s working perfectly for everyone else. Guess nobody needs a properly shadowed window sill. Back to contact shadows it is… :man_shrugging:

Ahhh you’re right, there’s definitely new sets of commands now. I’ll have to take a look and see what I can find engine-side. I’ll add it to my research bucket, since you definitely won’t be the last to ask this and I know little about the new systems commands myself.

Alright, so the reason every unreal image has those crisp fancy shadows is that all nanite meshes apparently don’t have their shadows culled naturally like normal meshes. So if you’d try it out for me, test the command r.Shadow.Virtual.UseFarShadowCulling 0 it might adversely effect your performance if you have tons of normal meshes. This should allow for no culling when using the new VSM system on any mesh.

That is a good guess, thank you for investigating. Unfortunately, that command doesn’t seem to effect any shadows, on nanite or not. These are nanite enabled meshes I’m now working with, they show up in the nanite visualization and everything. Stats show no culling going on. It seems like it might have to do with the clip map, since this is a directional light. here’s a pic. The shadows are starting to disappear even a few feet away, once you hit the green zone. Further back, once you hit orange, even the board overhead loses its shadow. The clip zones can be adjusted a little using some commands, but I can’t seem to get much improvement.


One thing I thought of is that I am not using ray traced shadows (No RTX card). In the documentation here Hardware Ray Tracing in Unreal Engine | Unreal Engine 5.0 Documentation if you scroll down to the “ray traced shadows” pic, you can see along the edges of the picture frame for example, the shadows starting to disappear in the non-rtx render. I would really love it if someone with an RTX card could do a little shadow test, like I’ve done, and verify whether shadow distance from small objects is improved significantly with “ray traced shadows” enabled in project settings.

Alright, I went ahead and did it myself. I realized I could run enable ray tracing on my GTX 1660 Super. I turned on ray traced shadows and all my shadow draw distance woes disappeared. Performance is still pretty good surprisingly.

1 Like

Even if that can be a solution (I also love RT shadows), RT is supposedly deprecated and it’s not thought to work well with Nanite so, anyway, a solution for “Lumen shadows” (VSM) should be found.

1 Like

I think I actually figured it out just now. I was looking at all the console commands starting with “r.shadow.virtual” and I found some not listed in the doc - there’s one called r.Shadow.Virtual.contactShadowLength. Changing that from the default .02 to .01 or less actually fixed the draw distance issues I described originally!

2 Likes

Wow, you’re right!

The command is r.Shadow.Virtual.ContactShadowLength but default value is 0.02. You can even reduce it to 0, to gain even a little more distance (still weaker than RT shadows, but quite near regarding distance visibility).

1 Like

Another thing related to the topic - anyone experiencing noise/graininess in VSM shadows (or RT shadows), make sure you turn on Temporal AA or Temporal Super-res AA in the project settings under anti-aliasing.

1 Like

Recently updated to 5.2 and found out, that render distance is less than in 5.0.

Commands mentioned in this thread does not help.

Does anybody know what might increase Virtual Shadow draw distance in UE5.2?

This command seems to be no longer available in 5.2

5.3 can use r.Shadow.RadiusThreshold 0.01(deault:0.03)

4 Likes

This is amazing. Without this, the default Engine behavior was having shadows disappear from my levels much too soon, even on High settings.