Hello, I’ve been looking around for a while now, but I can’t find a solution for this. So pretty much, when I set the near clipping pane to a low value like 0.1, the shadows start flickering like crazy, it’s really annoying and I’m not too sure what’s going on, I need the near clip pane to be really low because my camera is designed to get closer to the character in tight spaces, and with higher near clip pane values, you start seeing through walls and stuff. I have found many threads about this but never a proper solution, does anyone have any ideas? I’m using Unity 5.0.
Alternatively, you can lower the far clipping plane. The reason for this is that Unity calculates the depth texture of the camera which is used for the shadow calculation. The more distance you have between the the near and far clip planes of the camera, the more distance has to be covered by the depth texture and the less precise it gets. At a certain point, it gets noticeable and you see the actual flickering.
There are a lot of ways to reduce the flickering, but there is no solution that works in all the cases. You have the bias values that you can tweak in the directional lights. Check the documentation of those, you can find significant improvements there. Another possibility is to use two cameras, one for the near range and one for the far range. You first render the far away objects e.g. between 300 and 2000 and then you render the closer objects between 0.1 and 300. You need to set up everything properly in order to get it working, but it is troublesome for transparent shaders.
The solution is usually a compromise and depends heavily on your actual application.
Thanks for the informative reply, sadly, lowering the far clip pane from 10K to 1K didn’t help at all, playing with the bias sort of helped, but created more problems, setting my near clip pane to 0.3 almost fixes it, but i need it to be 0.01. Maybe my terrain is just too big, I’ll post again if I find a solution, but for now thanks for the reply! ![]()
Finally I’ve found the closest thing to a solution I could. And to be honest, it’s mostly just tweaking values. Here’s what I did:
-Made the character controller radius slightly larger so you wouldn’t have to get too close to walls, thus limiting the amount of culling
-Made my camera get as close to the player as possible (almost 0 distance), through raycasting, in addition it gains height the closer it gets, so you’d be looking down on the character.
My camera’s target is inside the character collider, so the target is never touching anything.
So since my character doesn’t actually touch anything, and my camera is getting even closer to my target now, I have much more room for higher near clip panes.
Figured I’d post an update in case anyone has the same problem, if more clarification is needed, feel free to ask ![]()