Search Unity

Question Apply baked data at runtime (with lightmaps and Lighting Data Asset)

Discussion in 'Global Illumination' started by fchiarandini, Sep 18, 2020.

  1. fchiarandini

    fchiarandini

    Joined:
    Mar 16, 2018
    Posts:
    5
    Hello,
    my goal: download an AssetBundle containing a static Scene with pre-baked lighting data, spawn the Scene (or eventually the Scene content in a new Scene) and apply the lighting data, all of this at runtime and on builds (Standalone and Android).

    You can stop here, the question is summed-up above, otherwise read through the post for some details on my current knowledge.

    I already searched a lot on the internet but I couldn't find how to achieve this in play mode, sorry if there already is an answer to this somewhere ot the topic has already been discussed.

    In Editor I was able to accomplish my goal manually (without code) by:
    1. Baking the data,
    2. exporting the Unity Package (just for testing purposes, the final version would use AssetBundles) with all the needed assets,
    3. importing the package in an empty project,
    4. assigning the Lighting Data Asset to Lighting settings,
    5. instantiating the Scene objects in the empty Scene,
    6. double-clicking the opened Scene to apply the Lighting Data Asset data.
    Now, while I can do points 1-5 by code with no particular problems (also assign each lightmap with the https://docs.unity3d.com/ScriptReference/LightmapSettings.html class) and while I can also apply the Light Data Asset to the Lighting settings, I cannot then apply the new lighting settings to the Scene.

    Also, I found out that Lighting Data Asset is and editor-only asset and it cannot be applied in builds.

    So, to sum up, my question is: is it possible to apply some light baked data to a Scene at runtime in play mode and on builds?

    Thanks in advance and have a nice day.
     
  2. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328