Search Unity

Lightmapping.Bake without replacing bake

Discussion in 'Global Illumination' started by echo4papa, Sep 1, 2015.

  1. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Hi everyone,

    I've encountered a problem where scenes with lightmaps are baked on one machine, committed to a git repo, and then built on another, the static geometry "breaks". I'm assuming it has to with the re-built static vertex list either not being transferred or being recalculated somehow. Either way the bug has been reported to Unity(I don't have a reference number readily available). While I wait to on the real fix, I think I may have found a workaround.

    To fix the issue I open each scene, click bake, and then I can build and the game is fine. The bakes don't take that long because since nothing has changed there's nothing to re-bake. This process is manual, and I'm looking to automate it.

    I have an editor script that gathers a list of scene paths, opens the scene, calls Lightmapping.Bake() then saves the assets and scene, for each scene then builds the project. This works. I can work with multiple static lightmapped scenes over git and keep static batching turned on.

    However, I think that Lightmapping.Bake is completely re-baking the scenes from scratch and storing new lightmaps. Should this be happening? It's definitely time consuming, but it's not breaking anything(since I have the scenes setup to be baked in their native state).

    Is there a better way to workaround this problem, maybe?

    Thanks!

    EDIT: I've also put this up on Polycount here
     
    Last edited: Sep 1, 2015
  2. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Bump.

    Anyone have any suggestions?
     
  3. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Bump again. Anyone?
     
  4. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    190
    How is your git repo set up? I am using Git for my source control and my repo is relatively large (5+ GB atm) and never had I this issue.
     
  5. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Pretty standard Unity Git setup: visible meta files, for text serialization, standard git ignore file.

    The problem doesn't happen in the editor, only in a build from a machine different from the machine that did the lightmap bakes synced through git.

    "Auto" is unchecked, so the probes, maps and snapshots are all stored and committed to the Git repo.

    I don't know about the 5.0.x series, but this happens in Unity 5.1.x series.
     
  6. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    190
    Are the all different machines use the same version of Unity? I.E. 5.1.3p2
    That's weird, to force scenes to re-sync with bake files, there must be at least some thing to break connection, which doesn't happen even in importing other assets with baked scenes.
     
  7. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Yes, all using the same version.

    If static batching is turned off in player settings the build if fine, but there the obvious implications of no static batching.

    I'm also surprised that calling Lightmapping.Bake() doesn't have the option to check first if there are any changes.
     
  8. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    190
    That's really weird. I've been using static batching since day one, I even stopped using ProBuilder until it solved the issue with static batching.
    You may wanna open a bug report.
     
  9. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    A bug report has been filed arleady. I also just tested and this problem still exists with 5.2.0f3, so no luck there either.

    At this point I'm open to workarounds because I need to have this setup on a build server, but I can't hold the server up with baking lightmaps each time.
     
  10. TanselAltinel

    TanselAltinel

    Joined:
    Jan 7, 2015
    Posts:
    190
    Hey man,
    You may wanna try 5.1.3p3 patch build, I saw this issue:
    • (706367) - Lightmapping: Fixed lightmap UV generation to be identical across platforms.
     
  11. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    EDIT:

    WAIT!

    Yes, this does fix the issue. Tested on the wrong version of Unity on my Mac.
     
    Last edited: Sep 11, 2015
  12. noisyislands

    noisyislands

    Joined:
    Sep 30, 2016
    Posts:
    2
    Hello from 2016. Can you explaine for me how to up server and baking lightmaps each times?