Directional Light shadows flickering issue

As you can see on video if I move my game objects 2500f (or even 200f) from world center point then shadows start to dance like crazy and if I go back to (0, 0, 0) everything is fine (don’t look at camera shake, it was some recording issue, only shadows flickering matters).

I’ve literally read every topic at google about it, I’ve found many solutions but none of them works. I’ve tested every option in editor:
graphic settings (even reseting and trying from 0), quality, bias, shadow distance, light rotation, camera far/near.

Only distance from center matters for me and I just can’t create 150x150 terrain.

I’m sure there is some solution, because for example there is no such problem in “Escape from Tarkov”. What am I doing wrong, what else should I check?

I’m using 2018.2.14, but I also tried with 2019.1.1 with same result. My graphic card is MSI GTX 1080.

1 Like

Ok for anyone that is trying to find answer, looks like it’s engine not my configuration and it won’t be fixed in default pipeline: Unity Issue Tracker - Flickering shadows with large Terrain + Cast Shadows enabled + large Shadow Distance value. Precision Issues?

1 Like

Do you see the problem in LWRP

In LWRP there were problems with trees and probably other shaders. I was really frustrated so decided to move my project to Unreal, always wanted to remind C++ :stuck_out_tongue:

3 Likes

LOL Amazing. Good choice @ritendev , good luck

I get the flickering in LWRP and the default pipeline. Raising the camera near z helps, lowering far z helps. The odd thing is that if you look at the Frame Debugger, most shadow casters stop drawing which would indicate that it is a culling problem.
At least the game speeds up when the casters are not rendering :wink: maybe it is an optimization.

2 Likes

In LWRP it looks like you can find angles where GetShadowCasterBounds returns false even if there are clearly shadow casters and receivers

I’m getting this shadow glitching too… It’s strange something like this is happening in Unity. Wish a Unity dev could get in on this thread…

1 Like

Same issue here, but after using temporal antialiasing those glitches are almost(huge diference) gone. Tested on small cube at 5700f away from center with 0.05f camera near and 10000f far clipping. :slight_smile:

3 Likes

What worked for me as a workaround is disabling Dynamic Rescale in HDPipilineAsset
With that disabled, I no longer get flickering shadows.

2 Likes

We get the same issue. Since it’s an endless racing game, the player can reach 10000 z points, everything starts to flicker much earlier. Using 2019.4

Hi @Tim-C @UnityMaru
Are you guys the best devs to ask about the flickering shadows?

So, please, what is the solution to fix shadows flickering issue?

guys solution is on temporal anti alising…lower jitter and all other settings…and shadows will stop flickering…just add post processing to scene in order to find temporal anti alising

1 Like

Hello! As a quick fix for this, I found that disabling shadows on the directional light, fixed this flickering problem. Unity should definitely look into this though, as this really screws up devs. Hope this quick advice helps some. (Temporary Fix).

1 Like

I’m not completely sure about this, but it could arise due to floating-point error at very large numbers. For whatever reason, Unity transforms are configured using single precision floating points instead of double. This means you can get something akin to a rounding error when you move too far from the origin. I don’t want to explain the binary architecture of floats here, but if you’re interested, this video does a great job of touching on these issues:

You should not be moving the player in an endless runner. You should move the world around the player. It’s quite odd at first, but a computer doesn’t conceptualize numbers like us, and it can only store a certain amount of precision. Hopefully this helps: if I say 0 and 0.1, you would recognize those as different numbers. If I say 11 million and 11,000,000.1 you would likely just round that to 11 million. Large numbers eat up the precision, so you should always keep the camera near the origin.

2 Likes

Setting my Far plane to 1500 on a 4km/4km terrain took away my flickering issue. This should not even be an issue to begin with but thats what i did to work around it for now.

Decreasing the shadow distance helped me with this issue

This Works^^