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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Lightmap UV Generator placing UVs to dense = UV Overlapping

Discussion in 'Global Illumination' started by Jan_Hasse, Dec 15, 2022.

  1. Jan_Hasse

    Jan_Hasse

    Joined:
    Sep 11, 2017
    Posts:
    21
    Hello everyone,

    i am using 2021.3.12 and i am running into an issue for a while, which i don't understand.

    When baking the light in my scene (see settings below) i get some uv overlapping. Most of them are small Objects with a high amount of generated lightmap uv shells.

    I was looking for a solution to fix this and saw a thread about the "Merging Method: Calculation" so i set the import settings for this to:

    upload_2022-12-15_15-44-34.png

    Now i still have the problem that my object (in this case the Crystal) has a completly different resolution in the lightmap, even if i have set "Scale in Lightmap" to 1.

    Btw: the Crystal is scaled to 0.34 here:




    Accordingly i get UV-Overlaps in the Lightmap:



    Am i doing something fundamental wrong?


    Lightmap Settings:
     
  2. DavidLlewelyn

    DavidLlewelyn

    Unity Technologies

    Joined:
    Aug 14, 2012
    Posts:
    29
    The Calculate Margin method is a contract essentially asking the user to specify the "worst case" usage of that particular Mesh. In your example, if you are scaling the object to 0.34 using the object's Transform Scale, then this should be the number that you enter into Lightmap UV Settings in the Mesh Importer. In your example:

    - Margin Method: Calculate
    - Min Lightmap Resolution: 20
    - Min Object Scale: 0.34

    This approach presumes that the Scale in Lightmap property of instanced MeshRenderers remains at 1, or is greater than 1.

    If you were using Scale in Lightmap on the MeshRenderer to further reduce the size of the resulting UVs in the atlas, this would shrink the padding to the point where texels potentially overlap again. Try to keep Scale in Lightmap =>1 when using Calculate Margin.
     
  3. Jan_Hasse

    Jan_Hasse

    Joined:
    Sep 11, 2017
    Posts:
    21
    Hello David, thank you for your answer.

    This means that i have to predict the future a little how small i will use this asset?
    I've read that people recommend using the unity generate uv function only for early progression or emergency :D
    Would you recommend doing a lightmap uv directly in the 3D-Software (i do it in rizom).

    If yes, do you have a best practice how to do so? Because i think i also have to predict the future how big my Lightmap UVs for the mesh will be in the project.

    Thank you,
    Jan
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,063