Search Unity

Where are the UVs of objects baked into a scene lightmap stored?

Discussion in 'Global Illumination' started by FIOHVR-Dev, Sep 25, 2020.

  1. FIOHVR-Dev

    FIOHVR-Dev

    Joined:
    Aug 28, 2019
    Posts:
    2
    After updating Unity from 2019.2.11f to 2020.1.6f we have an issue in many of our scenes where some, but not all, models have incorrect UVs in the scene's baked lightmap. This leads to the models appearing with dark stripes in the scene. The models that have incorrect UVs have their lightmap UVs generated by Unity. Models that have manually created lightmaps are all correct. Here's an example of a model with incorrect UVs:



    Below is an image showing the issue (with a different model than above). On the left side is the 2019 version with correct UVs. On the right is the same model with incorrect UVs in Unity 2020:



    As you can see the UVs themselves appear to be identical but their location and rotation has changed in the 2020 scene lightmap.

    So my questions are:
    • Where does Unity store the UVs of objects baked into the scene lightmap?
    • Would I be able to copy this UV data from the 2019 project into the 2020 project?
    My thoughts and attempted fixes so far:
    • I do not think that this UV data is stored in the GI cache because both editors point to the same directory for their GI cache.
    • I have been unable to find the data in the project root directory, because there are quite a lot of files.
    • I do not think the data is stored in the Assets folder as all the relevant assets regarding this issue (models, scenes, lighting data, and all their meta files) are bit-by-bit identical (comparison done with WinMerge).
    • We know that we could simply rebake all the scenes to fix this issue but due to the large number of scenes and the time it would take to bake them, that is our last resort.
    • Reimporting the models does not do anything.
    • Changing the generated UV parameters to something does change the UVs in the scene lightmap, but changing them back to the correct values does not fix the issue.
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    Maybe something changed that I don’t know but I think you’re out of luck. Generate Lightmap UVs is not really consistent, and as they change the algorithm with each version the UVs change as well. Sometimes even different computers/OSes can result in different UVs.

    The solution is to not rely on this feature and just make your own UVs for lightmaps.

    To answer some of your question though, the UVs are stored in the meshes (added in the library when the import happens).

    I think you can export the imported version of the mesh (which would “bake” the generated UVs into the file) but that would also mean you’d export the tripled version of the mesh, I think, I haven’t tried it. Try Unity’s fbx exporter and see what happens?
     
    Pema-Malling likes this.
  3. FIOHVR-Dev

    FIOHVR-Dev

    Joined:
    Aug 28, 2019
    Posts:
    2
    We've decided to rebake all the scenes.