Search Unity

ProBuilder meshes included in lightmap bake with missing UV2 (U2018.3)

Discussion in 'World Building' started by Arkade, Jan 4, 2019.

  1. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Similar to http://www.procore3d.com/forum/topi...included-in-lightmap-bake-due-to-missing-uv2/ I have auto-gen enabled in a new clean project and have tried manual "generate" and restarting Unity. Every time I get:

    Code (csharp):
    1. 5 ProBuilder meshes included in lightmap bake with missing UV2.
    2. You can turn off this warning in Preferences/ProBuilder.
    3. UnityEngine.Debug:LogWarning(Object)
    4. ProBuilder.Core.pb_Log:PrintToConsole(String, LogType) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Log.cs:271)
    5. ProBuilder.Core.pb_Log:DoPrint(String, LogType) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Log.cs:201)
    6. ProBuilder.Core.pb_Log:Warning(String) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Log.cs:166)
    7. ProBuilder.Core.pb_Log:Warning(String, Object[]) (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Classes/ClassesCore/pb_Log.cs:160)
    8. ProBuilder.EditorCore.pb_Lightmapping:OnLightmappingCompleted() (at C:/Users/karlh/procore/probuilder/probuilder2.0/Assets/ProCore/ProBuilder/Editor/EditorCore/pb_Lightmapping.cs:64)
    9. UnityEditor.Lightmapping:Internal_CallCompletedFunctions()
    Right after:

    Code (csharp):
    1. There are 5 objects in the Scene with overlapping UV's. Please see the details list below or use the 'UV Overlap' visualisation mode in the Scene View or Lightmaps in Lighting Settings for more information.
    2.  
    3. - Cube: 424 texels
    4. - Stairs: 335 texels
    5. - Door: 186 texels
    6. - Arch: 173 texels
    7. - Cube: 115 texels
    8.  
    9. Please see this webpage for more information about objects with overlapping UVs:
    10. https://docs.unity3d.com/Manual/Lightmapping-SeamStitching.html
    Screenshot attached. Th for any thoughts.
     

    Attached Files:

  2. gabrielw_unity

    gabrielw_unity

    Unity Technologies

    Joined:
    Feb 19, 2018
    Posts:
    963
    Hi! Tough to say what's going on there- are you using PB 3.0.9? Also, could you double-check that the objects are marked as "Lightmap Static" from the upper-right Static checkbox (I see in the image they are marked in the lower inspector area, but there's a known bug where those can get out of sync).
     
  3. ErikH2000

    ErikH2000

    Joined:
    Apr 30, 2014
    Posts:
    13
    I have this message too. And it's in a big scene with thousands of PB gameobjects, so it's hard for me to go through every single GO and look for issues in inspector settings, particularly when I'm not certain which setting definitely does or does not cause the problem. I've done a spot check of some gameobjects, and they have the lightmap static value set.

    Is there some way for me to learn which specific gameobjects that the warning refers to? I have a little experience writing code against Probuilder API, so I don't mind writing a scanner that iterates over GOs with ProBuilder components if I knew what I was looking for as the cause of the problem.

    My PB version is 4.3.1. The project inherited many assets from some 2018 version of PB, which I upgraded with the Tools -> ProBuilder -> Repair -> Check for Broken References menu option.

    My message below:
    Code (csharp):
    1. 284 ProBuilder meshes included in lightmap bake with missing UV2. Use the Lightmap + options to find missing UV2s.
    2. (You can turn off this warning in Preferences/ProBuilder).
    3. UnityEditor.Lightmapping:Internal_CallBakeCompletedFunctions() (at /Users/builduser/buildslave/unity/build/Editor/Mono/GI/Lightmapping.bindings.cs:308)
    I love seeing PB as one of the official Unity packages now. Happy to watch that journey, as I've enjoyed PB for years.
     
  4. ErikH2000

    ErikH2000

    Joined:
    Apr 30, 2014
    Posts:
    13
    I got deeper into this, looking at the source inside Lightmapping.cs that generates the above warning. Numerous objects in my scene have all of the following true:

    * They are ProBuilder objects and have the ProBuilderMesh component.
    * They have the "Contribute to Global Illumination" inspector property of MeshRenderer component checked.
    * The MeshRenderer.mesh.uv2 is non-null with length of 0.

    So when baking completes, code within Lightmapping.cs will report on all the above objects. Using either the Probuilder "Lightmap UVs" menu option or the inspector "Generate Lightmap UVs" button won't fix this. These operations complete with no reported errors, but I don't see a change to my broken objects.

    I was able to write code that lists all the PB objects that are missing a UV2. I'll post it here in case it helps somebody else. A shortcoming of the code is that it doesn't exclude objects that have the "Contribute to Global Illumination" flag unchecked. So if somebody runs this code in their scene, it may over-report problems. The Lightmapping.cs code seems to use an internal method to check for contributing to GI, which I could not use.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Linq;
    3. using System.Collections.Generic;
    4. using UnityEngine.ProBuilder;
    5. ...
    6. IEnumerable<ProBuilderMesh> allPbObjects = Object.FindObjectsOfType<ProBuilderMesh>().Where(x => !x.HasArrays(MeshArrays.Lightmap);
    7. foreach (ProBuilderMesh pbmesh in allPbObjects) {
    8.   Debug.Log(go.name + "@" + go.transform.localPosition + " is missing a lightmap UV.");
    9. }
    10.  
    When I look at one of the "broke" objects in the Unity inspector, it doesn't show any evidence of a problem. I can preview the realtime lightmap image in the inspector under the Mesh Renderer.

    So I don't know if there is something legit wrong with my objects that I can fix, or if there is some bug outside of my code. I may just disable the warnings for now, but I'm pretty religious about fixing warnings and having things working the way they were intended. Plus, my scene might look a lot nicer with PB objects affecting the lightmap.

    A few other data points - not all PB objects are in this broken state. And one of the PB objects that is in this broken state is newly created with PB 4.3.1 (as opposed to a PB object generated with an older version of PB, which many of mine are).
     
  5. bhoffman67

    bhoffman67

    Joined:
    May 14, 2022
    Posts:
    20
    I'm getting this as well... but beyond just the error, after Generating Lighting, my PB meshes visually disappear, even though they are still listed as game objects within the Project. :(