Search Unity

Is texture streaming supported with addressables?

Discussion in 'Addressables' started by Lex4art, Dec 26, 2020.

  1. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    If somebody have this problem or you planning to use addressables/runtime material loading with Texture Streaming enabled - please, give your "user pain voice" for this bugreport or it will probably never be noticed and fixed. Thanks in advance!


    ============================== Old post ==============================

    I don't know is it a bug that needed to be reported or this feature just not implemented: if material loaded using addressables and 'Texture Streaming' enabled in project settings (Camera has 'Streaming controller' on it of course)... well, all textures on this loaded material will stay in low-res state (mip 4 with default settings) no matter how close your camera to that object and how long you wait; same material applied on the scene objects and saved as a part of the scene - it works fine with streaming. Is this problem of my code / it's a bug / this feature is not implemented?

    Code (CSharp):
    1. //MUIDKEY - material GUID.
    2. MatIndex = 0; //for this example
    3.  
    4. Addressables.LoadAssetAsync<Material>(MUIDKEY).Completed += LoadFinished;
    5.  
    6. private void LoadFinished(AsyncOperationHandle<Material> mtl)
    7. {
    8.     if (mtl.Status == AsyncOperationStatus.Succeeded)
    9.     {
    10.         var i = 0;
    11.         while (i < this.transform.childCount)
    12.         {
    13.             if (this.transform.GetChild(i).gameObject.GetComponent<MeshRenderer>())
    14.             {
    15.                 if (this.transform.GetChild(i).gameObject.GetComponent<MeshRenderer>().enabled)
    16.                 {
    17.                         Material[] mats = this.transform.GetChild(i).gameObject.GetComponent<MeshRenderer ().materials;
    18.                         //In case lower LODs have less materials than LOD0
    19.                         if(MatIndex < mats.Length)
    20.                         {
    21.                         mats[MatIndex] = mtl.Result;
    22.                         this.transform.GetChild(i).gameObject.GetComponent<MeshRenderer>().materials = mats;
    23.                         }
    24.                  }
    25.             }
    26.         i++;
    27.        }
    28.    }
    29. }
     
    Last edited: Feb 17, 2021
  2. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    Upd: hmmm, Texture Streaming feature not working properly even when I don't use addressables materials - just applying material at runtime gives same problems with low-res & overall inadequate streaming behavior. Meh...

    Upd2: Got streaming working - both for addressables materails and normal ones. The trick is to apply material to the prefab and then instantiate it for a second - both original and instantiated versions will update their textures to full res after that and instance can be simply deleted after that... Weird, but at least something working ).

    Upd3: Nope, Texture Streaming with run-time materials not working - if you place material close up to the camera and do the instancing trick - material will have full res textures but if you place material on distant object and come close to it - it's still have low-res textures no matter how long you will wait...
     
    Last edited: Dec 27, 2020
  3. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    If somebody has this problem or you planning to use addressables/runtime material loading with Texture Streaming enabled - please, give your "user pain voice" for this bugreport or it will probably never be noticed and fixed. Thanks in advance!
     
    Last edited: Mar 25, 2021
  4. Leniaal

    Leniaal

    Joined:
    Nov 7, 2012
    Posts:
    119
    I upvoted the bugreport, though I think there are other issues with texture streaming + addressables as well. For example we are using impostors for some structures/objects and no matter what settings we use for texture streaming, a lower quality mip map is always used.

    We've had to disable Streaming Mipmaps on the textures used for these impostors for them to work in combination with addressables.

    Example this crane in the distance:

    Using Asset Database:
    PaintDotNet_2021-03-25_16-48-28.png

    Using Existing Build:
    PaintDotNet_2021-03-25_16-48-47.png

    It doesn't matter whether we configure a higher memory budget, or any other setting. It keeps using the wrong mipmap.
     
    Lex4art likes this.
  5. Lex4art

    Lex4art

    Joined:
    Nov 17, 2012
    Posts:
    445
    Finally fixed in today's 2022.1b1! Hell yeah :)
     
    io-games, AshwinMods and Whatever560 like this.