Skip to content

Namespace Apogee.Content.Import

Classes

AssetImporter

Turns the assets of a game into the engine's own formats. It is a small registry: each takes some extensions (models, images, shaders…) and writes an artifact for each asset, in res://imported/ beside an index.xml that says which source each came from ( reads it). Artifacts are kept: an asset is imported again only when its key changes, the SHA-256 of the importer's name and fingerprint, the asset's .import.xml settings, the asset, and every file the import read for it (a model's buffers and textures, the modules a shader imports). Artifacts whose source is gone are deleted. Importers run in the order of the list, and a file that an earlier import read (a model's image) is not imported on its own. res:// has to be writable.

Importing also gives assets their UID (): an imported file gets one in its .import.xml (made if there is none), an authored one () in its root, and imported/assets.xml lists them all for . The UID is not part of the key (), so minting one never imports anything again. A UID that is already there is never changed, except to tell a copy from its original.

BasisEncoder

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.

ContentLoader

Loads models and textures the way a game wants them: the imported artifact when there is one (), the source file otherwise. A game that was never imported loads from its sources, so the same call works everywhere. A package's files have artifacts when the package shipped them (it was imported as a folder of its own, its imported/ is at mod://id/imported). It does not check that the artifact is current: importing is the step that does.

ImageImporter

PNG and JPEG images into KTX 2 files with their mip chains, GPU-compressed () unless the settings say otherwise.

ImportContext

An asset being imported: its bytes, its settings, and the files it reads, which become the artifact's dependencies.

ImportEntry

One artifact of the import: the source it came from, what it was made from, and the file.

ImportReport

What did.

ImportResult

What an importer made: the artifact's bytes and the extension that is added to the source's name (.amodel).

ImportSettings

What an <asset>.import.xml file next to an asset says about importing it.

Ktx2Writer

Writes a 2D texture of 8-bit RGBA with its mip chain as a KTX 2 file, uncompressed (supercompressionScheme 0): the header, the level index, a data format descriptor that says what the bytes are (RGBA, sRGB or linear), and the levels, smallest first as the format requires. reads it back; so does any KTX 2 tool. With zstdLevel each level is compressed with zstd (supercompressionScheme 2, which libktx inflates when it loads): the file is smaller, the texture the same. This is not GPU texture compression: the texture is RGBA8 in memory and on the GPU. That is ; this writer is for compression="none" and for textures too small to compress.

ModelFile

The engine's own model file (.amodel): a as it is after import, ready to load without a glTF parser, its files, or any decoding of images. Vertex and index buffers are compressed with meshoptimizer's codecs (lossless: the model comes back bit for bit), textures are embedded KTX 2 files (), the rest is plain little-endian fields. Loading is far faster than reading the glTF, and the file is smaller than the sources it replaces.

ModelImporter

glTF models into s, their textures GPU-compressed unless the settings say otherwise.

ShaderVariant

A shader compiled with one set of preprocessor defines, listed in a shader's .import.xml as <Variant><Define name="" value=""/></Variant>.

Interfaces

IAssetImporter

One kind of asset can turn into an artifact: a name, the extensions it takes, a fingerprint (part of the key, so changing what it writes imports again) and a function from source to artifact. Importers do not touch the index, the keys or the files: they read through , which records what they read.

Enums

AssetStatus

Where one asset stands: what an asset browser shows next to a file.

TextureCompression

How an imported texture is stored: GPU-compressed (Basis Universal UASTC inside KTX 2, transcoded when it is loaded) or as 8-bit RGBA.