Legacy Documentation: Version 4.6.2
Language: English
Compute Shaders
Graphics Hardware Capabilities and Emulation

Sparse Textures

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

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

See SparseTexture scripting class for more details.

Example Code

A small example usage might be a map-like application that creates a large texture, but only a small camera-visible portion needs to be in memory at any time. As the camera moves, newly visible tiles are loaded, and no longer visible tiles are unloaded.

Sample project: SparseTextureExample.zip. In this example, a simple procedural texture pattern is generated for simplicity. Note that this will need a recent GPU and a DirectX 11.2 (Windows 8.1) system, or using OpenGL with ARB_sparse_texture support.

Compute Shaders
Graphics Hardware Capabilities and Emulation