Search Unity

LightmapIndex not setting

Discussion in 'General Graphics' started by LondonStevey, Jan 21, 2019.

  1. LondonStevey

    LondonStevey

    Joined:
    Jun 26, 2015
    Posts:
    33
    Hi, I've creating some assets that blend with the terrain. Its all working perfectly now apart from the lightmapping when I press play. Below is the cliff I've created and blended with the terrain. I've set its uv2s to the terrain hits, and set the lightmapindex and lightmapscaleoffsets on the renderer to match that of the terrain, and all works great.
    terrainblend1.JPG
    terrainblend2.JPG
    When I hit Play, the baked lightmap settings all get cleared on the cliff object and I get the below:
    terrainblend3.JPG
    terrainblend4.JPG
    I've tried setting this again at runtime and check the uv2s and they're still exactly the same, but it all seems to be offset incorrectly, even though it looks like its potentially using the correct lightmap.
    terrainblend5.JPG

    If I regenerate the entire mesh in Play mode it works and sets everything correctly again.

    So, is there anything additional I need to do to get that lightmapindex saved before building?
    Also any ideas why if I reset the index and offset at runtime without rebuilding the whole mesh, its producing those weird results above?
    Many Thanks!