I’ve just added the ‘Geographically Accurate Sun Position’ plugin to my project (it was added in 4.21) and I am trying to make the sun constantly move across the sky in a day night cycle. I setup code to update the time values in the Sun Position BP every tick. The sun moves perfectly and overall the shadows follow it, but looking closer the shadows are now constantly flickering, with lines of shadow moving across the landscape. Here is a picture:
These lines are constantly moving and flickering. I tried reducing the frequency that the sun position was updated, but it just made it flicker slower and also made the sun too jerky for my liking. What can I do to make the shadows move smoothly?
Alright, can you try and zoom or scale up one of the rocks to verify whether it’s happening to them too?
It’s a bit tough to go off so little info so I’m gonna shotgun you with some potential solutions to try:
Is the landscape a Static Mesh or you made it in-Editor? Does its material use a Normal map? If so, disable it or set a flat one (R=127,G=127,B=255) and check if the issue persists.
Try adjusting these settings in your directional light:
Increase Shadow Bias. Decrease the Shadow Filter Sharpen. Make sure Cast Dynamic Shadow is checked. Increase Dynamic Shadow Distance. Increase the Number of Dynamic Shadow Cascades.
I haven’t found a complete solution for this myself. But I am having some success getting rid of the ripples. I can’t do anything about shadow flicker though. What I decided to do was code around the issue. So when the sun position is at those really low angles and shooting shadows across the terrain, I am disabling shadows and the re-enabling them once the sun gets higher in the sky. Hope this helps.
I’ve tried everything you said with no success. I put a cube into the world-it was also affected by the flickering shadows and the shadow it cast itself was also affected, so it seems all shadows in the world have this problem. Removing the normal map from my landscape did nothing. I tried all the adjustments to the directional light that you said, but none of them stopped the flickering. What more information can I give you that would be helpful?
Hey there, sorry for the late response. I’m away from UE at the moment but in the meantime can you tell me about the terrain, is it a static mesh? If so, Stationary/Moveable?
Can you try creating a new level, add the terrain, and rotate the default light manually to see if you get the same flicker?
It’s a landscape, done using level streaming. But clearly that doesn’t make a difference, because when I put a cube in the level (static mesh) it had flickering shadows on it too. I tried changing the mobility of the cube but it has the same flicker if it is on stationary or movable. When I rotate the directional light manually the same flicker persists.
I think most likely the problem is that the shadows have some element of randomness in them and because I move the directional light every frame, this is re-calculated every frame and therefore the shadows look subtly different each frame. This would explain the flicker. The only question is now how can I get rid of it or work around it?
So not sure if this helps but after I coded around the ripples I noticed something about the flickers. For me they only flicker on Medium settings. At low shadows disable. And on High and Epic it doesn’t flicker for me.
@Marsminer. Was this addressed for you? I do gert same issue.
See 3 consecutive frames from a render. (this does persist in real-time window at MID, EPIC and CINEMATIC settings.
Afraid I haven’t opened unreal engine for 2 years and can’t remember anything about this but most likely I didn’t find a fix as I would have posted about it here.
Hi, currently I am using non-virtual shadow maps, and my shadows were also flickering. First, click on the static meshes that you have flickering shadow problem and then try enabling Dynamic Inset Shadow. That fixed my problem. Hope it is helpful for you too.