Search Unity

Bake Lightmaps from batchmode corrupted LightingDataAsset

Discussion in 'Editor & General Support' started by ShuTheWise, Jun 15, 2018.

  1. ShuTheWise

    ShuTheWise

    Joined:
    Dec 23, 2016
    Posts:
    3
    Hi,

    I'm having an issue when baking lightmaps from a static function invoked via command line arguments using Unity batchmode.

    Unity version: 2017.4.5f1, 2017.3.1p1

    Code (CSharp):
    1.  public static void BakeLightMap()
    2.     {
    3.         var config = GetCommandLineArgsDictionary(Environment.GetCommandLineArgs());
    4.         var scenes = config.GetArray<string>("sceneList", ',');
    5.         foreach (var scene in scenes)
    6.         {
    7.             EditorSceneManager.OpenScene(scene);
    8.             Lightmapping.ClearLightingDataAsset();
    9.             Lightmapping.Bake();
    10.             //EditorSceneManager.MarkAllScenesDirty();
    11.             EditorSceneManager.SaveOpenScenes();
    12.         }
    13.  
    14.         AssetDatabase.SaveAssets();
    15.     }
    LightningDataAsset has been build but it seems to be corrupted and obviously the scene is not lit:
    upload_2018-6-15_13-18-20.png

    I have also tried invoking Unity through Windows Task Scheduler (which opens a new window).
    Surprisingly for a set of scenes the last one was properly lit (and LightningDataAsset was not corrupted).

    So I'm thinking I'm doing something wrong with saving scene or assets rather then the batchmode itself.

    Build log fragment:
    Code (TextFile):
    1. Opening scene 'Assets//Scenes//Scene_A.unity'
    2. Load scene 'Assets//Scenes//Scene_A.unity' time: 0.009303 ms
    3. Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
    4. System memory in use before: 40.4 MB.
    5. System memory in use after: 40.6 MB.
    6.  
    7. Unloading 1 unused Assets to reduce memory usage. Loaded Objects now: 2716.
    8. Total: 2.551977 ms (FindLiveObjects: 0.294496 ms CreateObjectMapping: 0.016681 ms MarkObjects: 2.231176 ms  DeleteObjects: 0.009624 ms)
    9.  
    10. Created GICache directory at C:/Users/Admin/AppData/LocalLow/Unity/Caches/GiCache. Took: 0.012s, timestamps: [8.319 - 8.331]
    11. [00:00:00] Enlighten: Precompute started.
    12. [00:00:00] Enlighten: Finished 2 Create Geometry jobs (0.00s execute, 0.00s integrate, 0.02s wallclock)
    13. Launched and connected shader compiler UnityShaderCompiler.exe after 0.02 seconds
    14. [PathTracer] Issuing atlassing job. Atlas hash: bc06a9703e5ae257241f86e6e5e9cb62, width: 1024, height: 1024
    15. Setting up 6 worker threads for Enlighten.
    16.   Thread -> id: e48 -> priority: 1
    17.   Thread -> id: 580 -> priority: 1
    18.   Thread -> id: bd0 -> priority: 1
    19.   Thread -> id: 3f0 -> priority: 1
    20.   Thread -> id: cb0 -> priority: 1
    21.   Thread -> id: 17e0 -> priority: 1
    22. [00:00:00] Enlighten: Finished 1 Layout Systems job (0.00s execute, 0.00s integrate, 0.02s wallclock)
    23. [00:00:00] Enlighten: Finished 1 Create System job (0.00s execute, 0.00s integrate, 0.02s wallclock)
    24. [PathTracer][LP] Issuing deduplication and tetrahedralization job. Combined: 80257199cfa681a16be5e09b3c2208f4, tetrahedralized probes: 00000000000000000000000000000000, non-tetrahedralized probes: 00000000000000000000000000000000, dependencies: 00000000000000000000000000000000
    25. [00:00:00] Enlighten: Finished 1 Create SystemAtlas job (0.00s execute, 0.00s integrate, 0.02s wallclock)
    26. [PathTracer][LP] Integrating deduplicated and tetrahedralized probes for hash 80257199cfa681a16be5e09b3c2208f4.
    27. [00:00:00] Enlighten: Finished 1 Clustering job (0.02s execute, 0.00s integrate, 0.04s wallclock)
    28. [00:00:00] Enlighten: Finished 1 Visibility job (0.02s execute, 0.00s integrate, 0.04s wallclock)
    29. [PathTracer] Common reset.
    30. [PathTracer] Lightmap reset.
    31. [PathTracer][LP] Light probes reset.
    32. [00:00:00] Enlighten: Finished 1 Light Transport job (0.02s execute, 0.00s integrate, 0.04s wallclock)
    33. [PathTracer] building lightmap data asset.
    34. [00:00:00] Enlighten: Finished 1 Tetrahedralize Probes job (0.01s execute, 0.00s integrate, 0.02s wallclock)
    35. [00:00:00] Enlighten: Finished 1 Create ProbeSet job (0.02s execute, 0.00s integrate, 0.04s wallclock)
    36. [00:00:00] Enlighten: Precompute took 0.307370 seconds.
    37. Enlighten scene contents:   2 geometries.   5 instances.   1 systems.   1 probe groups.   0 cube maps. Scene is up-to-date.
    38. [00:00:00] Enlighten: Bake started.
    39. [00:00:00] Enlighten: Finished 1 Bake Runtime job (0.02s execute, 0.00s integrate, 0.03s wallclock)
    40. [00:00:00] Enlighten: Bake took 0.034329 seconds.
    41. -- Creating lighting data asset 'Assets//Scenes//Scene_A/LightingData.asset' --
    42. DisplayProgressbar: Building...
    43. Refreshing native plugins compatible for Editor in 1.76 ms, found 4 plugins.
    44. Preloading 2 native plugins for Editor in 0.07 ms.