What is causing this horrendous flickering? It’s not very noticeable at the edges of larger shapes separating light and shadow, but it’s maddening to look at in the case of the striped pattern produced by window blinds. This only happens when you move / rotate the camera, as you can see in the video moving an object through the shadow looks completely fine.
The only threads about shadow flickering I found here were about some issues in open world games where the camera moves far away from the origin and you start to get floating point problems. My scene is very small however, and the shadow distance is also set to only 10 units. The camera is less than 1 unit away from the origin in the video.
I tried messing with pretty much every setting related to shadows in the projects settings and on the directional light, nothing seems to affect this problem in any way. The only thing that makes it less noticeable is setting the shadow distance to around 2 units at which point the resolution is so ridiculously high that the flickering at the edges becomes somewhat less noticeable, but that obviously is not an acceptable solution. I’m perfectly fine with the shadow map resolution as is, I just want it to stop flickering as if the shadows are made out of ants.
I tested this scene in the HDRP too, no sign of the flickering there. Switching away from the builtin RP is not an option for me though because of dependencies, is there anything that can be done to fix whatever is going wrong here?
Thanks for the reply, but as I said I already tried every single option available related to shadows, including stable fit projection which is selected by default anyways. Using close fit instead doesn’t affect the flickering either.
Is the lattice actual geometry or an alpha tested texture? Don’t know if it matters but I’m running out of ideas.
What I can tell you is that we’ve had the same problem but setting QualitySettings.shadowProjection to ShadowProjection.StableFit fixed it. We are using the built-in render pipeline.
Thanks for the help, unfortunately that does not fix it for me. I already had the same suspicion and tried both mesh and alpha texture, both produce the same flickering shadow.
My guess would be that the shadow frustum is getting adjusted depending on the camera’s frustum. This is what happens when using “Close fit” instead of “Stable fit”, but this was already mentioned in the thread and didn’t seem to help OP’s case. I would still double check this since the shadows in the video really, really look like using close fit.
I’m very sure that what you see in the video is stable fit, as the shadow resolution always stays the same no matter where you look. Close fit adjusts the resolution depending on what is visible to the camera.
I thought this might be a bug introduced in recent Unity versions, but this problem exists as far back as 2019.4 LTS. I also created a fresh project and only imported the mesh with the blinds to see if something got messed up in my main project, but there still is the exact same flickering on both stable and close fit projection.
Why do I keep having so many graphics related issues that nobody else has ever experienced? Is this Unity not being able to handle my GPU again? Apparently nobody else has the problem where the lightmapper never uses more than a third of the available VRAM to bake either. I have a fresh Windows 10 running very little other than Unity and the latest drivers for my 6900XT so I don’t know what else I can do.
I’ve tested a similar setup in 2019.4 LTS and 2021.3 and shadows are rock-solid for me in both versions, no shimmering at all. Used exact same quality settings seen in your last video (shadow resolution, fit, cascade number and splits, etc).
Just as a sanity check, I’d create a new project and a scene with just a basic plane and a cube (no custom meshes), and see whether you can reproduce the shimmering effect there. If you cannot, then try to dissect your original project until you spot some difference.
If a basic project also exhibits the issue, then I’m at a loss.
The unity cube and plane shadow is stable, but any shadow cast from my mesh has the flickering. Not just the blinds, even a cube and other completely rectangular shapes.
What am I supposed to do about this though? I don’t feel like remodelling my entire scene out of unity primitives. I tried going through all of the import settings, none of them make any difference.
Good news is you won’t need to re-do the entire mesh, or approximate your scene with primitives. In this case, my guess is your mesh has some sort of non-manifold structure or some other weirdness to it (overlapping coplanar faces, zero-area faces, zero-length edges, etc) that is messing with shadows. You’ll need to hunt these down.
Note that not all non-manifold topologies cause problems. But while modeling it’s best to avoid anything that would make you go “ughh”, because it will make some rendering/simulation systems go “ughh” as well.
Nevermind, it’s not actually the mesh itself, it’s the transparent window materials!
I didn’t even consider materials since I was just using the default materials from blender instead of the proper ones in the video, but I forgot that the windows still have an extremely low amount of opacity and are set to alpha blend mode.
So my apologies to @georgerh who had the right idea all along, the flickering does come from an alpha tested texture, specifically in transparent and fade mode. Cutout is fine, no flickering there. I thought using the blinds alpha texture versus the blinds mesh made no difference because the glass texture was triggering the flickering in both cases.
This was extremely hard to solve because my scene is only indoors and only has one directional light that passes through glass at any point before casting a shadow, the culprit probably would have been much easier to spot otherwise. Maybe there should be some kind of warning about this flickering added to either the shadow mapping or standard shader rendering mode section in the manual, I can’t be the first and only person the come up with the revolutionary idea of using a transparent material for a window.
@arkano22 Thanks for the heads-up about fixing non-manifold structures anyways, I’ll be sure to look out for that as well in the future.
Sorry to hijack this post. I came here because I had a similar issue but none of the posted fixes worked for me. This might be slightly trivial but nobody seemed to mention it so I’m just leaving this here for posterity.
If anyone is experiencing the same thing and none of the above solutions work, try upping the near-clipping plane of your camera. I had mine set to 0.05 which made the shadows flicker. Setting it to 0.3, the flickering stopped.
My solution for my large scene is kinda weird, I had some empty game object under my Directional light, removing it didn’t fixed the flickering problem completely but it decreased it dramatically; it is still there now but not annoying at all.