SetStreamingTextureMaterialDebugProperties
This function sets mipmap streaming debug properties on all materials known by the mipmap streaming system.
Read time 5 minutesLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
SetStreamingTextureMaterialDebugProperties()
This function sets mipmap streaming debug properties on all materials known by the mipmap streaming system.
public static void SetStreamingTextureMaterialDebugProperties()
Remarks
You can use this function to set up debug shader properties on the materials of all renderers in the scene. To set up renderers and cameras for the mipmap streaming system, see Texture Streaming.
For every streaming Texture a material uses, this function sets up two properties that are called and . Respectively, they contain the following values:
(Texture property name)_MipInfo(Texture property name)_StreamInfo-
streamingMipmapsMaxLevelReduction, minus the number of mips that Unity has stripped in the texture.
-
Time stamp of the latest texture upload.
-
Streaming status code.
-
Unused / 0.
Note that the streaming status code value is set even for non-streaming Textures. The codes set by the mipmap streaming system are:
- -1: Texture is correctly streaming.
- 0: The Mipmap Streaming system does not know this Texture.
- 1: Mipmap Streaming is disabled for the active Quality level.
- 2: No texture.
- 3: Texture has no mipmaps generated, cannot stream.
- 4: Texture is not set to stream.
- 5: Texture cannot be asynchronously streamed (player only).
- 7: Texture has an invalid streaming index within the mipmap streaming system: report a bug.
- 8: Texture is manually streaming through the use of requestedMipmapLevel.
Use these properties in your own debug shaders to visualize the current streaming state of any Textures.
For example, when you use this function in a scene with a renderer that has a material with a Texture property named "MainTex", it sets two properties called and on the material. The former property contains Streaming Mip Level, Texture Original Mipmap Count, Desired Streaming Mip Level, and Loaded Mip Level in its x, y, z, and w fields while the latter property contains the Texture's Streaming Priority, time stamp of its latest GPU upload, Streaming Status Code and 0 in its x, y, z, and w fields.
float4MainTex_MipInfoMainTex_StreamInfoFor lightmaps, this function sets the and properties.
unity_Lightmap_MipInfounity_Lightmap_StreamInfoTo view the mipmap streaming state of textures in the Universal Render Pipeline (URP), use the Mipmap Streaming debug views in the Rendering Debugger.
The and properties contain the state at the time of the call, and materials keep these values until the next call. To visualize up-to-date values with your own debug shader, call every frame before the camera renders, for example from RenderPipelineManager.beginCameraRendering.
_MipInfo_StreamInfoTexture.SetStreamingTextureMaterialDebugPropertiesTo render objects with your own debug shader, draw renderers with DrawingSettings.overrideShader. The override shader keeps the properties of each material, so it can read the and properties. For an example render pass in URP that draws renderers with an override shader, refer to SceneView.AddCameraMode.
_MipInfo_StreamInfoTo declare the and properties for a texture in your shader, use the macro in . For shader functions that decode these properties into debug colors, refer to , which the Rendering Debugger uses.
_MipInfo_StreamInfoUNITY_TEXTURE_STREAMING_DEBUG_VARS_FOR_TEXPackages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlslPackages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreaming.hlslSetStreamingTextureMaterialDebugProperties(int)
This function sets mipmap streaming debug properties on all materials known by the mipmap streaming system, using data specific to a given material texture slot.
public static void SetStreamingTextureMaterialDebugProperties(int materialTextureSlot)
Parameters
The material texture slot to refer to when setting up mipmap streaming debug properties.
Remarks
You can use this overload to easily debug any given material texture slot on the materials of all renderers in the scene.
Instead of setting two properties for each material texture property, this function sets the following properties:
- A 2D texture property called .
unity_MipmapStreaming_DebugTex - A vector property called .
unity_MipmapStreaming_DebugTex_MipInfo - A vector property called .
unity_MipmapStreaming_DebugTex_StreamInfo
The values set for these properties correspond to the data known by the mipmap streaming system for the texture in the indicated material texture slot, even if that texture is not streaming.
The mipmap streaming system uses the order in which texture properties appear in the block of shaders to determine what a given slot number corresponds to.
PropertiesAdditionally: if is , the mipmap streaming system, where it makes sense, aggregates the data of all textures on materials known by the system and sets the previously mentioned properties using that aggregated data.
materialTextureSlot-1- is set using the texture assigned to material texture slot 0.
unity_MipmapStreaming_DebugTex - is set to (0, 0, 0, 0), the values are too specific to individual textures to be aggregated.
unity_MipmapStreaming_DebugTex_MipInfo - is set to (0, Time stamp of the latest texture upload on the material, Packed Streaming Status Code + Streaming Status Flags, 0).
unity_MipmapStreaming_DebugTex_StreamInfo
Note that the Streaming Status Codes reserve the 0-15 values. The streaming status flags set by the mipmap streaming system when aggregation occurs are:
- 16: The material has Textures that are streaming.
- 32: The material has Textures that are not streaming.
- 64: The material has Textures that have issues preventing them from streaming.
- 128: The material has Textures that are streaming manually through the use of requestedMipmapLevel.
- No flags set: The material has no Textures.
To declare the vector properties in your shader, use the macro in . For shader functions that decode these properties into debug colors, refer to , which the Rendering Debugger uses.
UNITY_TEXTURE_STREAMING_DEBUG_VARSPackages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlslPackages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreaming.hlsl