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. Dismiss Notice

Mesh.CombineMeshes ignoring light maps

Discussion in 'Scripting' started by Gnimmel, Mar 17, 2017.

  1. Gnimmel

    Gnimmel

    Joined:
    Apr 21, 2010
    Posts:
    358
    I have been experimenting with a real time spot light as a flashlight in a mobile scene and found this doesn't work too well with static batching.

    To get around this I just tried the example script in the docs under Mesh.CombineMeshes to combine parts of my level into 1 mesh and so manually reducing draw calls.

    https://docs.unity3d.com/ScriptReference/Mesh.CombineMeshes.html

    This seems to work well, except that the light map uv's are dropped.

    I have a bunch of the same object, e.g. walls, floor etc. tiled around the level, but once I've combined things together, all the same mesh uses the same lightmap UV's so all the wall sections have the same lighting.

    Can anyone point out what is wrong with that script?
     
    Last edited: Mar 17, 2017
  2. Gnimmel

    Gnimmel

    Joined:
    Apr 21, 2010
    Posts:
    358
    No one combines meshes in unity 5 anymore :(

    Is there a asset that can do it?
     
  3. advo

    advo

    Joined:
    Apr 6, 2016
    Posts:
    14
    This is so frustrating, spent days on this and i also have the same problem and cannot get it to work. The last parameter (bool hasLightMapData), setting it to true does not carry forward lightmap data and UVs (generated by Unity's import settings on the mesh).

    mesh.CombineMeshes(combine, true, true, true);