Search Unity

Clearing Lightmap and Lightprobe cache

Discussion in 'Global Illumination' started by josh_unity344, May 8, 2019.

  1. josh_unity344

    josh_unity344

    Joined:
    Mar 20, 2018
    Posts:
    3
    Hello,

    I have been having some trouble with additive scenes where it seems like the light probes from a previous scene wasn't cleared away properly.

    Is there anyway to, say, uncache the light probes through script? My understanding of the issue might be wrong, so hopefully someone can enlighten me on this issue.

    Thanks
     
  2. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    153
    Hey Josh,

    so just to get this right: You want to clear out the lightprobes during Play without reloading any scene? What exactly was the process with the additive scene that lead to this state?

    LightProbes do not support additive loading, so usually they get overwritten by additive scenes that contain new probes. If they don't, then the last probes stick around. That also happens if you unload the scene that originally contained them, in which case they'll simply be passed on to the remaining scenes.

    Cheers
     
  3. skyrusfxg

    skyrusfxg

    Joined:
    Jan 14, 2016
    Posts:
    127
    @thefranke Hello. We have main scene and in the process of the game we loading/unloading additive scenes with light probes. You said "they'll simply be passed on to the remaining scenes". Does it lead to memory leaks? In bagsnag we started to obtain "Out Of Memory" craches around the time after release with additive scenes. Is there the proper way to clear light probes data when unloading an additive scene?
     
  4. skyrusfxg

    skyrusfxg

    Joined:
    Jan 14, 2016
    Posts:
    127
    Please answer someone?
     
  5. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    Which version of Unity are you using? The information in this thread is a bit old. On newer versions of Unity, the behavior is different. When you switch between single scenes, the previous probe data will get unloaded. When you additively load a scene, if the light probes associated with that scene were not already in memory, they will be loaded into memory. When you unload an additively loaded scene which contains light probes, to my knowledge, the LightProbes object will linger in memory until you either call Resources.UnloadUnusedAssets or switch to a different scene.

    There are some known memory-related issues with light probes on versions prior to the 2022 LTS. If you can, I'd recommend upgrading to that. The system was quite heavily refactored internally around then.
     
  6. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    And in general, light probes do now support additive scene loading. You just need to call LightProbes.Tetrahedralize whenever loading new scenes additively.
     
  7. skyrusfxg

    skyrusfxg

    Joined:
    Jan 14, 2016
    Posts:
    127

    We asre unsing 2021.3.9f1 Unity version