The Mipmap Streaming system gives you control over how Unity loads mipmaps.
이 페이지는 다음에 관한 정보를 제공합니다.
For information about using the API to extend the functionality of this system, see Mipmap Streaming system API.
This system forces Unity to only load the mip levels needed to render the current Camera position, 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.
You can set a total memory limit for all textures in an application, and the system automatically reduces mip levels to stay within this budget.
In Unity’s Viking Village demo project, the Mipmap Streaming system saves 25–30% of texture memory, depending on Camera location.
To enable Mipmap Streaming, go to Unity’s Quality Settings (Edit > Project Settings > Quality) and enable the Texture Streaming checkbox.
When you enable this setting, the Quality settings window reveals the settings specific to the Mipmap Streaming system. For details on each setting, see documentation on Quality Settings.
By default, this enables Mipmap Streaming for all Cameras in your project.
Now you can set up Mipmap Streaming on individual textures. Select a texture asset, 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 Mipmap Streaming system relies upon.
Unity loads mips at the highest resolution possible while observing the memory budget. You can configure the priority of a texture with the Mip Map Priority setting in the Texture Import Settings.
Unity uses this setting to determine:
Positive numbers give higher priority. Valid values range from –128 to 127.
You can use the Mipmap Streaming system to stream mip levels for lightmaps.
You can edit the Mip Map Streaming settings of the lightmap assets in the same way that you can any other texture, but they reset to their default values when Unity regenerates the lightmaps. To solve this, you can tell Unity to apply these values when it generates the lightmaps. The Player Settings (Edit > Project Settings > Player) provide two controls to set streaming and priority for generated lightmaps: Lightmap Streaming Enabled and Streaming Priority.
Enabling Mip Map Streaming and configuring priority work in the same way for lightmaps as for regular textures.
You can configure default settings in the Unity Editor, and then use the Mipmap Streaming API to override these settings if required.
The Memory Budget property determines the maximum amount of memory Unity uses for textures. If your memory budget is too small, Unity lowers the resolution of textures in your scene. This can cause textures to pop or load slowly. However, the memory budget should be as small as possible to allow memory for other resources.
Set the memory budget in the Quality Settings window, with the Texture Streaming > Memory Budget property.
When the memory budget is full, Unity discards mipmaps it’s not using, to make room for those it needs to use. You can control how many unused mipmaps it discards with the Max Level Reduction.
This value is also the mipmap level that the Mipmap Streaming system initially loads at startup. For example, when this is set to 2, Unity skips the two highest mipmaps on first load.
Set this value in the Quality Settings window, with the Texture Streaming > Max Level Reduction property.
Note: Unity prioritises the Max Level Reduction value over the memory budget. It never discards more mipmaps than the Max Level Reduction value, even if this causes the textures memory to exceed the budget.
The memory budget includes textures that do not use Mipmap Streaming. For example, if your budget is 100MB and you have 90MB of textures that don’t use Mipmap Streaming, Unity tries to fit all the streaming mipmaps in the remaining 10MB. If it can’t, it loads them at a lower resolution. Unity always loads textures that don’t use Mipmap Streaming at full resolution, even if that exceeds the budget.
적절한 가용 메모리를 파악하려면 다음을 수행하십시오.
이렇게 하면 씬에서 가장 리소스가 많이 소요되는 영역을 위한 텍스처 메모리를 충분히 확보할 수 있으며, 텍스처의 해상도가 저하되는 일을 방지할 수 있습니다. 여유 메모리가 있다면 Unity가 씬에서 보이지 않는 텍스처 데이터를 스트리밍 캐시 내에 유지할 수 있도록 가용 메모리를 좀 더 크게 설정해도 됩니다.
By default, when you enable the Mipmap Streaming system, Unity enables it for all cameras. You can disable this setting if you like.
Control whether Unity enables mipmap Streaming for all Cameras in the Quality Settings window, with the Texture Streaming > Add All Cameras property.
If you want to exclude a specific Camera, add a Streaming Controller component to that Camera and then disable it.
If you disable Add All Cameras, then you must enable mipmap Streaming per-Camera. To do this, add a Streaming Controller component to the same GameObject as the Camera component.
This component also allows you to adjust the mip bias setting per-Camera.
Mipmap Streaming (also known as texture streaming) in the Editor is enabled by default, but only takes effect if you have enabled Texture Streaming in Quality Settings, and have enabled Mipmap Streaming on one or more of your texture asset’s import settings.
You can control whether Unity uses Mipmap Streaming in the Editor in both Play Mode and Edit Mode independently. To do this, go to Project Settings > Editor > Streaming Settings.
If you enable Mipmap Streaming in the Editor for one mode but not the other, entering and exiting Play mode takes slightly longer. Enabling Mipmap Streaming for both modes prevents Unity from unloading and reloading mipmap data, and increases the speed of entering and exiting Play Mode.
The “Load texture data on demand” setting enables further optimizations in the Editor for textures which have mip-map streaming enabled, which:
These optimizations avoid some stalls, make loading slightly faster, and reduce the amount of CPU memory used. However, this setting can cause mip-mapped textures to temporarily appear at a lower resolution than they should while a higher resolution version is loaded in. This feature incurs some overhead on the CPU, so you might want to leave this disabled if your textures all fit in memory at once, or you don’t have any textures set up to stream.
Unity에는 빌트인 밉맵 스트리밍 디버깅 뷰 모드가 있습니다. 이 모드에 액세스하려면 씬 뷰 컨트롤 드롭다운을 클릭한 후 Texture Streaming 을 선택하십시오. 이 뷰 모드는 밉맵 스트리밍 시스템의 상태에 따라 게임 오브젝트에 다음 컬러를 입힙니다.
디버깅 API를 사용하여 직접 커스텀 디버그 툴 및 시각화를 작성할 수도 있습니다.
중요 : MainTexture 속성을 사용하여 설정된 메인 텍스처는 텍스처 스트리밍 디버깅 뷰 모드 또는 커스텀 디버그 툴을 사용하는 경우 게임 뷰에 표시되지 않습니다.
For textures that use Mipmap Streaming, Unity calculates the correct mip level using one of the following methods:
If you don’t do this, Unity can’t calculate the correct mip level, and it loads the texture using low-quality mips. These can appear blurry.
Note: The following systems don’t use standard Renderer components. This means you must manually set the requested mips for these systems:
_ST
value with the same name as the texture flagged in your shader. For example, if you reference your textures are in the shader using _MainTex
, Unity will look for _MainTex_ST
.