Shadow Cascade Distance

Hello,

  1. Is there any way to change the distance for each shadow cascade?
  2. Is there any way to force a specific shadow cascade to appear everywhere?
1 Like

Simple answer from what I had asked before: No you can’t.

I also once i asked if it’s possible to animate shadow cascades according to camera distance so the cascade length can always be accurate on a key moving object. Ex. Camera moving form close to far view but you need the center target area to always have the highest definition of shadowing and could compromise on backgrounds and foregrounds.

That’s not possible either, not sure if it would be possible if someone really goes deep in the source code.

No way to control cascade distance,
no way to force specific cascade,
no way to increase shadow res beyond 4096,

next gen engines… :frowning:

Not really. You only have overall cascaded shadow distance control, which is split into cascades according to distribution exponent parameter.

Not sure what exactly You are asking about in this question.

To make first shadow cascade appear all the way instead of transitioning into second cascade, then third and fourth.

Well, that is the same as reducing cascade count to 1

This is why i get cooked up on fanboys living the dream of realtime is that future just around the corner that will render your upcoming starwars movie. They have no idea how difficult it is to get any decent image that will be playable to start with and i’m speaking of the basics in lighting here.

Not quite what I mean. I hope the image explains better.

https://i.imgur.com/xJWMByf.jpg

Some other engine:

https://i.imgur.com/klaVIhw.jpg

Back in UE4:

https://i.imgur.com/8CphAg0.jpg

CE/LY has somewhat different shadow projection, different initial settings, but in the essence, everything else is still the same.

You can’t pull out shadow map resolution out of thin air, sadly.
Increasing shadow distance, shadow resolution and number of shadow cascades will get you where you want. Plus, shadow sharpening slider helps quite a bit.
Adjusting exponent will also allow you to span first cascade further.

I was rather interested in a way other than playing with sharpen slider, because that sharpens the blurry shadows and doesn’t bring back the details.
The screenshots I’ve posted above (First and Third) are both with 4 cascades and CSM distance set to max. Setting shadow res to 4096 still gives somewhat blurry results if camera isn’t close to the object. I’m trying to take some cinematic screens and don’t care about performance but even then it’s just disappointing to be so limited here. Anyways, thanks for the replies.

4 cascades is not enough for long-range open world scene(I assume that is what you are after). But besides above mentioned things, not much you can do, unless you are willing to dive into the engine code a bit.

Overall you are right about what you are describing being a problem. It has cause. shadow filter has a constant size, disregarding cascade number. Not hard to guess that world size of the filter can vary from centimeters for first cascade to meters for last cascade. It is possible to reduce filter size with each cascade, but doing so creates new issues,gives some complications in implementing it and does not tag along well with box shaped filter, that is default in UE4.

I don’t have problems mixing different shadow techniques to get the results I want. Keep in mind this is realtime rendering, not a raytrace engine, so pixel-perfect shadows are just not going to be possible. That being said, this is the mix I love using the most:

Distance Field: 30,000 - 100,000+ units - Per-pixel shadowing in the deep background.
OR: Baked shadows for static projects. Baking takes care of distant shadowing.
Far Shadow: 8,000 - 20,000 units - Separate cascade for distant landscape. One cascade for distance usually enough. Toggle in large meshes to be included.
CSM: 8,000 Units - Good resolution, works with alpha masks for foliage, but not very sharp. Performance depends on number of objects in scene, number of cascades, and resolution.
Contact Shadows: <0.1 length, entire scene - Sharper definition for details where lower-res CSM may miss. Excellent for foliage.

Using all these techniques together you will get stunning shadows. But the memory and computation required for larger resolution captures grows exponentially. A 4K capture has 16 times more pixels than a 1K capture and yields an image that is 16.8 megapixels large. This has to be captured every frame.

1 Like

Thanks but I wasn’t really interested in sharp shadows for open world/far distances.
I have a scene that sits relatively close to the camera, something like the distance from this cube to the camera, not as close to have sharp shadows and not as far to rely on distance field shadows: https://i.imgur.com/8CphAg0.jpg and I find it hard to believe we can’t have some better shadows at such distance right out of the box.

I don’t think I desire anything beyond what other real time engines do. The other image I posted was from cryengine, and shadows there looked much sharper even in cryengine 2 back in 2007 than ue4 today. But I guess that’s because static lighting has always been the main focus here so we have a perfect lightmass that does wonders for some projects and then we have dynamic lighting which does less than some 2007 tech used to do. Thanks anyways.

I’m not seeing your same results, unless I drastically reduce the quality.

Movable Directional Light
Default CSM Distance, 3 Cascades, default transition
Distribution Exponent: 4(Default is 3)
Epic settings
MaxCSMResolution is 4k in this image, but 2k is not much of a difference.

My CSM res was at default. I get same results as you once I increase it to 4096, but:

You’ll notice this once you approach the object slowly. It’s much sharper when you go close up and I was interested in that sharpness from not close up. First cascade is always sharper than second, third and fourth of course, that’s why I was looking for a way to increase first cascade distance.

Do you have any issues with contact shadows? The method I listed was not just for open world, but all shadows in general. UE4 has broken down the best way to handle shadows at a variety of given distances. Contact shadows will improve clarity for sure, but it needs to be leveraged with CSM to avoid all the artifacting. Using a very high quality shadow map and a shorter distance will improve CSM while contact shadows take care of the rest. And good news for you, contact shadows work on any stationary or dynamic light source!

The only way you can possibly get sharper shadows than per-pixel raycasting is per-vertex stencil tracing, but the costs scale exponentially for high-polygon objects and it’s completely unnecessary. We’re rendering these things on the fly: it’s all smoke and mirrors. Do what you can.

1 Like