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.

Reusing beast generated lightmap in another scene?

Discussion in 'Editor & General Support' started by kurylo3d, Dec 16, 2010.

  1. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    Is there a way to use a lightmapped room done by beast in another scene without having to regenerate the lightmap? Also how would i use this on another computer with an installation of unity? I understand I would use meta data somehow.. but i dont know the exact process, since every time i switch computers it reexports/imports inside unity at the very start the first time i copy the files over. Im afraid it might try to regenerate the uvs so they are different.
     
    Last edited: Dec 16, 2010
  2. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    anyone have an answer about this?
     
  3. robert

    robert

    Unity Technologies

    Joined:
    Dec 21, 2008
    Posts:
    265
    I thought we talked about this already ;)

    There's no magic in there and there's no hidden data (so there aren't any meta data you need to worry about). Everything is in plain sight.

    Say you have a scene into which you drop a couple of meshes, setup the lights and bake it.

    Now you want to use those meshes in a new scene with the same lightmaps.

    If for some reason you don't want to use prefabs, you can do it like this:
    1. In the new scene, in the Maps pane of the Lightmapping window, assign the lightmaps you need to the same slots they had in the orginal scene (you can assign to different slots, but then you will have to modify the indices on the objects accordingly).
    2. Drop the meshes into the scene.
    3. Using a script (or manually, if you don't have many meshes) assign the same atlas info (i.e. lightmap index, tiling and offset - 5 values), which you see in the original scene in the Object pane of the Lightmapping window, to all the meshes in the new scene.
    4. Since meshes always get unwrapped the exact same way (this is important, we guarantee that) and you just copied all the atlasing info, all the objects will have correct lightmap UVs and will display them correctly.

    If you're using Single Lightmaps, then that's it.

    If you're using Dual Lightmaps, you need to setup one more thing, i.e. the lights that make up for the realtime lighting part of the dual lightmaps - the Auto lights. To make it work you can start by positioning the lights in the same places as they were in the original scene. Then hit bake (you don't have to bake any meshes). This is needed so that the lights 'know' they have been baked already and you won't get double lighting past the shadow distance (if you skip this step, you will get lighting from the lightmap + lighting from the light past the shadow distance).

    You can do all this manually in a couple of minutes, but if you plan to do it more than once or you have a big scene, I suggest you have your programmer whip you up a script to do that automatically.
     
  4. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    How would you accomplish this using a prefab... say its a prefab that is a bunch of meshes with a few lights... and it being baked.

    Last time i tried doing a prefab... it basically ruined BOTH scenes. With unity giving me some strange error about not being able to regenerate lightmaps ever again. For the time being have just been using save as to get the same room into another scene.
     
  5. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,496
    Yeah, it tries to regenerate uvs. But if they are different you know who to poke with bug case ;-)
     
  6. kurylo3d

    kurylo3d

    Joined:
    Nov 7, 2009
    Posts:
    1,123
    ill have to do some more experimenting to narrow down each and every problem and how i came across it... honestly though.. right now i just dont have time... Unity should be paying me for bug testing. :)
     
    grossimatte likes this.
  7. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,496
    hehe, as for different uvs - just drop the model 8)
    as for bug testing... Noone payed me for that, only for fixing - so i'm in the same boat ;-)
     
  8. MattFS

    MattFS

    Joined:
    Jul 14, 2009
    Posts:
    219
    how would you go about just baking prefabs - and using something like the legacy lightmap shader? (or a custom one)

    Beast can get some awesome results, so what if you wanted to bake some general AO or skylight into all your prefabs, but that was it... you then wanted to use the prefabs in other scenes and not have to bake the scene. For example, you be wanting to proceedurally lay down lots of props - but you want to have lightmaps for them all.

    The typical way to do this would be to do the entire lightmap process outside of Unity - but the question is can it be done in Unity, seeing as there's a pretty nice baking tool there? :)
     
  9. merlin981

    merlin981

    Joined:
    Apr 16, 2012
    Posts:
    305
unityunity