Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Flickering shadow bug, will it get fixed in Unity 5?

Discussion in 'Editor & General Support' started by ChrisV, Jul 24, 2014.

  1. ChrisV

    ChrisV

    Joined:
    Mar 3, 2013
    Posts:
    57
    Hello all,

    I know this has been discussed before, but i doubt it ever really got fixed. I experienced this on my previous machine (Windows 7, ATI Radeon HD 6670), and i'm now also experiencing it on my new PC (Windows 8.1, GForce GTX 760 (192 bit)), and it's really annoying as hell. :(

    Whenever i set the near value (clipping planes on cam) to the lowest (0.01), then for some strange reason, i get flickering shadows on terrain (and also on models, i think) whenever i move the cam (in editor, or ingame). So, what i usually do, is set it higher (to a value of 0.2 or such), but then it happens that you get 'cut off' vegetation in front of the cam (third person mode) when the cam is close to the ground. Really not nice to see.

    I've tried various things to get rid of the flickering shadows, while still having a low value on the clipping planes (because it's not nice to see through walls, or get cut off vegetation or whatever), but none of it really worked. :(

    Because of this, we (Rimfrost Software) had to change gameplay mode to first person, instead of third, for our adventure/puzzle/action game, similar to Tomb Raider/Uncharted.

    I really hope this gets solved once and for all in upcoming Unity 5.

    Has anyone else experienced this, and got it solved somehow? If so, please do share your experiences. Plus, it would help to notifiy the Unity team of the 'bug', so they can get it fixed. ;)

    Cheers!
     
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,679
    Did you try reducing the far value as well, it is asking a lot of a 32 bit zbuffer to handle 0.01 to 1000 without issues. You can always change the values based on how close the camera is to the ground.
     
  3. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    As @SpookyCat mentioned, this is to be expected. This can't be solved by Unity, simply because it is impossible. You have to make sure the camera is not intersecting with anything.
     
  4. 0tacun

    0tacun

    Joined:
    Jun 23, 2013
    Posts:
    245
  5. ChrisV

    ChrisV

    Joined:
    Mar 3, 2013
    Posts:
    57
    Thanks for the responses, guys! :)

    'You can always change the values based on how close the camera is to the ground.'

    'This can't be solved by Unity, simply because it is impossible. You have to make sure the camera is not intersecting with anything.'
    We already use raycasting to make sure the cam doesn't go inside walls or through terrain. But, for vegetation painted on the terrain...is that even possible to check using raycasting?

    The actual problem we're having, is not really the cam/obstacle avoidance, but rather the flickering shadows (actually, i'm not even sure the black flickering are shadows) that you get when the near clipping value is lower than 0.2.

    The effect we're getting is very similar to what this guy shows in his vid:

     
  6. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Well if you think there is a bug somewhere then by now you have probably already submitted a bug report with screenshots/video and other details included to Unity so its even on the fix list?

    :rolleyes:
     
  7. HolBol

    HolBol

    Joined:
    Feb 9, 2010
    Posts:
    2,888
    That's called z-fighting. Watch that you don't have 2 mesh planes on the same normal too close to each other. Either move them apart (best option) or compromise and change the near and far clip panes of your camera.
     
    karl_jones likes this.
  8. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    The flickering you get with values below 0.2 is due to floating point imprecision, caused by your CPU and GPU. This is caused by the hardware.
    You may lower the far clipping plane to reduce it. You may also use several cameras. The far clipping plane would need to meet the near clipping plane. The make sure the far away camera is rendered before the closer one, but you will likely get trouble with transparent materials like that.
    You need either that kind of camera setup, or use better obstacle avoidance for your camera, such that it doesn't matter anymore.
     
  9. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,169
    You need to push the near plane out as far as you can. This is the single most important factor in determining the precision of the zbuffer. Then, set the shadow bias (on the light) as high as possible. Certainly not less than the 0.05 that is the default.
     
  10. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,069
    Bump
     
  11. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It may make sense if you could share a little information about your actual problem along with your current settings, like near and far clip planes of the camera and the shadow settings you are using.
     
    karl_jones likes this.
  12. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
    This is a great thread folks, but it may be better suited to the General Support section of the forums :D /movingthread
     
  13. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,169
    I think I already answered what to do back in 2014. It's just a few messages up.
     
  14. dudester

    dudester

    Joined:
    Oct 25, 2014
    Posts:
    371
    Also just to add pushing the far clip plane further out helped me as well as setting the near clip to 0.1f , my current settings are near 0.1f , far 15000 and so far no flickering shadows at all my lights normal and bias can be set to what ever i want .
     
  15. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,069
    It's only solve when I put near clip on 0.9! I don't like that I need a near clip of 0.1
     
  16. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    How about sharing all your relevant settings?
    Keep in mind that this is a precision issue of GPUs and not really a Unity issue. There is not much Unity can do about it, but you need to find settings that work for you. And there are also some tricks that can be used, like using multiple cameras. But you need to share the relevant information, such that people from this forum can help you.
     
  17. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,169
    A Zbuffer is not linear-It has much more resolution up close than it does far away. Move the near plane it as far out as you can for your game. For the far plane, move it IN as far as you can for your game, though this won't have as much effect unless you move it a lot. this will give your zbuffer the most precision. If you are still having issues, you can adjust the shadow bias.
     
  18. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,727
    This is one of the reasons I've decided to abandon Deferred.
    1. Shadow flickering
    2. Alot of Post effects don't work in deferred
    3. No HW AA
    4. Unity problem with multiple cameras and Post-effects in deferred rendering. Some cameras need to be forced to operate in Forward.
    5. Hard to manage the 4 light culling limitation

    I just find that with light baking, forward is just the best approach for me