Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Manually applied lightmaps not working in build since upgrading to Alpha

Discussion in '2020.2 Beta' started by b4gn0, May 14, 2020.

  1. b4gn0

    b4gn0

    Joined:
    Jul 26, 2019
    Posts:
    119
    Hello,

    Our game at runtime gets a lightmap texture array from a prefab, add them to the scene LightmapSettings, and assign the updated lightmapIndex to the renderers.

    Code (CSharp):
    1.  
    2. // Update scene available lightmaps
    3. LightmapSettings.lightmaps = newLightmapArray;
    4.  
    5. // (Inside a loop) Assign index to renderer
    6. info.renderer.lightmapIndex = lightmapOffsetIndex[info.lightmapIndex];
    7.  
    We initially had a problem with it due to Unity stripping unused UV channels ("Optimize Mesh Data" options under the "Player" settings), but it is not the case anymore.

    This has been working fine in the 2019.3 version, both in editor and build.
    Since updating to the alpha version, this works only in the editor windows, and does not work in build.
    upload_2020-5-14_10-44-8.png

    I added logging and can confirm that both the textures and the meshes are the same as when in the editor.
    I tried disabling texture mipmaps and texture streaming, with no effect.

    I read from the release notes that a lot of work has been done in global illumination, maybe there are some additional steps we must do to apply the new lightmaps at runtime?

    Thank you
     
  2. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    194
    I ran into a similar problem, I believe it was fixed after passing an empty texture to lightmapDir.
     
  3. TheZombieKiller

    TheZombieKiller

    Joined:
    Feb 8, 2013
    Posts:
    266
    I had this issue in a 2019 version of Unity, if I'm remembering correctly. The solution was to go into Project Settings -> Graphics and set "Lightmap Modes" to "Custom" with all boxes ticked.
     
    tahercal and b4gn0 like this.
  4. b4gn0

    b4gn0

    Joined:
    Jul 26, 2019
    Posts:
    119
    That was it!
    It was set to "Automatic" and I think Unity 2020 checks differently what kind of lightmap you use in your project.

    Thank you.