- Home /
how to stop real time shadows in Unity5 from blinking flickering and fritzing
We are building a flying simulation with a large multi-kilometer city model. simple shader : standard opaque. simple lighting : single directional light and skybox.
The buildings are exhibiting what looks like z-fighting errors with what appear to be the real-time shadows on them. souped up system, Intel i5 / 16gb ram / Radeon 7990 6gb gpu. Windows 7, DirectX 11.
The screenshots below were taken from a stationery vantage point as the buildings flickered.
does anyone know how to fix this?
Answer by gregroberts · Apr 21, 2015 at 03:49 PM
We solved it. We had clipping planes on the camera between 0.1 near and 10000 far. We had this because the flyer sits on the back of a robot and we want them to see both the robot and distant terrain. The terrain + asset set is quite large, about a 10k x 10k swath of land, sea, and buildings.
turns out this extreme focal range messes with most GPUs capabilities.
A simple modification of the camera's near clipping plane from 0.1m to 0.4m completely solved this problem.
Here's where we found the hints: http://forum.unity3d.com/threads/terrain-flickering-really-annoying-please-help.164936/
Good question & answer. I have the problem so it's good that you found a solution.
Answer by mephistonight · Jan 07, 2018 at 02:17 PM
I know this is an old thread but it's high up when searching for this problem so am adding some info that helped me:
Setting the near clipping plane to 0.4m also solved this for me, except that it's not a good solution for me as it allows a first person camera to see through walls, clip the top of arms moving infront of the camera etc.
What worked for me was my changing some settings on my directional light's shadow settings. By increasing the Bias from the default 0.05 to 0.5 I was able to retain the camera's near clipping plane at 0.1 and also prevent the flickering. I think the shadows were effectively shadowing themselves, so it created the flickering. Increasing the bias pushes the shadows away from the source, preventing self shadowing.
This is by far the best answer! I've long have issues with this problem, but they are now solved! Thank you.
Thanks a ton! Totally forgot about shadow bias, adjusting it to .2 solved my flickering issues on terrain while also letting me use a far clipping plane, perfect!
Answer by darkhog · Sep 22, 2018 at 01:13 PM
Before you do anything anyone else suggested, try changing the Shadow Projection (Under quality settings, do it for every quality level) from close fit to stable fit. It completely fixed the issue for me, while other suggestions merely decreased the rate at which shadows flicker @gregroberts
Using 2019.2.11..."stable fit" appears to already be the default setting. $$anonymous$$ephisTonight's answer with the bias increase definitely decreased the flickering but some still exist.
Answer by jmarcos007 · Jun 10, 2019 at 04:40 AM
I solve my problem just bringing back my gameobject (player) close to word origin (0,0,0). I'm using a huge map (70 Km x 70 Km). Far away from origin, the problem appear. Using near clipping planes solve the problem too, but only at values bigger than 7 (that is not good for my project).
Your answer
Follow this Question
Related Questions
Huge unknown shadow in scene [android] 1 Answer
Odd Portional Screen Flickering 0 Answers
Light creates distortion on mesh? 1 Answer
No shadows. 2 Answers