Search Unity

What is the expected multi-scene lighting pipeline? Because it appears to be broken...

Discussion in 'Global Illumination' started by hypnoslave, Sep 5, 2018.

  1. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    I'm a long time Unity fan, so if this post sounds salty, no disrespect was intended...

    It seems to me that the multi-scene lighting pipeline is currently broken and making an additive-loading game in Unity is either profoundly limited or impossible because of the ongoing bug where light probes are used from the most recently loaded scene, which makes separate baking impossible.

    What is the expected multi-scene lighting process here? Loading my entire game together for lightmapping theoretically solves the light probe issue, but introduces other problems. Even if I can load my entire game at once to generate mapping, I would need to create a single set of lightmapping options that work across my whole game. that means:
    1. No ambient light can be used anywhere if I want even a single dark area, which means I need a complex material solution for ambient lighting, including a solution for objects traveling between areas.
    2. Areas with Unrealistic lighting (such as a portal to another dimension where there are two suns) is simply impossible without a loading screen.
    3. Cheating by having sections overlap slightly is impossible - all scenes must be perfectly laid out in rational physical space so they do not block lighting from one another.

    I hope someone can tell me that I'm completely flying off the handle here and I'm just a dummy?

    I have no doubt that Graphics programming is insanely difficult and well over my head... but unless I'm missing something, making this sort of game simply isn't feesible in Unity, and as a consumer, if I had known how broken this was I'd have considered Unreal.

    Is there an ETA on the light probes issue, by any chance? I'd rather not re-build everything I have an another engine, if I can avoid that.
     
  2. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,788
    Try to ask bakery's creator
     
  3. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Bakery?

    I'm out of the loop, apparently.
     
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    4,788
    https://forum.unity.com/threads/bakery-gpu-lightmapper-v1-2-released.536008/
    I mean you might have faster answer and turn around with bakery than anything with unity team, because he is on a much smaller target than them. He was willing to listen about interval mapping which an obscure lightmap technique, so it will certainly inform you of the feasability of your issues. Also it's a damn fast and efficient lightmapper, like 10x faster at worst.
     
  5. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Huh. No kidding. that's very interesting. Thanks very much neoshaman, I'll take a good look into this and see if it doesn't alleviate my woes.
     
  6. jStinson

    jStinson

    Joined:
    May 9, 2017
    Posts:
    20
  7. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Thanks very much! Unfortunately that script solution does not work. it's possible that it's broken as a result of later unity patches, but who knows. I took some time, analysed it, understood it, and ran it, and it does what it purports to do (almost) but the probes that it ultimately creates are not correct - the data fails to copy to them properly. most of them are black, for example.

    I'm going to investigate this new light mapper, and in the absence of that, I'll simply see if I can use Unity's solution - to just bake all of my scenes together. I think I can prooooobaabbbllyyy get away with all scenes having a similar lighting set up. I'll just have to be super sneaky and put in some effort.
     
  8. danielrugu

    danielrugu

    Joined:
    Jul 24, 2016
    Posts:
    14
    Did you solve it yet?
     
  9. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Nope.

    I've been onto other things. Hopefully unity can fix this (they are aware of the problem) but it's possible that I'll just have to load all the scenes together and bake. I've altered my design slightly and my entire environment should all be able to be baked together, as it makes euclidean sense.

    God help anyone who's making a non-euclidean game who needs to bake lightmaps.
     
  10. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    392
    Well I guess there still isn't a solution. I'm using Unity 2017.4.24f and still seeing this as an issue.

    All of my scenes must be baked separately as they are much to large to fit in memory at the same time. I'll have to make in-between scenes (with very small and very little meshes), that have no light probes...so there are only main large scene light probes to go off of.

    Not ideal, but that's the only "solution" I could come up with.
     
  11. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Hey, that's a very creative solution. good idea!
    Still sucks though, really, as it will only work with some pretty specific design restrictions.

    Honestly, I'm not sure why this isn't higher priority (or perhaps it is and it's just a really difficult problem). It's not like seamless open world games aren't insanely popular. It's not like Unity didn't revamp their entire scene management system to allow for seamless multi-scene loading/uloading. This bug basically F***s that all completely up.

    Very strange.
     
  12. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    392
    I totally agree. I wish there were at least guidance or best practices to get around these kind of issues. It seems as though more advanced issues gets unresolved.
     
  13. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Yeah, I know the feeling. Well it could very well be that they're absolutely gargantuan ice-berg problems, for all we know, so.... meh.

    Honestly, this isn't the first massive issue that I've navigated around and it won't be the last. it would have been nice to get a response on this particular issue but... I guess that's game development when you're using someone else's engine.
     
  14. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    93
    Hello everyone,

    I can confirm that there is a solution to the Light Probe problem with additive scenes. In the latest 2019.3 beta, probesets from additively loaded scenes will be merged together automatically. You will however need to call an API function to finalize the merge. This call - Lightmapping.Tetrahedralize() - will update the tetrahedralization structure you see when you click on a probeset (the lines connecting the probes) to include the newly added probes. Because re-tetrahedralizing probes is quite heavy work, you want to reduce calls to this function to a minimum.

    E.g. let's assume you build a Spacehulk like game where characters move along corridors, and each corridor segment is a scene. You load each neighboring/connecting segment to the current corridor because you don't know which way the characters will move next, i.e. each time characters move into a corridor segment, multiple new scenes are additvely loaded rather than just one. In cases like these, first load all scenes, then when everything is done call Lightmapping.Tetrahedralize().

    Cheers
     
    FiveFingerStudios likes this.
  15. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Fantastic!!! Thanks very much for the tip, thefranke!

    You guys have saved me quite a lot of forehead rubbing and eye squinting, etc. This is great news for my forehead and others.

    I'll give this a try quite soon.
     
    thefranke likes this.
  16. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    219
    Am I correct in assuming that the baked probe data from an additive scene cannot be moved to a new location and then retetrahedralized ?

    What I want to do is bake a series of rooms in their own scene all at the same location. Then load the additive scenes and move the rooms in to their correct position, retaining the baked light probe data. Is this possible?
     
  17. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Quick update for anyone who finds this thread. "Lightmapping.Tetrahedralize" is a UnityEditor function, so it can't be used at runtime. I think what thefranke probably meant was LightProbes.Tetrahedralize & TetrahedralizeAsync. I hope. I'm about to find out :S

    pcg - responding because nobody else has -- Did you try this? it's possible that once you load a scene, and then move it (and thereby move the lightprobe objects in that scene), Tetrahedralize might update with the new positions. Sounds like we can call Tetrahedralize whenever we damn-well please.
     
  18. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    392
    I came up with a solution for baking light probes across scenes loaded async….I tested it in Unity 2017.4.24f.

    Here is a video of it working.
     
  19. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    219
    Hey @hypnoslave thanks for the reply.

    Just tested on 2019.3.0f3 and I can confirm that you CANNOT move the light probe group and call Tetrahedralize.
    I'm assuming the baked probe data is actually stored in the LightingData.asset for the scene and that the Light Probe Group is only used for baking.

    Sadly this means Tetrahedralize doesnt address the problem for me in that I don't know the location the baked objects will finally end up as its a procedural level using prefabs.

    EDIT: I havent tried modifying the Light Probe position yet, I moved the light probe group instead, so perhaps that might work. I'll try that tomorrow and update.

    EDIT: Doh, position data is read only :(
     
    Last edited: Dec 14, 2019
  20. hypnoslave

    hypnoslave

    Joined:
    Sep 8, 2009
    Posts:
    286
    Five Finger Studios - that's fantastic! Congrats on getting it working. I'm super curious as to what your solution was. In terms of your question about what to do with it -- by all means if you can, capitalize, and an asset might be good for you guys. However it sounds like this issue may be addressed more-or-less in the newer versions of unity, so it might not be worth your time. I won't ask you to fork over your trade secrets but if you do, let me know, because I'm really quite curious indeed.

    PCG - I suppose that makes sense - the position data is baked and saved to a file, and then can be read from and tetrahedrawhatsitalized at runtime. Too bad a transformation can't be applied to the loaded data though. Don't think I've got an idea for you I'm afraid. I can imagine a few reasons why someone would want to do what you're doing - like... procedurally generated dungeons, for example. Can you change your design to allow for pre-placed configurations?
     
    FiveFingerStudios likes this.
  21. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    219
    I have a solution which is to place all the prefabs in a single scene, bake it and then remove all the prefabs and just load the scene for the LightingData asset. There is a probe anchor field on the renderer component that can be used to get light probe data from another transform and I use this.
    It just means I have to create a separate game object for every item that needs to use light probes, position it in the correct place for the light probe data and if the object needs to move I have reflect this in the probe reference object. It all seems like overkill and I was hoping to ditch it if I could move the scene probe data but I guess it stays.
     
  22. FiveFingerStudios

    FiveFingerStudios

    Joined:
    Apr 22, 2016
    Posts:
    392
    Thanks!

    I'll talk it over with my partner to see what we should do. At the very least I should be able to write something up and provide some code to anyone that wants it.
     
unityunity