Search Unity

Generate Lightmap UVs for Editor Combined Mesh

Discussion in 'Global Illumination' started by keninger, Sep 13, 2017.

  1. keninger

    keninger

    Joined:
    Mar 29, 2014
    Posts:
    17
    Hi,

    I have combined meshes in the editor, and the plugin itself did not regenerate lightmap uvs like I could if I just imported the mesh. How can I generate the lightmap UVs in this case?
     
    CGDever likes this.
  2. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    Hey! Did you find solution? I have the same problem :(
     
  3. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
  4. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    156
    Thank you! It works!
    But sometimes for some meshes I get such error :

    UnityException: You can generate UVs only for meshes with vertices inited.
    UnityEditor.Unwrapping.GeneratePerTriangleUVImpl (UnityEngine.Mesh src, UnwrapParam settings)
    UnityEditor.Unwrapping.GeneratePerTriangleUV (UnityEngine.Mesh src, UnwrapParam settings) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Unwrapping.bindings.cs:43)
    UnityEditor.Unwrapping.GeneratePerTriangleUV (UnityEngine.Mesh src) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Unwrapping.bindings.cs:37)
    UnityEditor.Unwrapping.GenerateSecondaryUVSet (UnityEngine.Mesh src) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Unwrapping.bindings.cs:52)
    StairRailing_Corrector.meshBacker () (at Assets/Units/Rooms/Part_2/Bridge/Scripts/StairRailing_Corrector.cs:330)
    StairRailing_Corrector.UpdateColliders_And_Mesh () (at Assets/Units/Rooms/Part_2/Bridge/Scripts/StairRailing_Corrector.cs:188)
    Bridge_Corrector_Abstract.SaveMeshAsAsset () (at Assets/Units/Rooms/Part_2/Bridge/Scripts/Abstract/Bridge_Corrector_Abstract.cs:73)
    Bridge_Corrector_Abstract_Editor.DrawButtons () (at Assets/Units/Rooms/Part_2/Bridge/Editor/Scripts/Abstract/Bridge_Corrector_Abstract_Editor.cs:12)
    StairRailing_Corrector_GUI_Editor.OnInspectorGUI () (at Assets/Units/Rooms/Part_2/Bridge/Editor/Scripts/StairRailing_Corrector_GUI_Editor.cs:29)
    UnityEditor.InspectorWindow.DoOnInspectorGUI (Boolean rebuildOptimizedGUIBlock, UnityEditor.Editor editor, Boolean wasVisible, UnityEngine.Rect& contentRect) (at /Users/builduser/buildslave/unity/build/Editor/Mono/Inspector/InspectorWindow.cs:1625)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Do you know the reason???
     
  5. Kuba

    Kuba

    Moderator

    Joined:
    Jan 13, 2009
    Posts:
    416
    This error is thrown when there are no vertices in the mesh (vertex count is 0). Apart from the mesh simply not having that data, one other reason could be that you called
    Mesh.UploadMeshData
    and passed
    true
    into the
    markNoLongerReadable
    parameter, which will deallocate the CPU-side data.
     
  6. Chris_Payne_QS

    Chris_Payne_QS

    Joined:
    Jul 16, 2016
    Posts:
    84
    I'm doing this and it works...but every single UV island is miniscule, about 1 pixel across in the lightmap.
    It's a lowpoly VR game so I am manually combining entire scenes into single figure drawcalls. I suspect this issue is because the resulting combined mesh has a massive bounds compared to any individual UV island? The scene lightmaps fine if I don't generate combined meshes, but I can't copy those UVs unless I can guarantee all the meshes that get combined are using the same lightmap page.
     
  7. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    327