Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Problems with instantiating baked prefabs

Discussion in 'Global Illumination' started by GSdev, May 8, 2015.

Thread Status:
Not open for further replies.
  1. John-B

    John-B

    Joined:
    Nov 14, 2009
    Posts:
    1,090
    I've found that the type of light doesn't matter, or even if you use different lights for your prefab and main scenes. What seems to be most important is that light map settings are the same in all scenes. However, I did run into a different problem (see here), batches and SetPass calls go up with baked prefabs.
     
    sivrikaya and joshcamas like this.
  2. Kuba

    Kuba

    Unity Technologies

    Joined:
    Jan 13, 2009
    Posts:
    403
    Just changing
    UnityEditor.Lightmapping.Bake()
    to
    UnityEditor.Lightmapping.BakeAsync()
    won't work, as the code below that line will execute immediately, without waiting for the bake to finish.
    Instead, the code below the async call should be moved to a
    Lightmapping.completed
    callback.
     
  3. nbg_yalta

    nbg_yalta

    Joined:
    Oct 3, 2012
    Posts:
    364
    This has to be done automatically by default inside engine, why should I brake my head with custom scripts and settings to get it work? Tell me! This is ridiculous...
     
  4. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    877
    For now, it's just how it is. I understand your frustration, I really do. But let's focus on figuring out how to do this, assuming it's even possible.

    I for one haven't managed to get this working yet
     
  5. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    404
  6. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    877
    Does anyone have a working workflow for 2018.3?
     
  7. joveem_

    joveem_

    Joined:
    Oct 28, 2017
    Posts:
    1

    I do exactly that and the object is as in image 1, but in play mode it looks like in image 2. how do I fix this ??

    this script seems to work perfectly with everyone on the internet, except me: c


    (translated by Google)
    (Unity version 2018.3.11f1)
     

    Attached Files:

  8. Alexaroth

    Alexaroth

    Joined:
    Feb 4, 2019
    Posts:
    18
    Hey guys, trying to figure out what's going on. I am using the GUI editor version with the "png" fix, this is how my prefab looks normally with everything baked:

    upload_2019-6-4_0-29-3.png



    However if I apply the lightmaps in another scene when I drag and drop or when I just instantiate it, I get this:

    upload_2019-6-4_0-27-37.png


    Seems like the mapping is all wrong, the circled area seems to be the actual lightmap (the blue dot is the emisive part of the small lightmap).

    Any ideas what could cause this? Any help would be greatly appreciated!

    Note: Android build, Probuilder objects, lights settings:
    upload_2019-6-4_0-31-20.png
     
    Last edited: Jun 4, 2019
  9. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    877
    Which version of unity are you using?
     
  10. Alexaroth

    Alexaroth

    Joined:
    Feb 4, 2019
    Posts:
    18
    2019.1.3
     
  11. Alexaroth

    Alexaroth

    Joined:
    Feb 4, 2019
    Posts:
    18
    Same here, see above. Found a solution yet?
     
  12. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    214
    Have you exported the probuilderized object as an asset or an obj?
     
  13. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    98
  14. Alexaroth

    Alexaroth

    Joined:
    Feb 4, 2019
    Posts:
    18
  15. Alexaroth

    Alexaroth

    Joined:
    Feb 4, 2019
    Posts:
    18

    upload_2019-6-4_18-45-15.png

    Update: seems Probuilder 'forgets' UVs when part of a prefab, so if I click generate UVs in each individual probuilder mesh inside the prefab, then apply the lightmaps saved from the plugin, then it works.

    Thanks guys for the help, will try to figure out now how to streamline pro-builderizing these prefabs with ease
     
  16. Alexaroth

    Alexaroth

    Joined:
    Feb 4, 2019
    Posts:
    18
    Update: Light probes don't work sadly, as stated above in other posts. I know this is by design, but can you guys maybe reconsider fixing this in future releases or adding native support for it?
     
  17. jirimotejlek

    jirimotejlek

    Joined:
    Nov 8, 2016
    Posts:
    7
    Really glad to see this issue being resolved after 4 years. Ah no, sorry, my mistake. Thank god it's nothing important.
     
    joshcamas likes this.
  18. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    877
    9 pages of people trying to get this working :^) oof
     
  19. Mr-Rouf

    Mr-Rouf

    Joined:
    Mar 1, 2015
    Posts:
    10
    henrimh and LeGiangAnh like this.
  20. LeGiangAnh

    LeGiangAnh

    Joined:
    Nov 10, 2013
    Posts:
    113
    Hi all. We are experiencing the same issue after upgrade the project to LWRP (2018.4). All the backed prefabs show broken lighting (big dark parts).
    From what @Mr-Rouf mentioned, we thought it's LWRP strip some passes of the shaders (but we don't know which ones). We try to use the code below as the hack but I'm not sure it works:

    Code (CSharp):
    1. bool StripUnusedPass(ShaderFeatures features, ShaderSnippetData snippetData)
    2.        {
    3.            if (snippetData.shaderType.ToString() == “Vertex”)
    4.                return false;
    5.            if (snippetData.passType == PassType.Meta)
    6.                return true;
    7.            if (snippetData.passType == PassType.ShadowCaster)
    8.                if (!CoreUtils.HasFlag(features, ShaderFeatures.MainLightShadows) && !CoreUtils.HasFlag(features, ShaderFeatures.AdditionalLightShadows))
    9.                    return true;
    10.            return false;
    11.        }
    If any one has better solution, please share with us.
     
  21. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    877
    Anyone figured out how to get this working? :')
     
  22. ergonomic

    ergonomic

    Joined:
    May 25, 2013
    Posts:
    1


    thank you thank you very very much
     
    Levr01 likes this.
  23. pcg

    pcg

    Joined:
    Nov 7, 2010
    Posts:
    214
    If you are at Unite, can someone please have a chat with the gfx team about this.
    I have work arounds for all the problems but they are an utter ball ache.
    The current changes to separating the lighting which have been started in 2019.3 still not not address the issues with procedural levels.
     
  24. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    388
    Support for nested prefabs is in our backlog and we will revisit this feature once planning allows for it.

    Meanwhile, if you have any issues regarding the subject, please open a separate thread. Thank you.
     
    INedelcu and pcg like this.
Thread Status:
Not open for further replies.