Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Generated lightmaps are not working after WebGL build

Discussion in 'Unity Forma' started by SachinJawade, Apr 25, 2022.

  1. SachinJawade

    SachinJawade

    Joined:
    Nov 8, 2021
    Posts:
    2
    Hello,

    We are working on Unity Forma.
    We have added some area-baked lights inside the model and generated the lights and the lightmaps. The objects of a model are set to static and they contribute to the GI. We have enabled contribute global illumination and generated the lights using multiple combinations.

    The scene contains, 1. a plane generated using the 3D object which is outside of the configurator and 2.a model which is in configurator placed using forma "add product".

    The generated lightmaps are available for a plane and not for a model after WebGL build.

    The generated lighting and lightmaps work fine in scene mode as well as in game mode as per expectations. But when we try to build using the WebGL platform the lightmaps created for the model are not available. We need to recreate the lightmaps for the "model" while the lightmap for "plane" still available after WebGL build.

    Also, we have observed that the baked lightmaps are working fine on the WebGL platform for the unity projects without forma.
    For unity forma, the baked lightmaps are not working on the WebGL platform, and also, they are lost from the instances once the build is completed.

    Is it an expected scenario?

    If it is an expected scenario of unity forma, then how can we resolve this.

    Please refer to attached screenshots in scene mode, game mode and on WebGL.
    Scene mode.PNG Game mode.PNG WebGL build.PNG

    Thanks!
     
    Last edited: Apr 25, 2022
  2. Enrickl

    Enrickl

    Unity Technologies

    Joined:
    Mar 11, 2020
    Posts:
    8
    Hi @SachinJawade,

    Lightmaps are currently not supported for Forma products (environments should work fine). Switching the product configuration at runtime can give you strange results since the data can only be baked on your current configuration.

    Here is a workaround
    • Download the PrefabLightmapData.cs script from https://github.com/Ayfel/PrefabLightmapping
    • Add the new component on the product's modelSet GameObject.
    • Once you are ready to bake, select Assets -> Bake Prefabs Lightmaps (this way, the data will be saved on the components directly)
    • Save the product using the Gear Icon -> Save Product
    • Build and launch
    Lightmap data is saved outside of prefab since Unity 5. Here is an interesting thread about this: https://forum.unity.com/threads/baked-lighting-on-prefabs-dynamically-generated-level.930534/
     

    Attached Files:

    SachinJawade likes this.
  3. SachinJawade

    SachinJawade

    Joined:
    Nov 8, 2021
    Posts:
    2
    Hi Enrickl,
    Using a script prefab lightmap data, the lightmaps are working fine after build.
    Thanks for input.
     
    Enrickl likes this.