Search Unity

Material, map tiling gives weird shadow artifact

Discussion in 'General Graphics' started by vildauget, Oct 17, 2019.

  1. vildauget

    vildauget

    Joined:
    Mar 10, 2014
    Posts:
    121
    Hi.

    I did my very best to search for this, as it has to be an issue that many people have encountered, but I could not find a single answer, so here we go.

    Issue: On a material, defining a tiling of a normal map larger than 1 makes the max distance the tiling is drawn shorter the larger the tiling is set. Put the material on a large plane or terrain to see the effect.

    I can't help but think this is a long time bug, but please correct me. When I stumbled upon this issue, it got me curious, cause I was annoyed by the same effect in the game "Project: Gorgon". The effect in that game looks like the camera itself is casting a big fat shadow close on the ground, but only in some world zones. I bet they have messed with the tiling on some materials.

    Whatever other settings I've tried, it doesn't help. Is there a setting for how far a normal map should render that can be adjusted? I'm sure the tiling messes up that setting.

    Using Unity 2019.2.8f1
     

    Attached Files:

    • 1-1.jpg
      1-1.jpg
      File size:
      179.1 KB
      Views:
      464
    • 2-2.jpg
      2-2.jpg
      File size:
      151.3 KB
      Views:
      467
    • 4-4.jpg
      4-4.jpg
      File size:
      114.3 KB
      Views:
      489
    • 8-8.jpg
      8-8.jpg
      File size:
      84 KB
      Views:
      471
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    It's caused by mip mapping and texture compression. If you tile a texture so it's really small, it's going to drop to the lower mip levels sooner. For normal maps this means they average down to a single normal direction, basically they become flat. Compression makes this worse as it additionally limits the detail so it doesn't have to get to the smallest mip level before loosing all detail and becoming flat.

    It doesn't help that in the above example the texture you're using is most definitely not a normal map, but it'll be true for any texture.

    The problem can be reduced by enabling anisotropic filtering on the texture, as well as adding a small mip bias (which can be set using the debug inspector).
     
    vildauget likes this.
  3. vildauget

    vildauget

    Joined:
    Mar 10, 2014
    Posts:
    121
    Thank you for clearing that up for me, and proving me wrong on the bug-part. :) Made me learn about mip mapping, anisotropic filtering and mip bias. It was fun to google, and end up reading your older posts on the subjects. Cudos for taking the time to spread your knowledge like that!