API

Function loadKtx2Texture2DArray

  • Fetch and decode a KTX2 file holding array layers (layerCount >= 1) into a Texture2DArray — the single-file, single-request counterpart to createTexture2DArrayFromUrls, which needs one image per layer. A single-layer container is accepted and yields a one-layer array.

    The array is transcoded to the device's best GPU-compressed format (BC7/ETC2/ASTC) and stays compressed in VRAM, and the container's authored mip chain is uploaded as-is rather than regenerated.

    Like every codec-decoded texture the data is uploaded unflipped with invertY = true (GUIDANCE §8 path 2), unlike createTexture2DArrayFromUrls which flips on upload. No built-in material samples an array, so honour that flag in your own WGSL (v = 1 - v).

    Requires a KTX2 decoder with 2D array support (configure self-hosting via setKtx2DecoderUrl).

    Parameters

    • engine: EngineContext

      Engine context.

    • url: string

      URL of a .ktx2 file whose layers become the array's layers, in order.

    • sRGB: boolean = false

      Select the *-srgb GPU format. Default false, matching loadKtx2Texture2D.

    Returns Promise<Texture2DArray>

    A promise resolving to the populated Texture2DArray.