Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Light Probes not Tetrahedralizing when loading scene in editor

Discussion in 'Global Illumination' started by Gillissie, Mar 1, 2021.

  1. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    294
    This is strange because it doesn't affect all of my scenes, but several of them keep the previous scene's tetrahedralizing (the pink lines) instead of showing its own. When I click the "Edit Probes" button, the pink lines suddenly change to where they're supposed to be. However, I'm also having this issue at runtime.

    Even at runtime, when I call LightProbes.Tetrahedralize() after loading or unloading a scene, with certain scenes, the pink lines still look like they're from the previous scene instead of using the new scene's light probes for the pink lines.

    Example... I load this scene and see the pink lines where they're expected.
    Venue 1 Light Probes.jpg

    Then I load this scene, and despite seeing all of the light probes in this scene, the pink lines are still where they were for the previous scene.
    Venue 2 Probes with Venue 1 Tetras.jpg

    Finally, I click the "Edit Light Probes" button, and suddenly the pink lines appear as expected in this scene.
    Venue 2 After Clicking Edit Probes.jpg
     
  2. thefranke

    thefranke

    Unity Technologies

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

    the pink lines, the tetrahedralization of the probes you're placing in the Editor, are independent of the Lightprobes.Tetrahedralize() call or the baked tetrahedralization of your probes. When you place probes and press Generate Lighting, the tetrahedralization used for lighting is computed for the first time and stored in the LightingData asset.

    The pink lines are an independent tetrahedralization that is computed for visualization whenever probes change and you click the GameObject to visualize them, simply because what you've baked is not necessarily always equal to what you're currently seeing in the Editor. Note that this tetrahedralization is not used to interpolate probes, so at runtime it has no effect.

    However, that visualization should change if you switch the scene, so we're missing a callback somewhere. Can you file a bug for this issue?

    Cheers
     
  3. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    294
    It's very important to note that this doesn't happen on every scene. Some scenes work as expected. I noticed this because at runtime I'm not getting the lighting I'm expecting, depending on the order of scene loading and unloading.

    Also, can you verify if I am doing this the way Unity intends? Here is a use case:
    1. Load main scene (no probes)
    2. Additively load Scene A (with probes) and tetrahedralize. I'm expecting only Scene A's probes to work.
    3. Set the Scene A's root GameObject inactive because I temporarily don't need it. Tetrahedralize, I'm expecting no probes to work.
    4. Additively load Scene B (with probes) and tetrahedralize. I'm expecting only Scene B's probes to work.
    5. Unload Scene B and tetrahedralize. I'm expecting no probes to work.
    6. Activate Scene A's root GameObject and tetrahedralize. I'm expecting only Scene A's probes to work.

    I can file a bug and reference this thread, but I don't know if I can provide a project to reproduce it. My project is way to big to include on a bug report.
     
  4. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    294
    What seems to be happening is:
    1. Load main scene (no probes)
    2. Additively load Scene A (with probes) and tetrahedralize. I'm expecting only Scene A's probes to work.
    3. Set the Scene A's root GameObject inactive because I temporarily don't need it. Tetrahedralize, but despite being inactive, are still included in the probe data.
    4. Additively load Scene B (with probes) and tetrahedralize. I'm expecting only Scene B's probes to work, but Scene A is still working too.
    5. Unload Scene B and tetrahedralize. I'm expecting no probes to work, but Scene A is still working too.
    6. Activate Scene A's root GameObject and tetrahedralize. I'm expecting only Scene A's probes to work. This is indeed the case.

    Was there a change between Unity 2018 and 2020 in that all additively-loaded scene's light probes are now included instead of only the most recently loaded scene's light probes? That's what I have gathered from stuff I've read, and it seems to be the case, but what is throwing me off here is that inactive light probes are still being included in the Tetrahedalize() call.
     
  5. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    294
    Hey @thefranke can you confirm or deny what I wrote above? Are inactive light probes supposed to be included in Tetrahedralize()?
     
  6. thefranke

    thefranke

    Unity Technologies

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

    indeed the old behavior before the introduction of the Tetrahedralize API was that the last scene to be loaded with probes would take priority. However, this was inconsistent with a lot of things, so the current (new) behavior is that all probes are managed when they are loaded, even if the tetrahedralization for them is missing. As soon as you call Tetrahedralize(), all changes since the last good tetrahedralization are computed and included.

    One important note: The LightProbes GameObject components are irrelevant at runtime! Because probes are a baked result, their state is entirely dependent on the scene's loading state. That is, setting a LightProbes GameObject to inactive has no effect on the Tetrahedralize call.

    Cheers
     
    Pema-Malling likes this.
  7. Gillissie

    Gillissie

    Joined:
    May 16, 2011
    Posts:
    294
    Thanks for the reply. This is unexpected, but it's good to have my strange behavior confirmed. Clearly, there is still a lot of room for improvement in this area. Are there still plans to make this more flexible and controllable?
     
  8. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    153
    Yes! One thing that is very high up on the list is the ability to move baked probes at runtime. This is particularly useful in the "moving elevator" scenario, where a baked enclosed room can move around.

    You make a good point on why we need better documentation for the behavior when dealing with multiple scenes and LightProbes. I will make sure this is the next item on the list for docs.
     
  9. Jakub_Machowski

    Jakub_Machowski

    Joined:
    Mar 19, 2013
    Posts:
    637
    Hello so what basically we have to do to reload scene in editor, for now we have to always load scenes i proper order even in editor what is annoying, Is there any tool, or buton to refresh lightprobes in editor too? or we shoudl use the same method as in runtime?