Class BasisEncoder¶
Namespace: Apogee.Content.Import
Assembly: Apogee.Content.dll
Encodes an RGBA8 texture and its mip chain as UASTC in a KTX 2 file, with libktx's Basis Universal encoder: the blocks go through RDO (rate-distortion optimization, which makes them compress better) and the levels are supercompressed with zstd. A color or data texture and a normal map get different settings: normal maps skip RDO and take a slower, more accurate encoder level, because errors in a normal are visible as lighting noise. Normal maps stay RGB (libktx's own "normal map" mode would keep two channels as RRRG, which the shaders do not read). The encoder is slow, which is what the import cache is for; it is deterministic.
public static class BasisEncoder
Inheritance¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Fields¶
MinimumSize¶
The smallest side a texture is compressed at: UASTC works in 4x4 blocks, and a smaller texture would only grow.
public const int MinimumSize = 4
Field Value¶
Settings¶
What the encoder does, for the import key: change it and the textures are imported again.
public const string Settings = "uastc color level 2 rdo 1.0 / normal level 3 no rdo / zstd 18 / ktx 4.4.2"
Field Value¶
Methods¶
Encode(TextureData, bool)¶
public static byte[] Encode(TextureData texture, bool normalMap)
Parameters¶
texture TextureData
normalMap bool
Returns¶
byte[]
Exceptions¶
The texture is not RGBA8 or its levels are not the sizes of a mip chain, or the encoder failed.