Virtual Shadow Maps for high quality rendering / cinematics

Hello together!

I’d like to share a quick hint on how to get rid of some ugly VSM artefacts and maybe some people would like to share their tips and tricks when using VSMs for hq rendering / cinematics.

In general we get good results using static VSMs. Most problems become visible when the shadows are moving.

After playing around with ray count and samples per ray for a while I finally discovered that the weird pixel artefacts you can see on moving shadows are caused by adaptive ray count.

r.Shadow.Virtual.SMRT.AdaptiveRayCount 0 fixed this issue for us.

After this we tried to get rid of the noise by increasing r.Shadow.Virtual.SMRT.RayCountDirectional but this value has to be increased by a lot to see any noticable difference so it depends on overall scene performance.

Next we solved bright spots/shadow culling issues (you can see them on the bottom of the vide) by simply setting: r.Shadow.Virtual.CullBackfacingPixels 0

Another issue we did not manage to solve is getting softer shadows that are closer to the raytraced or pathtraced shadow reference.

Pathtracer:
image
VSM:
image

While we did manage to get softer looking shadows following the VSM documentation it introduces these hard lines and it can cause the loss of contact shadows.

Hope some of you will join this discussion! Cheers

VSM needs temporal AA (TAA or TSR) to reduce the noise and generally using Light Source Angles higher than the default 0.5357 value results in lower quality details and artifacts.

0.5357 matches closely with the sun on a clear day in the middle of the day. Would be nice to use higher values around sunsets or hazy/cloudy days.

Hey ZacD!
With hard shadows there is very little to complain about. Most issues become visible when you increase the source radius. Soft shadows are extremely important to match different lighting scenarios so this what we are trying to improve.

We are usually using TSR or DLAA for our renderings but you will still see VSM noise coming trough resulting in flickering.

We would like to use raytraced shadows instead of VSMs but they dont really work with foliage/subsurface scattering.

Back in the day I built an Area shadows solution for cryengine. It worked, but only for cinematics. If by the time I will need to render my project, we will still not have a soft shadow/Area shadow for unreal, I will try to recreate that solution in the form of a plugin for Area Shadow and another one for DOF bokeh, with custom shapes. Because unless you are using pathtracing, DOF also has problems/limitations.

I believe a better shadow system is needed even if you don’t intend to have a huge area light.
Even with normal sun size, the shadows projected from leaves high above the ground should be pretty soft and transparent, while leaves close to the ground will have sharp shadows and need to smoothly blend with the soft shadows.

I think the biggest dealbreaker here is the blending between soft shadows and hard shadows. I was even thinking about using the actuall subsurface scattering material type for my foliage and just going with fully raytraced shadows.

I’m honestly a bit mad about the fact that UE5.4 now costs money considering that it is just not production ready for people doing viz or cinematics and there is no support coming with that.

(Area Shadows für CryEngine3 dann? Erinnere mich an den Tech-Trailer. Area Lights und Top-Secret-Tesselated-Toad-Tech. Sehr nice!)

Even if the sun or the light source has a small/normal size, objects high above the ground like tall trees would still project soft blurry shadows, while foliage and objects close to the ground would project sharp shadows. As you can see in the picture. And these two shadows need to combine seamlessly. Raytraced shadows should do that, but as previously stated and as far as I know, they have missing features with foliage.

Is there a workaround with raytraced shadows ?

I was playing around with this the last couple of days and I didnt find a way to make this work. Raytraced shadows do not work with two sided foliage. The only subsurface scattering you’ll get is from the lumen GI doing its thing.

So basically there is no good solution for soft shadows right now unless you just dont want to use foliage in your scene.

As I said I’m working at a plugin solution for correct soft shadows and DOF without artefacts or missing features. Something which will work with everything. Only for cinematics and MRQ. But I’m not sure when it will be ready.
Plus I’m hesitant to devote too many work hours for this because it’s possible future versions of Unreal to offer this.

Yeah its always hard to tell if its better to wait or spend the hours. But I have the feeling that epic won’t give us a working hybrid solution anytime soon. In case you end up releasing your plugin anytime soon I would love to test and eventually purchase it.

Btw if you want to use raytraced shadows with foliage you can use the “subsurface” shading model instead of “two sided foliage”. But I’m not sure if this is a viable option for you.

Thank you for sharing the solution. Setting Adaptive Ray Count to 0 was the key to my issue as well.