Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


SparseTexture

Class for handling Sparse Textures.
Read time 6 minutesLast updated 4 days ago

Definition

  • Type: Class
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
  • Inherits from: Texture
public sealed class SparseTexture : Texture

Remarks

Sparse textures are textures where not the whole texture data can be present in memory at once. They are also commonly called "tiled textures" or "mega textures".
Imagine a 16384x16384 texture at 32 bits per pixel - it would take 1GB of memory. The texture is broken down into rectangular "tiles", and each tile can either be present in memory or not. You can load & unload these tiles as needed based on distance from the camera, sectors of the world that the player has to see, etc.
Otherwise, the sparse textures behave just like any other texture in shaders - they can have mipmaps, can use all texture filtering modes, etc. If you happen to read from a tile that's not present, you can get undefined result (on many GPUs the result is a black color, but that's not guaranteed).
Not all hardware and platforms support sparse textures, so you should check SystemInfo.supportsSparseTextures before using them. For example, on DirectX systems they require DX11.2 (Windows 8.1) and a fairly recent GPU; and on OpenGL they require ARB_sparse_texture extension support. Sparse textures only support non-compressed texture formats.
After creating the sparse texture, query the tile size with SparseTexture.tileWidth & SparseTexture.tileHeight. Tile sizes are platform and GPU dependent.
Use SparseTexture.UpdateTile or SparseTexture.UpdateTileRaw to make a tile resident in memory and update its color data. Use SparseTexture.UnloadTile to unload a tile.
Additional Resources: Sparse Textures.

Constructors

Properties

Property

Description

isCreatedIs the sparse texture actually created? (Read Only)
tileHeightGet sparse texture tile height (Read Only).
tileWidthGet sparse texture tile width (Read Only).

Methods

Method

Description

UnloadTileUnload sparse texture tile.
UpdateTileUpdate sparse texture tile with color values.
UpdateTileRawUpdate sparse texture tile with raw pixel values.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.