Documentation

Unity Engine

Download Unity

Unity Engine

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
(Texture property name)_MipInfo
and
(Texture property name)_StreamInfo
. Respectively, they contain the following values:
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
float4
properties called
MainTex_MipInfo
and
MainTex_StreamInfo
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.
For lightmaps, this function sets the
unity_Lightmap_MipInfo
and
unity_Lightmap_StreamInfo
properties.
To view the mipmap streaming state of textures in the Universal Render Pipeline (URP), use the Mipmap Streaming debug views in the Rendering Debugger.
The
_MipInfo
and
_StreamInfo
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
Texture.SetStreamingTextureMaterialDebugProperties
every frame before the camera renders, for example from RenderPipelineManager.beginCameraRendering.
To 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
_MipInfo
and
_StreamInfo
properties. For an example render pass in URP that draws renderers with an override shader, refer to SceneView.AddCameraMode.
To declare the
_MipInfo
and
_StreamInfo
properties for a texture in your shader, use the
UNITY_TEXTURE_STREAMING_DEBUG_VARS_FOR_TEX
macro in
Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl
. For shader functions that decode these properties into debug colors, refer to
Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreaming.hlsl
, which the Rendering Debugger uses.

SetStreamingTextureMaterialDebugProperties(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

materialTextureSlot

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
Properties
block of shaders to determine what a given slot number corresponds to.
Additionally: if
materialTextureSlot
is
-1
, 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.
  • unity_MipmapStreaming_DebugTex
    is set using the texture assigned to material texture slot 0.
  • unity_MipmapStreaming_DebugTex_MipInfo
    is set to (0, 0, 0, 0), the values are too specific to individual textures to be aggregated.
  • unity_MipmapStreaming_DebugTex_StreamInfo
    is set to (0, Time stamp of the latest texture upload on the material, Packed Streaming Status Code + Streaming Status Flags, 0).
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
UNITY_TEXTURE_STREAMING_DEBUG_VARS
macro in
Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreamingMacros.hlsl
. For shader functions that decode these properties into debug colors, refer to
Packages/com.unity.render-pipelines.core/ShaderLibrary/DebugMipmapStreaming.hlsl
, which the Rendering Debugger uses.