Search Unity

Question What's causing my mesh's lightmap UVs to look like this?

Discussion in 'General Graphics' started by Schneider21, May 7, 2021.

  1. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    I have a square mesh I created in Blender that I'm using to create a 3D terrain. Basically, I'm instantiating the mesh for each tile and adjusting each vertex's Y position as needed to create the elevation in the terrain. Despite having "Generate Lightmap UVs" checked on the mesh, shadowed faces are being distorted, like so:
    upload_2021-5-7_16-42-48.png

    The UVs are perfect in Blender. I'm using a vertex-colored shader I made myself, but this happens with the Standard shader as well. Is it because I'm moving the position of the mesh's vertices? Do I need to do something to tell the UVs to update as well?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    This isn't related to UVs or light maps. This is related to shadow maps, which don't use UVs. Look up the term shadow acne.
     
  3. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
  4. Schneider21

    Schneider21

    Joined:
    Feb 6, 2014
    Posts:
    3,512
    @BrandyStarbrite I got distracted by making a separate application to be able to load and edit the map data, and the scope of that spiked quickly enough to irritate me and force me to focus on something else. :p

    But no, I didn't make any progress on figuring out the shadow issue here.
     
    BrandyStarbrite likes this.
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    As mentioned in my previous post, the problem you're seeing is shadow acne. If you look up that term you'll find a lot of resources explaining the problem and possible solutions one could implement. For Unity the solution they use is a combination of vertex normal bias and light direction bias, controlled using the Normal Bias and Bias settings on the light component itself. If you're seeing acne, you may need to increase those values on the light, or you may have bad normals on your mesh.