TextureStreaming
Manages dynamic texture mipmap streaming to optimize VRAM usage.
Manages dynamic texture mipmap streaming to optimize VRAM usage.
The TextureStreaming singleton manages dynamic loading and unloading of texture mipmap levels based on what is visible in the current frame. This allows projects with many large textures to significantly reduce VRAM usage while maintaining visual quality for visible textures.
Texture streaming works by analyzing shader feedback to determine which textures are actively being used and at what resolution they're being displayed. Textures that are far from the camera or not currently visible have their higher-resolution mipmap levels unloaded, while textures being displayed up close are loaded at higher resolutions.
The system includes a memory budget feature that automatically manages texture resolutions to stay within a specified VRAM limit. When the budget is exceeded, the system prioritizes textures based on how recently they were used and how much screen space they occupy.
Note: Texture streaming must be enabled in the Project Settings (ProjectSettings.rendering/textures/streaming/enabled) and textures must be imported with streaming support to use this feature.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties4
MaxLodOverrideProperty
public static int MaxLodOverride { get; set; }Overrides the maximum LOD (mipmap level) that can be loaded for streamed textures at runtime. Lower values allow higher resolution textures. Valid values are 0 (full resolution) to 13 (lowest resolution). Values outside that range clear the override and use the default from ProjectSettings.rendering/textures/streaming/max_lod; when no override is active this property returns -1.
MemoryBudgetMbOverrideProperty
public static uint MemoryBudgetMbOverride { get; set; }Overrides the memory budget for streamed textures at runtime (in megabytes). When the budget is exceeded, the system reduces texture resolution to stay within the limit. A value of UINT32_MAX (4294967295, the maximum unsigned 32-bit integer) disables the override and uses the default from ProjectSettings.rendering/textures/streaming/memory_budget_mb.
MinLodOverrideProperty
public static int MinLodOverride { get; set; }Overrides the minimum LOD (mipmap level) that textures start at when loaded. Higher values result in lower initial resolution. Valid values are 0 (full resolution) to 13 (lowest resolution). Values outside that range clear the override and use the default from ProjectSettings.rendering/textures/streaming/min_lod; when no override is active this property returns -1.
SingletonProperty
public static TextureStreamingInstance Singleton { get; }Methods8
FlushTextureStreamingvoid
public static void FlushTextureStreaming();Forces all currently queued texture streaming operations to complete immediately, bypassing the normal gradual transition and I/O throttling. This immediately loads or unloads mipmap levels to reach the target resolution for all managed textures, then emits the TextureStreaming.FlushCompleted signal. Useful during loading screens or when teleporting the player to ensure all textures are at their optimal resolution without a visible transition.
GetMaxLodOverrideint
public static int GetMaxLodOverride();intGetMemoryBudgetBytesUsedulong
public static ulong GetMemoryBudgetBytesUsed();Returns the current VRAM usage of streamed textures in bytes. This represents the total memory consumed by all streamed textures at their currently loaded mipmap levels.
ulongGetMemoryBudgetMbOverrideuint
public static uint GetMemoryBudgetMbOverride();uintGetMinLodOverrideint
public static int GetMinLodOverride();intSetMaxLodOverridevoid
public static void SetMaxLodOverride(int maxLod);| Name | Type | Default |
|---|---|---|
maxLod | int | — |
SetMemoryBudgetMbOverridevoid
public static void SetMemoryBudgetMbOverride(uint mb);| Name | Type | Default |
|---|---|---|
mb | uint | — |
SetMinLodOverridevoid
public static void SetMinLodOverride(int minLod);| Name | Type | Default |
|---|---|---|
minLod | int | — |
Signals and events1
FlushCompletedEvent
public static event Action FlushCompleted;Emitted when a texture streaming flush operation finishes, after TextureStreaming.FlushTextureStreaming has been called and all managed textures have reached their target resolutions.