Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Lightmap issue with assetbundle

Discussion in 'Shaders' started by watsonsong, Jan 16, 2016.

  1. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    360
    I build a lightmapped scene into assetbundle, and load it in editor, the lightmap is missing. I dig into it and find strange things, I don't know how to deal with it.
    I write a script and attach it to the root of the scene to report the lightmap information.

    And Print this result, I think it means the lightmap is existed:



     

    Attached Files:

  2. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    360
    And I check the lightmap texture:

    And print it on GUI, it shows!!
     

    Attached Files:

  3. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    360

    I watch the render pipeline in profiler, the LIGHTMAP_OFF is used.
     

    Attached Files:

  4. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    360

    When I use EditorApplication.LoadLevelAsyncInPlayMode to load the scene, but not Application.LoadLevelAsync, it use lightmap.
     

    Attached Files:

  5. watsonsong

    watsonsong

    Joined:
    May 13, 2015
    Posts:
    360
    I find a strange thing, if I build assetbundle when the editor open the lightmapped scene, then everything will be OK.
    But if I build assetbundle when the editor is opening an empty scene, the problem will show.
    Is there anything I missed?
     
  6. DziDAI

    DziDAI

    Joined:
    Dec 6, 2012
    Posts:
    67
    @watsonsong Did you find any solution how to fix it?
     
  7. matrix4x4

    matrix4x4

    Joined:
    Oct 29, 2012
    Posts:
    7
    @DziDAI @watsonsong same problem~! Download lightmap assetbundle, and set lightmapsetting. instantiate prefab from assetbundle , then recover their rendermesh component's lightmap index and uv. but wrong, open debug frame, shader properties LightMap_OFF,anyone have solution for it? (instantiate gameobject from resources is ok!)
    // 1. instance from resources
    1.instance from resources.jpg
    // 2. instance from assetbundle
    2.instance from assetbundle.jpg
    1.instance from resources.jpg 2.instance from assetbundle.jpg 1.instance from resources.jpg 2.instance from assetbundle.jpg
     
  8. DziDAI

    DziDAI

    Joined:
    Dec 6, 2012
    Posts:
    67
    Hi @matrix4x4

    Try next:

    1. open empty scene and create assetBundles, after test it, if ok, so your lucky, if not try step 2
    2. Open any scene with Lightmap and create assetBundles (while scenes open) and test it
     
  9. mr_zog

    mr_zog

    Joined:
    Jan 21, 2014
    Posts:
    165
    MNNoxMortem likes this.
  10. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    356