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

Question Dynamically loaded lightmaps won't work with Asset bundles

Discussion in 'Asset Bundles' started by pauldarius98, May 22, 2023.

  1. pauldarius98

    pauldarius98

    Joined:
    Jan 5, 2021
    Posts:
    2
    Hello everyone, We are working on a game for Android using Unity 2022.2 and URP. The game is going to have over 1GB so we are going to use Asset Bundles with PAD (Play asset delivery). Each map has three light scenarios and we have a system for dynamically loading the lightmaps (The lightmaps and render informations are stored and then applied at runtime).

    Everything works well in the editor but the problems appear when I try the build on Android and using asset bundles, the problem is that the shader variant gets stripped (we are using mostly the built-in Lit shader). Also, kepp all variants is not an option as the build size and time will be tremendous.

    Is there any way to make Unity keep the variants needed for the lightmaps? Even some workarounds will be appreciated.
     
  2. AndrewSkow

    AndrewSkow

    Unity Technologies

    Joined:
    Nov 17, 2020
    Posts:
    89
    Hi pauldarius98. I do know that a ShaderVariantCollection can be added to the same AssetBundle as the shader and then any variants specified on it will be included in the build. So it is a way of keeping variants that might otherwise be stripped.

    I'm not certain if it is at all a practical solution for your scenario, as I know the number of variants can be big and you would need to figure them out which ones are active for you in the editor. But i hope this can be helpful.