• News

• Industries

• Learning & Support

• Community

• Marketplace

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;

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

As soone as I move the camera further away;

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

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.

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

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:

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

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

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.

Can you give me some kind of visualization? I need an explanation about the meaning of resolution and distance hereâ€¦

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.

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.

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.