Search Unity

New Prefab System and Lightmapping

Discussion in 'Prefabs' started by Laurens-Paladin-Studios, Sep 7, 2018.

  1. Laurens-Paladin-Studios

    Laurens-Paladin-Studios

    Joined:
    Apr 25, 2015
    Posts:
    54
    Hi there Unity,

    Im very excited that in 2018.3 the new prefab system will be available for production! Im already setting up the pipeline for one of our next games to make heavy use of this. One thing that I currently do is assigning a lightmap to the prefabs that we instantiate with our inhouse version of a Prefab Lightmap Data script:

    upload_2018-9-7_13-35-28.png

    My question is, will there be support to direcly bake lightmaps into the new prefab system? Or do we have to bake the prefebs in unique scenes to maintain all the lightmap data? Im thinking of something similar as the new navigation system that is now setup to work with prefabs instead of scenes.

    If we are on this topic anyway, embedding Light probes and Reflection probes would be the next obvious step :)

    Thank you in advance!
    Laurens
     
  2. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    There have been no features implemented that relate to Prefabs with lightmapping. Our focus has been nested Prefabs, Prefab Mode and Prefab Variants. Hopefully your existing script will continue to work or can be made to with a few tweaks.
     
  3. Laurens-Paladin-Studios

    Laurens-Paladin-Studios

    Joined:
    Apr 25, 2015
    Posts:
    54
    Allright! Thanks for letting us know. We can definitely work arround this and the new prefab system is great anyway.
     
  4. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    btw @runevision that original script came from @Joachim_Ante in the official prefab lightmap thread. Probably a good idea to actually build it in, rather than have users in a commercial environment continue to have to navigate a mess of forum posts to discover this "fix".

    At least include this script inside a package manager package for the love of god!
     
    Salvador-Romero likes this.
  5. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    We have much higher standards for what we require of built-in shipped features than for what we can provide in a quick example script. Built-in features require significant time and resources to complete. While it would be great to have lightmap baking into Prefabs be a built-in feature, there are lots of other things it would be great to have as well, and we can't do everything at once. Everything is a prioritization of time and resources. We are basing this prioritization based on many things. What you're all telling us you need the most being a primary one.
     
  6. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    Ok, but if you have such high standards, why is the only "official" solution this example script? It seems a silly thing to not cater for, prefabbed lightmaps. I could maybe understand during 2014 when it originally happened but it is nearly 2019 now, I dont think in the modern world this is acceptable.

    Yes, it would be great to have X and Y and Z feature. But im not saying that. I am saying, you have a lightmapping system since 2014, im saying proc gen is a common thing, and i am saying it makes it difficult to do that properly with lightmapping unless you resort to these as you quite rightly say, low quality hacks.

    So brush it under whatever table, its still coming up to 5 years this hasnt really been dealt with other than the original example lightmap offset script and multiple community additions.

    It seems a sensible thing to bring up now because the current workflow, using that script, in a commercial setting is not very viable when you have a large scale project. And its frustrating to see that despite the many many many posts from many users on it, its never getting dealt with.

    Well, we have a new prefab workflow being authored. I ask you, when if not now is the time?

    Or do procedurally generated games (and sim-vis as we are at work) not deserve lightmapping after 5 years in waiting?
     
  7. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    I said we have high standards for shipped built-in features. This is not a built-in feature, not because it wouldn't be desirable, but because we can't do everything.

    Your feedback that this feature should be prioritized is noted and will be taken into consideration by our product managers along with all the other requests we get.
     
  8. Laurens-Paladin-Studios

    Laurens-Paladin-Studios

    Joined:
    Apr 25, 2015
    Posts:
    54
    I'm glad to tell you that we had to do little to no refactoring of the script to make it work for the new prefab system.

    We now also included into the script being able to bake multiple prefabs in a single scene where it writes away a unique lightmap to a dedicated folder for all the prefabs. It also overwrites the previous lightmaps so we can inherit any texture import settings that we altered (like ASTC compression for mobile, disabling mipmaps etc) .

    So for now we are okay, but as GameDevCouple is saying it would be great feature to be more integrated into the prefab workflow. I can understand though that it ties into many departments and that realtime raytracing is now higher on the list to be tackled to keep up with where the industry is going ;)
     
    MadeFromPolygons and runevision like this.
  9. hwizard

    hwizard

    Joined:
    Jun 30, 2016
    Posts:
    3
    Is there a chance to share this updated script?
     
    Rich_A and MadeFromPolygons like this.
  10. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,277
    It would be very helpful to see an update on this. I've been trying to get lightmap packing to work for a year now, and have never been successful. I'm totally happy if I have to make my own code to pack the lightmaps and stuff, as long as I can figure out how to serialize / deserialize that lightmap data for a prefab...
     
    viknesh2020 likes this.
  11. CyRaid

    CyRaid

    Joined:
    Mar 31, 2015
    Posts:
    134
    I'm gonna +1 this, as I'm working on an infinite runner myself, but baking AO into occlusion maps have been taking me sooooo long. I initially tried to do this with a different layer called "Ambient Occlusion" and hoping I could bake them from the prefabs but it didn't seem that was the case.. Oh well, I'm making due, but just would be nice. :)
     
    joshcamas likes this.
  12. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    378
    Half a year has passed and there is still no solution... It would be better if you added this function instead of these complex new prefabs, seriously, working with this system is infuriating like nothing else when even the order of the hierarchy cannot be changed without opening the prefab, where after each change you have to wait a few seconds. And when you work with a PoorBuilder, even with the allocation of geometry elements, you have to wait for those damned few seconds. This is so disappointing, I'm felt in depression because of all this...
     
    Ruslank100 and sebastiansgames like this.
  13. sebastiansgames

    sebastiansgames

    Joined:
    Mar 25, 2014
    Posts:
    114
    I'd also like to add a feature request for a robust, instantiatable, baked prefab lighting workflow.
     
  14. MAWMatt

    MAWMatt

    Joined:
    Nov 10, 2016
    Posts:
    77
    I have to agree. I can only imagine the prioritization of features is more political than practical. Prefab lightmapping is an obvious and substantial feature to have available to us. It's been many years, and the engine itself still offers no solution. This is highly disappointing. I don't see this feature taking a tremendous amount of time and/or resources...get a small team, and implement it please.

    We shouldn't have to rely on a script from half a decade ago...for a basic, necessary feature like baking lighting for prefabs. I mean really, come on...
     
    Ruslank100, Rich_A, Opeth001 and 4 others like this.
  15. Charlicopter

    Charlicopter

    Joined:
    May 15, 2017
    Posts:
    125
    Another vote for prefab lightmapping & baking. I'm working on an XR application with prefab based map modules (sort of like the block-based map design of 2D platformers like Mario/Celeste and it would be an absolute godsend to be able to offload the GPU without additive sceneloading.
    It's obviously possible right now, but the custom implementations you see out there are far too much of a kludge and don't scale well.

    Edit: What about DOTS? Could this provide something that functionally breaks additive scenes into a more procedural granularity of "additive worlds"?
     
    Last edited: Jan 26, 2020
    TebogoWesi and tonialatalo like this.
  16. ESludden

    ESludden

    Joined:
    Aug 27, 2012
    Posts:
    19
    I would also like to see the incredible lightmapping in Unity be baked into Prefabs, rather than locked into a Scene, for the purposes of instantiating great (proc-gen) looking assets.

    I work at a mid sized company on PC/console games and Unity is our game engine. I've shipped several games using Unity and I often feel that Unity does not fully understand the challenge of making mid to AAA sized games with respect to things like Scene size,Asset Amounts, Perforce Integration and Lightmapping. It can be unresponsive, frustrating and unstable. (Unreal can be similarly sluggish) The fundamental issue is that Games contain ever increasing amounts of 3D Art in Scenes and to compound this, Nested Prefabs are getting huge. 'Baked lightmaps in Prefabs' would be a more adaptive and modular Lighting strategy that could help us bridge the gap between the current need for 'next-gen' graphics and the wider adoption of future technologies like real-time ray tracing.
     
    brinca likes this.
  17. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,980
    Well obviously it wasnt given that its basically 2 years later now and nothing was ever done.

    FYI Its getting really irritating fighting against your ridiculous prioritization of crappy features over things that users actually want.
     
    Salvador-Romero and Rich_A like this.
  18. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    Err, all user requests combined just for Prefab related things could keep our team working for the next 10 years at least. :)

    All work we do is based on requests from users. But I do understand it's frustrating when the things you want are not the ones that get picked. We're also frustrated we don't have much more manpower to address more things faster, but it's how it is.
     
  19. ShadedMelee

    ShadedMelee

    Joined:
    Jan 1, 2019
    Posts:
    1
    +1.
    It is such a basic and important feature that i am shocked that this is still not supported at 2020.
     
  20. Craze74

    Craze74

    Joined:
    Nov 19, 2012
    Posts:
    83
    Hello

    I just came across this post as I have the same issue happening : impossible to bake lights in prefabs.

    I tried the scripts that are there and there, but everytime I have an error and not working, making me think it is not compatible with unity 2020 ?
     
  21. Charlicopter

    Charlicopter

    Joined:
    May 15, 2017
    Posts:
    125
    The best solution I've come up with is to use Additive Scene loading and put the prefabs in those individual scenes. Additive loading comes with its own advantages - I highly recommend checking into it.
     
  22. Rich_A

    Rich_A

    Joined:
    Nov 22, 2016
    Posts:
    338
    Still need a solution, June 2020. I guess we will have to wait for the new enlighten replacement in 2021 before we get anything.
     
    Salvador-Romero likes this.
  23. rtknapp28

    rtknapp28

    Joined:
    Apr 29, 2020
    Posts:
    3
    I'll add my vote for this feature! In the meatine, does anyone know of a 3rd party solution or a way to transfer baked objects between scenes without loosing the lightmaps? Bakery mentions a prefab option in it's documentation but I don't see it anywhere in the editor. From the manual:

    "Bakery Lightmapped Prefab
    This component allows prefabs to store lightmapping metadata. Such prefabs can be then instantiated in any scene, both in editor and at runtime. The component should be added directly to the root object of the prefab. Nested prefabs are not supported. Because the prefab is going to be overwritten after bake (the same way as when the “Apply” button is pressed), it is required that the prefab does not have any unapplied changes (child objects shouldn’t be moved, materials and script parameters should be unchanged, etc). If such changes are detected, an error will be printed in the component UI and no metadata will be saved after bake. If Lightmapped prefab validation warning is enabled, all prefab errors will be also shown in a dialog box before the bake.

    Lightmapped prefabs support all Bakery features, such as LODs, terrains, directional lightmaps, RNM, SH, per-vertex modes and shadowmasks. For shadowmasks to work, you need lights to also be a part of the same prefab."

    https://geom.io/bakery/wiki/index.php?title=Manual
     
    Last edited: Jun 22, 2020
  24. Bentoon

    Bentoon

    Joined:
    Apr 26, 2013
    Posts:
    98
  25. Aurigan

    Aurigan

    Joined:
    Jun 30, 2013
    Posts:
    291
    +1 for this as a Unity supported feature!
     
    viknesh2020 likes this.
  26. viknesh2020

    viknesh2020

    Joined:
    Jul 19, 2016
    Posts:
    52
    Lorrak likes this.
  27. Parixit_Jadeja

    Parixit_Jadeja

    Joined:
    Jul 27, 2017
    Posts:
    8
    I am using this script from Git hub. Script works great in editor but when you build (tested in WebGL and stand-alone) your game, it is not showing lightmaps as intended. Is anyone else facing this issue or any help on this issue will be highly appreciated.

    Thank you!
     
  28. Parixit_Jadeja

    Parixit_Jadeja

    Joined:
    Jul 27, 2017
    Posts:
    8
    Btw, I have also found this page (https://unity.com/how-to/advanced/optimize-lighting-mobile-games) which is more recent. But I still don't understand clearly how this works as there are multiple lightmaps of my baked scene. Do I need a different material instance for each lightmap? If I create different material instance for each lightmap, this method works in build as well.

    I am not sure which one is best to use, a Github script or this method. It will be great if you can put some light on this as well. :)
     
  29. Alex_Heizenrader

    Alex_Heizenrader

    Joined:
    May 16, 2019
    Posts:
    95
    Make sure that shader stripping is set up properly, you can see in the readme in github how to check that in Project Settings>Graphics
     
  30. Nico3D1982

    Nico3D1982

    Joined:
    Aug 14, 2017
    Posts:
    2
    Lorrak and JamesArndt like this.