Version: 2019.4
Frame Debugger (Depurador de frames)
Streaming Controller

Texture Streaming

The Texture Streaming system gives you control over which mipmap levels Unity loads into memory. This system reduces the total amount of memory Unity needs for Textures, because it only loads the mipmaps Unity needs to render the current Camera position in a Scene, instead of loading all of them by default. It trades a small amount of CPU resources to save a potentially large amount of GPU memory.

With the Texture System, you can also use the Memory Budget to set a total memory limit for all Textures to use in a Project. The Texture Streaming system automatically reduces mipmap levels to stay within this budget.

You can use the Texture System API to request specific mipmap levels for specific Textures. Unity provides sample C# code that duplicates the engine logic for mipmap selection, which you can use to override the engine logic for your own Projects. For more details, see Texture Streaming API.

In Unity’s Viking Village demo project, Texture Streaming saves 25–30% of Texture memory, depending on Camera location.

Texture Streaming setup

To enable Texture Streaming, go to Unity’s Quality Settings (Edit > Project Settings > Quality) and enable the Texture Streaming checkbox. This reveals the settings specific to the Texture Streaming system. For details on each setting, see documentation on Quality Settings.

When you’ve done this, set up Texture Streaming on individual Textures, to allow the Texture Streaming system to stream each Texture’s mipmaps from the disk into memory. To do this, select the Texture you want to apply Texture Streaming to, navigate to the Inspector window and view the Texture Import settings. Open the Advanced settings, and enable the Streaming Mip Maps checkbox.

If you’re developing for Android, you also need to open the Build Settings and set the Compression Method to LZ4 or LZ4HC. Unity requires one of these compression methods for asynchronous Texture loading, which the Texture Streaming system relies upon.

Unity loads mipmaps at the highest resolution level possible while observing the Texture Memory Budget. For more specific control, or to fine-tune the Texture Streaming system’s automatic results, use the C# API to specify mipmap levels for each Texture. For more details, see Texture Streaming API.

Texture Streaming limitations

For Texture Streaming, you need to assign each Texture to a Unity Renderer to allow the system to calculate the required mip map level, unless a script requests manual mip levels (see documentation on Texture2D.requestedMipmapLevel). If you do not assign a Texture to a Renderer (and do not set a manually requested mip), the system cannot calculate what mip to use. This results in Unity loading the Texture with reduced mips, which look blurry when close to the Camera.

The following systems don’t use standard Renderers, so you should disable Texture Streaming on Textures associated with them:

  • Decal projector Textures.
  • Reflection probe Textures. These are related to different Material properties at lower mips, so it doesn’t make sense to stream them.
  • Textures in Unity’s Terrain system. Unity does not support Texture Streaming on Terrain Textures, because the system usually blends these Textures over the whole Terrain, so they should stay on the GPU.
  • Systems which have complex Texture blending in the Shader.

When Unity renders a streamed Texture directly with an API (such as Graphics.DrawMeshNow) the system has no renderer bounds information to calculate the mip level, so you need to set the Texture mip level explicitly (or disable Texture streaming on this Texture). See documentation on Texture2D.requestedMipmapLevel for more details.

Frame Debugger (Depurador de frames)
Streaming Controller
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961