用户工具

站点工具


侧边栏



Unity3D中文文档

script:unityengine:classes:sparsetexture:sparsetexture

SparseTexture 稀疏贴图

class in UnityEngine/Inherits from: Texture

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

设想一个16384×16384贴图在每像素32位——它可能占用1GB的内存。该贴图分解成矩形“拼贴”,并且每个拼贴也可以存在在内存中或者不存在。你可以在需要时基于该玩家可以在世界空间可视的扇形区域的距离即到相机的距离等加载或不加载这些拼贴。

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

另外,该稀疏贴图就行其他的纹理贴图在着色其中一样——它们可以有mipmaps,可以使用所有的纹理过滤模式,等等。如果你读取一个拼贴是不存在的,你可能获取未定义的结果(在很多GPU中结果是黑色,但这也不一定)。

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.

注意并不是所有的硬件和平台都支持稀疏纹理,因此你在使用它们之前应该检查SystemInfo.supportsSparseTextures。例如,在DirectX系统上它们需求DX11.2(Windows 8.1)和一个相对先进的GPU;并对 OpenGL 要求 ARB_sparse_texture 扩展支持。

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

在创建稀疏贴图之后,使用tileWidth和tileHeight询问该拼贴的尺寸。拼贴的尺寸取决于平台和GPU。

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

使用UpdateTile 或者UpdateTileRaw 去使拼贴存储于内存中并更新它的颜色数据。使用UnloadTile去卸载拼贴。

Variables 变量

isCreatedIs the sparse texture actually created? (Read Only)
稀疏贴图实际上是否已经创建?(只读)
tileHeightGet sparse texture tile height (Read Only).
获取稀疏贴图的拼贴高度(只读)。
tileWidthGet sparse texture tile width (Read Only).
获取稀疏贴图的拼贴宽度(只读)。

Constructors 构造

SparseTextureCreate a sparse texture.
创建稀疏贴图。

Public Functions 公共函数

UnloadTileUnload sparse texture tile.
卸载稀疏贴图拼贴。
UpdateTileUpdate sparse texture tile with color values.
更新稀疏贴图拼贴的颜色值。
UpdateTileRawUpdate sparse texture tile with raw pixel values.
更新稀疏贴图拼贴的原始像素值。
script/unityengine/classes/sparsetexture/sparsetexture.txt · 最后更改: 2016/08/02 05:24 (外部编辑)