Incorrect shadow cast start position from objects

Hi!

I’m relatively new to UE5 and noticed a pretty weird interaction between shadows casted from objects in my project. Tried to scour google and the forums for an answer but couldn’t really get the terminology right for the problem so trying my luck making a post, feel free to point me at the exact term for this issue if there is one!

As you can see from screenshot 1 the shadow casted from the cube doesn’t actually start from the cube’s edge, red line is cube’s edge and the shadow starts a fair bit after it, also resulting in some off-looking corners like screenshot 2, on both screenshots the object is lined up to be exactly on top of another. This seem to be happening with shadows from all objects/sprites/etc and persists through moving the light source.
What could be the issue here? Is it the shadow resolution/settings, the material or some setting/tickbox that needs ticking?

I’ve also noticed that the shadow stops moving alongside the object at a distance around 53 or closer relative to the object the shadow is being cast upon, so a shadow at distance 40 and distance 20 between two objects looks exactly the same, this is happening disregarding the actual height in the world, so same behavior at both z 0 and z 500.

Could you please point me at what could be the issue here?

Thank you!


That depends on what shadowing method you are using, if you are using regular shadow maps, this is called “peter panning”. There’s basically no good solution for this, but you can use contact shadows to try to cover the gap.

A better solution is to use virtual shadowmaps, instead of regular shadowmaps, as it generally handles this a lot better.

If these are baked shadows using static/stationary lighting, then this is due to low lightmap resolution, just increase it. Ideally you should be using a stationary light if you need sharp baked shadows, as they bake their shadows to a 2D distance field that let you get a sharper result with lower lightmap resolutions.

But if you need pixel perfect shadows, basically your only option is to simply use raytraced shadows. They have a lot of drawbacks, but they will never leak like this.

1 Like

I’m testing out the regular shadow maps atm, but will also play around with virtual shadowmaps, really appreciate the tips shared!

I actually got it to work last night after a lot of digging and randomly stumbling upon cascaded shadow maps and their settings, lowering the Dynamic Shadow Distance MovableLight parameter in the light source increases the shadow accuracy to almost pixel-perfect (for human eye at reasonable view distance).

For anyone stumbling across this post in the future keep in mind this approach only works for Movable light sources and comes at a tradeoff of decreasing the max distance your shadows will render at from the camera, while increasing the accuracy of the ones that do render. Box in the distance to showcase the shadows cutoff at the param set to 2000, it’s located at a rough borderline, a bit closer and the shadows will come back.
This might not work that well with regular free cameras in 1st/3rd person and huge exteriors but for top-down, interiors or specific static camera angles it should do the trick. If this doesn’t work for you the options described by Arkiras might lead you to a better fitting solution.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.