Search Unity

Mipmap streaming + asset bundles: is the whole texture loaded from disk?

Discussion in 'General Graphics' started by tspk91, Feb 3, 2020.

  1. tspk91

    tspk91

    Joined:
    Nov 19, 2014
    Posts:
    131
    Many engines load coarser mipmaps at first, and then asynchronously load the others during the first moments of gameplay. This allows for faster loading screens, at the expense of the world looking blurrier just after the level starts.

    When you load an assetbundle that contains textures with mipmap streaming enabled, are all mipmaps loaded from the assetbundle regardless? I did not notice any loading speed improvements after integrating streaming mipmaps in the project and all assets.
     
  2. lyndon_unity

    lyndon_unity

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    66
    Hi,

    Yes the mipmap streaming should mean only the lower mips are loaded at first. The 'Max Level Reduction' value specifies how many mips at not loaded at the start. Once it calculates the highest visible mip level for a texture it will then load that desired mip level, if its not already loaded (including all the mips below that level).

    There are some requirements for a texture to be streamable which could effect the result.
    • Are your textures Read/Write enabled. If they are then all mips are loaded for the CPU side copy.
    • Crunch compressed textures are not mip streamable so will load in full.
    Which Unity version are you currently using?
    There was a bug at one stage where all mips would be loaded on startup then the unnecessary ones dropped when the mip level was calculated. Recent releases fixed this.

    What platform are you testing on?
    Are you testing on device rather than in editor?
     
    bwk_obs and FlightOfOne like this.
  3. meichen8050753

    meichen8050753

    Joined:
    Jan 16, 2017
    Posts:
    37
    I'm using 2018.4.23, and some texture loading with low mipmap, It doesn't change whether I'm close or not,texture streaming memory budget is enougth. Is this the bug you mentioned?
    In which version has it been fixed?
     
  4. lyndon_unity

    lyndon_unity

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    66
    The bug I previously mentioned didn't prevent mips streaming in, it caused unnecessary loading of the highest mips on initial startup, then correctly unloaded some as needed when mip levels were calculated.

    If your streaming texture on a mesh which uses a standard unity shader?
    If you have an issue with streaming mips not loading in, it could be related to using a complex custom shader that modifies the uv values, or one of the other cases covered in the following document. Check the other cases here and if you are still having problems then it would be worth raising a bug report.
    https://docs.unity3d.com/Manual/TextureStreaming.html
     
  5. meichen8050753

    meichen8050753

    Joined:
    Jan 16, 2017
    Posts:
    37
    Our day and night system is a dynamically replaced texture. At the beginning, the day texture is loaded on the building. Because Max Level Reduction is set to 2, the night texture is defaulted to mipmaplevel2 in the memory, and then when switching between day and night, directly put the day The texture is replaced with the night texture. It seems that Unity will not recalculate the mipmaplevel, so the night texture is loaded on the material with mipmaplevel = 2, so it is blurred. For the time being, I found that re-active the model can streaming to mipmap0
     
  6. akashdarshan99

    akashdarshan99

    Joined:
    Feb 26, 2020
    Posts:
    8
    @lyndon_unity
    so based on your previous message is it correct to infer that the mip map streaming will not be affective at all when crunch compressed?
    also one more thing im my case is that I'm using a VFX graph which does modify certain UVs. so according to the docs, im responsible for doing the mip map streaming. so is there a way to gradually load the texture from lowest mip map to highest to reduce hiccups? also in my case the vfx graph texture always seems to be loaded in the lowest possible mip map level, but the texture is also crunch compressed.

    So my tests are contradicting either one of your statements. Could you please clarify this once?
     
  7. lyndon_unity

    lyndon_unity

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    66
    Crunch compressed textures will load from disk in full, but a subset of the mips will be loaded to GPU memory. So you get the memory saving benefit but not an additional loading speed benefit (over the crunch compression itself).

    If you have a custom and complex shader which modifies the UV's, the texture streaming system will not be aware of this. Therefore it will not be able to calculate the correct mip to load, so you would need to override it by setting the requestedMipLevel on the textures related to those shaders. (This could be the cause of the system currently selecting the lowest mip map level).

    When requesting a change of mip level all the mips are currently reloaded to the GPU so you cannot gradually load the texture from lowest mip map to highest.

    You might find that the Virtual Texturing system provides a better alternative for your needs. This does screenspace mip calculations so would work with the custom shaders.
     
  8. fanshuhua

    fanshuhua

    Joined:
    Jul 3, 2014
    Posts:
    1

    I also encountered this problem,How did you solve this problem?