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.

Question How does Unity calculate the tiling values for objects in a Lightmap?

Discussion in 'Global Illumination' started by SticklandPWorm, Nov 15, 2022.

  1. SticklandPWorm

    SticklandPWorm

    Joined:
    Apr 20, 2017
    Posts:
    17
    How does Unity calculate the tiling values for objects in a Lightmap? I want to have a consistent lightmap density across all objects in the scene. I've found that if I add objects of different sizes but identical UV layouts Unity will calculate the tiling values correctly and I can leave the Scale in Lightmap value at 1. However if I add objects of the same size but with different UV layouts (though with the uv's still representing the same amount of surface area) I will need to adjust the Scale in Lightmap value by eye to get the same density. I wish to automate setting the Scale in Lightmap value to achieve the same density across the whole scene but can not work out what factors Unity is using to set it's tiling values relative to the Scale in Lightmap value.

    The image shows 5 boxes, 4 of which have similar uv layouts which Unity has set their tiling values to give a consistent density at a Scale in Lightmap value of 1. The circled box has a notably different layout which needs it's Scale in Lightmap set to 1.14 to match. Other objects will come out with more extreme differences but I have provided a simple cube example here to not overly complicate the question.

    Thank you

    Unity Lightmapping Scale example.JPG
     
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,054
    By default, Unity determines how to pack lightmap UVs based on their bounding box. If you'd want to ensure consistency between your lightmap UVs, you'd need to ensure that bounding box surrounding your UVs match. This might be a tedious process...
     
  3. SticklandPWorm

    SticklandPWorm

    Joined:
    Apr 20, 2017
    Posts:
    17
    If I knew how the bounding box of the UV's would effect the packing would I not be able to calculate the the Scale in Lightmap setting to offset this though? So rather than make sure I had a consistent bounding box I'd just apply the required scaling to compensate?