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. Dismiss Notice

Need help understanding UV Mapping

Discussion in 'General Graphics' started by Bloogson, May 10, 2017.

  1. Bloogson

    Bloogson

    Joined:
    Jan 27, 2015
    Posts:
    12
    Hello everyone!

    I'm trying to understand some of the details in the process of importing a blender model into Unity

    So, I created a simple plane mesh in Blender. As my first test, I imported the .blend file into Unity, then dropped the prefab into a fresh scene. When I set the mesh as "lightmap static", I get the following two error message:

    "Mesh doesn't have albedo UVs. Please create them in your modelling package."
    "Mesh doesn't have UVs suitable for lightmapping. Consider enabling "Generate Lightmap UVs" in the model importer."

    The second error makes sense to me, but why would I only get the first error after setting the mesh to lightmap static? What does an albedo UV have to do with lightmapping? My understanding was that the UV map simply mapped a 2D texture onto a 3d mesh.

    As a follow up question - the next test was to go into Blender and UV Unwrap my mesh. When I import that .blend file into Unity, then drop the prefab into the scene, and set the mesh as "lightmap static", BOTH error messages disappear. Is Unity automatically using my single UV Map as both the albedo UV and the lightmap UV? If so, what's the purpose of the "Generate Lightmap UV" checkbox in the model import options? And what's the point of the "Lightmap Pack" Unwrap option in Blender?

    Additionally - if Unity can just use a single UV Map additionally as a lightmap UV automatically, what's the point of creating a seperate lightmap UV in the second channel?

    Thanks much.
     
  2. MDK2k

    MDK2k

    Joined:
    Oct 27, 2014
    Posts:
    15
    The basic idea of having separate UV:s for lightmaps is that the regular UV:s for textures might go beyond the 0 to 1 area or have overlapping UV islands on purpose. With lightmaps you want every single part of the surface to have unique UV coordinates or the bake will be wrong and look bad.

    I did a quick test and if you don't use the "Generate Lightmap UVs" option and the model doesn't have a second UV channel then it will just make a copy of the first one. This can be acceptable. In many cases the UV:s for the textures follow the same rules as for lightmaps. For example a small scale prop like a sofa or a table can be mapped in a way that suits both.

    There is one possible problem if the regular maps and the lightmap have drastically different resolutions. In that case you would either have to make a non-optimal UV with larger gaps between UV islands or have some artifacts in the lightmap when 2 UV islands share the same pixel on the lightmap. However if you have good UV tools on your software it doesn't take long to make a separate UV for the lightmap. In Maya I can just make a copy of the first UV channel and then use the layout option to rearrange the UV:s to have bigger gaps with a press of a few buttons. Making the lightmap UV:s yourself gives a lot more control and you can fix possible issues.
     
  3. Bloogson

    Bloogson

    Joined:
    Jan 27, 2015
    Posts:
    12
    Fantastic. Thanks for the thorough answer.