Search Unity

Baked lightmap in assetbundles not work properly, what should i do to make it working.

Discussion in 'Global Illumination' started by sunyifeng, May 25, 2015.

  1. sunyifeng

    sunyifeng

    Joined:
    Nov 4, 2014
    Posts:
    28
    when i use Application.LoadLevelAsync(m_strScene);
    it works properly like this:
    upload_2015-5-25_20-10-5.png
    but if i use BuildResources to build the scenes to assetbundles, the lightmap do not work ever, like this:
    upload_2015-5-25_20-13-4.png
    any help will be appreciated and my unity version is 5.0.2f1.
     
  2. sunyifeng

    sunyifeng

    Joined:
    Nov 4, 2014
    Posts:
    28
    Anybody can help me? I doubt its a bug in unity 5.0 right now?I was really stucked on this problem.
     
  3. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    Could you show the code you use to build asset bundle and to load from it?
     
  4. sunyifeng

    sunyifeng

    Joined:
    Nov 4, 2014
    Posts:
    28
    I used like this:
    BuildPipeline.BuildAssetBundles(GetBuildResourcePath(targetos), BuildAssetBundleOptions.DeterministicAssetBundle, targetos);
    And load like this:
    1.First, I load from memory, ab is compressed data, I read the bytes data and load ab use: AssetBundle.CreateFromMemory(download.data);

    2.Second, when it is completed, I load the scene use:
    LoadedAssetBundle bundle = AssetBundleManager.GetLoadedAssetBundle (m_AssetBundleName, out m_DownloadingError);
    if (bundle != null)
    {
    if (m_IsAdditive)
    m_Request = Application.LoadLevelAdditiveAsync (m_LevelName);
    else
    m_Request = Application.LoadLevelAsync (m_LevelName);

    return false;
    }
    else
    return true;

    Normal assets works good.Am i doing wrong?
     
  5. sunyifeng

    sunyifeng

    Joined:
    Nov 4, 2014
    Posts:
    28
    Others work properly except the baked lightmap. Please help me.
     
  6. SpiriTx

    SpiriTx

    Graphics QA Unity Technologies

    Joined:
    Apr 12, 2012
    Posts:
    252
    LoadLevelAdditive is not yet supported for new system, so please beware not to use it.
    Otherwise code seems ok.
     
  7. sunyifeng

    sunyifeng

    Joined:
    Nov 4, 2014
    Posts:
    28
    I do not use LoadLevelAdditive, I just only use LoadLevelAsync. When i load scenes, everything is ok except the baked lightmaps, I tried not build baked lightmaps as dependences, but still lightmaps seems not loaded successfully, it just black always. When I use the normal LoadLevelAsync, not use assetbundle, It works fine.
     
  8. mweldon

    mweldon

    Joined:
    Apr 19, 2010
    Posts:
    109
    I am having a similar issue with asset bundles. I bake separate small lightmaps for individual prefabs. I save the prefab and its lightmaps into asset bundles. I store the index and scale/offset values per renderer on the prefab so that I can fix them up at runtime.

    If I load one of these prefabs using Resources.Load the lightmaps work fine, but if I bundle the same prefab into an asset bundle and load it from there, the building looks as if the lightmap is solid white. Only difference between the two is one is in a bundle and the other is not.
     
  9. mweldon

    mweldon

    Joined:
    Apr 19, 2010
    Posts:
    109
    Solved my problem. Looks like there was crap in my asset bundle. Took me a while but was able to get it to work.

    One remaining issue with bundles though is that if the only thing that changes in a bundle is an .ezr file (lightmap) then it seems like Unity thinks it doesn't need to update the bundle.