Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Lightmapping and Static Batching: Odd Behavior

Discussion in 'Global Illumination' started by Exguardi, Feb 20, 2016.

  1. Exguardi

    Exguardi

    Joined:
    Jul 31, 2013
    Posts:
    11
    I have noticed that in Unity 5 it appears that static batching operations do not function correctly with scenes that contain multiple lightmaps. If I have, say, a cube and a sphere in a basic scene and bake a lightmap out, the cube and the sphere (when marked static) will behave oddly when they belong to different lightmap files.

    Namely, the objects do display 'Combined Mesh' in the Hierarchy if viewed while the game is running, but the batches are not reduced as expected (still 1 pass per object).

    If anyone could shed some light on this issue it would be much appreciated. The massive scale and complexity of the scene I am currently working with results in 4 lightmap files, meaning that a LOT of batches could be saved if I could find a way around this issue.
     
  2. greenmonster

    greenmonster

    Joined:
    Jan 18, 2013
    Posts:
    26
    I think this was always the behavior, and that to alleviate this somewhat you can increase the resolution of your baked lightmaps so that more stuff fits into one lightmap texture. Correct me if I'm wrong!
     
  3. Exguardi

    Exguardi

    Joined:
    Jul 31, 2013
    Posts:
    11
    I was in fact able to adjust per-object lightmap scale and the baked lightmap resolution to achieve the desired effect. I'm curious as to why the lightmap index does not seem to be an exposed parameter like the lightmap scale-- now THAT, I thought, was an option in Unity 4. Either way, as it seems lightmap index -can- be accessed programmatically, this issue can be worked around in situations that require multiple lightmap files by using an editor script to batch objects to specific lightmap indices.
     
unityunity