Download

Cascaded Shadow Maps explanation needed

Hi guys.

Can someone explain to me, how the Cascaded Shadow Maps work and how I set them up with the best quality?

This is the Distance 20000;
No crisp, Sharp shadow:

This is Distance 4000;
Camera is very close to the foliage; Crips, sharp shadow.

As soone as I move the camera further away;
Blurred Shadow:

At Distance 4000, I get the best results, but only if the camera is very close.
I want to have detailed shadows with a further distance of the camera.
With Values lower or higher than 4000, the shadows are ALWAYS undetailed.

I’d like to have a proper explanation how to setup the shadow maps so I have Detail 1 until Distance X, Detail 2 until Distance Y and so on.

I not full sure but

change shadow distance / nun dinamic shadows / distribution exponenet.

In you example 4000 / 4 / 4 = 250 for the best quality

r.Shadow.MaxResolution and Shadow Filter Sharpen are the value you can tweak, but getting masked grass, like the one you have, to cast detailed shadow comes at very high performance cost.

250 What?

Well. I’d like to have “super detailed” shadows until Distance X, “not so detailed Shadows” until Distance Y and “horrible Shadows” at Distance Z.

Shadow cascades is simply a lod for dinamic shadows. “nun dynamic shadows” is the numbers of the chunks.

Check this link

https://msdn.microsoft.com/en-us/library/windows/desktop/ee416307(v=vs.85).aspx

Shadow distance / nun dynamic shadows / distribution exponet

if you set “Shadow distance” to 4000, “nun dynamic shadows” to 4 and distribution exponet to 4:

4000 / 4 / 4 = 250 unreal units from camera the best quality.

if you set “Shadow distance” to 4000, “nun dynamic shadows” to 4 and distribution exponet to 1:

4000 / 4 / 1 = 1000 unreal units from camera the best quality.

if you set “Shadow distance” to 4000, “nun dynamic shadows” to 1 and distribution exponet to 1:

4000 / 1 / 1 = 4000 = 4000 unreal units from camera for the best quality.

btw this is the theory but can be wrong:rolleyes: .

According to you, the distance must be:
10000/ 2 / 1 = 5000 units for the best quality.:rolleyes:

That is exactly how shadow cascades work.

hahahaha sorry men my apologies i mismatch completely how work. :o

I know that. But they don’t work how I think they work.
There’s no documentation about what parameter does what.

here is the documentation

https://docs.unrealengine.com/latest/INT/Resources/ContentExamples/DynamicSceneShadows/

look like I say…

There is only one shadow map that is being used. I think it is 1536 x 1536 or something by default on highest settings. That one texture is then split into different parts, called cascades. First cascade is the one that is closest to the view, thus it gets the largest portion of that one 1536 x 1536 shadow map. Next cascade starts from where the first ends and it goes on further. That second cascade will have a smaller split of the 1536 x 1536 texture. This splitting happens as many cascades you have specified.

The distribution exponent specifies the ratio between sizes between the shadow cascades. I guess having an exponent of 1 means that each cascade is equally large, which isn’t optimal since you need higher resolution up front.

But why is the resolution most of the time low?
Even on highest settings, achieving a good result is very hard

Also to second on that, if lets say the first fraction that has the “in theory” highest quality that looks nice and crisp over 250 units gets spread over 800 units instead, it will still use the same resolution to cover a larger area thus meaning a decrease in quality! The only way to work against this is increasing cascaded shadow map resolution via console variables.
So just increasing the distances will not make the shadows look better, it will blur them even more if you dont compensate with higher resolution :slight_smile:

Cheers

Well the resolution can be as low or as high as you want it to be.
Try the console command r.Shadow.MaxResolution 4096
It’s worth mentioning that increasing the Dynamic Shadow Resolution can have a HUGE impact on performance.
So it’s probably a good idea to have it as a setting in your game options menu, where 4096 could be very high, ultra or whatever.

I see I haven’t understand the Cascaded Shadow Maps.
Can you give me some kind of visualization? I need an explanation about the meaning of resolution and distance here…:frowning:

I’d try setting the Editor scalability settings for Shadows to “High” or “Epic” before experimenting with cascaded shadow maps, as they seem to crippled on the lower settings by default.

https://docs.unrealengine.com/latest/images/Engine/Performance/Scalability/ScalabilityReference/ScaleR_ViewQual.png

You need to understand that the resolution of the shadow map will stay the same regardless of the settings you set for the light shadow settings. If you increase the distance you’re effectively stretching the shadow map, which in turn causes low res shadows.
Cascaded shadow maps just split that single shadow map into different parts and those parts can be made larger or smaller depending on your settings. It basically allows you to trade resolution between far and near cascades. Far away stuff doesn’t require much resolution since you can’t see it anyway, so it’s better to use that resolution close to the camera.

This is a general idea behind the Cascaded Shadow Maps:

To have a really good resolution in front of the camera you need more cascades or higher resolution or shorter range that they cover. You could try all three, don’t remember if amount of cascades is capped.

Dead old thread but I am interested in cascaded shadow maps settings for VR.

Well, I just want to throw my two cents in here as I’ve been studying UE4’s lighting extensively for almost two years now. Regarding cascaded shadows, UE4 behaves a little strangely under particular circumstances:

  1. Movable directional might tend to have significantly sharper results than Stationary. Not entirely sure why, but it’s a symptom that also exists with spotlight and point light dynamic shadows as well.

  2. You can have more than four cascades, but weird artifacts may begin to appear, such as shadows cutting off at a shorter distance, or not rendering at all.

Now, you’re not going to want to get a sharp shadow for grass strictly from shadow cascades because you will murder your performance. I’m also going to assume you’re not using Ray-Tracing. Thankfully, that’s what contact shadows are for, and if you aren’t sure, it’s a parameter in the directional light settings, and the difference can be striking. I typically set the value between 0.01-0.03.

No Shadows

Shadow Cascades Only

Contact Shadows/AO Only

Contact Shadows and Cascades


​​​
Hope this helps
​​

2 Likes