Version: 2020.3
프레임 디버거
스트리밍 컨트롤러

밉맵 스트리밍

밉맵 스트리밍 시스템은 Unity가 메모리에 로드하는 밉맵 레벨을 제어하도록 해줍니다. 이 시스템은 Unity가 텍스처에 필요로 하는 총 메모리 양을 줄여줍니다. 즉, 기본적으로 모든 밉맵을 로드하는 대신, Unity가 씬의 현재 카메라 포지션을 렌더링하는 데 필요한 밉맵을 로드합니다. 이렇게 하면 약간의 CPU 리소스를 소모하여 잠재적으로 매우 많은 GPU 메모리를 절약할 수 있습니다.

또한 Memory Budget 을 사용하여 프로젝트에서 사용되는 모든 텍스처에 대해 총 메모리 제한을 설정할 수 있습니다. 밉맵 스트리밍 시스템은 메모리 할당량을 넘지 않도록 밉맵 레벨을 자동으로 낮춥니다.

밉맵 스트리밍 API를 사용하여 특정 텍스처에 대한 특정 밉맵 레벨을 요청할 수 있습니다. Unity는 선택한 밉맵의 엔진 로직을 복제하는 샘플 C# 코드를 제공합니다. 이 코드를 이용하면 자체 프로젝트의 엔진 로직을 오버라이드할 수 있습니다. 자세한 내용은 밉맵 스트리밍 API를 참조하십시오.

Unity의 Viking Village 데모 프로젝트에서는 밉맵 스트리밍이 카메라 위치에 따라 텍스처 메모리를 25–30% 절감합니다.

시작

밉맵 스트리밍을 활성화하려면 Unity의 품질 설정(Edit > Project Settings > Quality)으로 이동하여 Texture Streaming 체크박스를 활성화하십시오. 그러면 밉맵 스트리밍 시스템에 대한 설정이 나타납니다. 각 설정에 대한 자세한 내용은 품질 설정 문서를 참조하십시오.

이 작업을 마치면 각 텍스처에 대해 밉맵 스트리밍을 설정하여 밉맵 스트리밍 시스템이 각 텍스처의 밉맵을 디스크에서 메모리로 스트리밍하도록 허용할 수 있습니다. 이렇게 하려면 밉맵 스트리밍을 적용할 텍스처를 선택하고, 인스펙터 창으로 이동하여 텍스처 임포트 설정을 확인해야 합니다. Advanced 설정을 열고 Streaming Mip Maps 체크박스를 활성화하십시오.

Android용 개발인 경우 빌드 설정을 열어 Compression MethodLZ4 또는 LZ4HC 로 설정해야 합니다. 이 압축 방식 중 하나를 밉맵 스트리밍 시스템이 기반을 두는 비동기 텍스처 로딩에 사용해야 합니다.

Unity는 텍스처 Memory Budget 을 관찰하는 동안 가능한 가장 높은 해상도의 밉맵을 로드합니다. 좀 더 세밀한 제어가 필요하거나 밉맵 스트리밍 시스템의 자동 결과를 미세 조정하려는 경우 C# API를 사용하여 각 텍스처에 대한 밉맵 레벨을 지정해야 합니다. 자세한 내용은 밉맵 스트리밍 API를 참조하십시오.

제한 사항

You can instruct Mipmap Streaming to calculate the required mipmap levels using one of the following methods:

If you don’t instruct Mipmap Streaming to calculate mipmap levels using one of these methods, Unity can’t calculate which mip level to use. This causes Unity to load the texture using low-quality mips that appear blurry.

The following systems don’t use standard Renderers. This means you must manually set the requested mipmaps for these systems or Unity loads the textures they use at low resolution:

  • 데칼 프로젝터 텍스처
  • Reflection probe Textures: Lower resolution mipmaps are a lookup table for roughness. Therefore, if Unity uses a lower mipmap level, it renders materials using the wrong roughness.
  • Textures in Unity’s Terrain system: Unity does not support Mipmap Streaming on Terrain Textures. This is because Terrain Textures need to be available at full resolution at all times to allow Unity to tile and blend the textures.
  • Shaders that handle texture UV coordinates differently from the Unity built-in shaders. Unity always assumes the textures are sampled using UV0 as stored in the Msh. Any shader based modifications of the texture coordinates, except for the scale and translation (see below), or the use of UV1, are not taken into account.

When a renderer is active, the mesh that renderer uses requires valid UV distribution metrics to calculate the desired mipmap level. Unity calculates distribution metrics automatically as part of the mesh importing process. You can also calculate this in a script using Mesh.GetUVDistributionMetric.

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

Debugging Mipmap Streaming

Unity has a built-in Mipmap Streaming debugging view mode. To access it, click the Scene view control drop-down and select Texture Streaming. This view mode tints GameObjects the following colours, depending on their status in the Mipmap Streaming system:

  • Green for Textures that have reduced mipmaps due to the Mipmap Streaming system.
  • Red for Textures that have fewer mipmaps because the Mipmap Streaming system does not have enough resources to load them all.
  • 파란색 : 스트리밍이 설정되지 않은 텍스처. 또는 밉 레벨을 계산할 렌더러가 없음.

You can also write your own custom debug tools and visualizations using the Debugging API

Important : If you flag a main texture in your shader using the MainTexture property attribute, these textures will not be visible in debug mode. To work around this, always use a texture property named _Maintex to indicate the main texture of a material.

프레임 디버거
스트리밍 컨트롤러
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961