Search Unity

[FIXED] Terrain Shading Issue

Discussion in 'General Discussion' started by SebastianMaj, Nov 19, 2015.

  1. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    I have ran into a weird terrain shading issue and can't figure out how to fix it. It seems to happen only when I turn on terrain casting shadows. Here is a picture of the issue.



    When the player moves the shadows flicker and shake. Thank you for everyones help! :D
     
  2. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    Adjust your cameras rendering distance stuff. (I believe it's the one that's closer to the Camera. change it from 1 or whatever to like 5 and it will help dramatically or completely. Just gotta find the right spot for your game.
     
  3. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    Thanks it worked! :D I adjusted that and for the scene editor I had to click terrain then f.
     
    N1warhead likes this.
  4. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    Is there a way to prevent the shading glitch without changing the minimum clipping distance? I need the clipping distance to be lower because my game is first person and then it clips my gun and hands but when I set it lower the terrain glitches like the picture below.

     
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unity needs something like reversed z or such to help eliminate draw distance issues. It uses a really basic system at the moment, probably the simplest kind.
     
    SebastianMaj likes this.
  6. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    So there is no way of fixing both issues its either one or the other?
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I'm not sure what you mean by "shading glitch". If you mean zfighting, then the only solution that just works is to raise the near and reduce the far in camera clip plane settings.

    Your screenshots were useless for me. If it's shadows then mess with cascades in quality settings.
     
    SebastianMaj likes this.
  8. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    Yes I think it was zfighting since the shadows were black and they were flickering and distorted and it only happens when I lower the near.
     
  9. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    Ok so yes I checked and it is zfighting is there a way I can fix it and at the same time fix my clipping gun issue I tried lowering near and far plane but it still didnt work.
     
  10. SebastianMaj

    SebastianMaj

    Joined:
    Nov 28, 2013
    Posts:
    113
    theANMATOR2b likes this.
  11. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @hippocoder - Is there a way I can code a script to do something like this? I had actually had this idea to fix the Z Fighting. But I wasn't sure if this was possible with just an average normal camera script, wasn't sure if it was a whole built in Unity function (E.G. > Source Code Only Fix).

    Because I do hate Z Fighting, it gets so annoying at times, things get blurred out, etc. So if I can make something like this - just let me know if it's even possible and I will start scouting this and try to make something to fix this.

    @Wolf_Tech - Glad you got it working buddy.
     
    SebastianMaj likes this.
  12. landon912

    landon912

    Joined:
    Nov 8, 2011
    Posts:
    1,579
    You can write your own information into the depth buffer using a shader.
     
  13. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @landon91235 - that's what I was hoping, well Image Effect wise at least.
    Same thing lol.

    So glad to know it is possible then via scripting.