Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

SparseTexture

Namespace: UnityEngine

/

Inherits from: Texture

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Class for handling Sparse Textures.

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).

Note that 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 also require a Unity Pro license.

After creating the sparse texture, query the tile size with tileWidth & tileHeight. Tile sizes are platform and GPU dependent.

Use UpdateTile or UpdateTileRaw to make a tile resident in memory and update its color data. Use UnloadTile to unload a tile.

See Also: Sparse Textures documentation page.

Variables

isCreated Is the sparse texture actually created? (Read Only)
tileHeight Get sparse texture tile height (Read Only).
tileWidth Get sparse texture tile width (Read Only).

Constructors

SparseTexture Create a sparse texture.

Functions

UnloadTile Unload sparse texture tile.
UpdateTile Update sparse texture tile with color values.
UpdateTileRaw Update sparse texture tile with raw pixel values.

Inherited members

Variables

hideFlags Should the object be hidden, saved with the scene or modifiable by the user?
name The name of the object.
anisoLevel Anisotropic filtering level of the texture.
filterMode Filtering mode of the texture.
height Height of the texture in pixels. (Read Only)
mipMapBias Mip map bias of the texture.
width Width of the texture in pixels. (Read Only)
wrapMode Wrap mode (Repeat or Clamp) of the texture.

Functions

GetInstanceID Returns the instance id of the object.
ToString Returns the name of the game object.
GetNativeTextureID Retrieve native ('hardware') handle to a texture.
GetNativeTexturePtr Retrieve native ('hardware') pointer to a texture.

Static Functions

Destroy Removes a gameobject, component or asset.
DestroyImmediate Destroys the object obj immediately. You are strongly recommended to use Destroy instead.
DontDestroyOnLoad Makes the object target not be destroyed automatically when loading a new scene.
FindObjectOfType Returns the first active loaded object of Type type.
FindObjectsOfType Returns a list of all active loaded objects of Type type.
Instantiate Clones the object original and returns the clone.
SetGlobalAnisotropicFilteringLimits Sets Anisotropic limits.

Operators

bool Does the object exist?
operator != Compares if two objects refer to a different object.
operator == Compares if two objects refer to the same.