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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Lightmapping bug: Inconsistent mapping between identical scenes

Discussion in 'Editor & General Support' started by kevincfy, Nov 15, 2016.

  1. kevincfy

    kevincfy

    Joined:
    Oct 12, 2012
    Posts:
    16
    Hi there,

    This is driving me crazy. In January we released a project where we'd bake identical scenes with different lighting and then switch between the lightmaps on the fly.

    We're working on an update but now when we bake the lightmaps for our difference scenes the coordinates for each object change. They change when the entire hierarchy is copied from one scene to another and baked AND even when you take one scene, save it as a different name, and then bake.

    Example below is from a very simple test scene that I've baked, saved as a new scene without changing anything, and then baked again. You'll see the cubes in the bottom right are in a different order.

    Firstly is this likely to be fixed (it seems like a pretty major issue) and secondly any workarounds we can use in the meantime?

    scene.PNG lightbake1.PNG lightbake2.PNG
     
  2. kevincfy

    kevincfy

    Joined:
    Oct 12, 2012
    Posts:
    16
    This works in Unity 5.2.4 btw, but we can't use that version.

    Why is lightmapping not the same if geometry is identical? Or indeed different between the same file saved under different names?
     
  3. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    231
    The instances in the scene are hashed with their position and this makes up the instance hash along with other properties of the instances. If the positions are changed even slightly, even though the hierarchy remains the same, the instance hash may change drastically and the order of instances by hash can change.

    Then when the atlassing for the scene is built the input instances are ordered by instance hash, so this accounts for the fact that the atlasses are differently laid out. This does not mean that the baked lighting on the objects is any different, just that the offsets into the lightmaps change. Of course if you have aliasing due to charts not having enough gutter then the aliases will move around depending on the atlassing.

    We are planning to change this to make the order more persistent between bakes and versions (which also alter the instance hash).