BTI

From Super Mario Galaxy wiki
Revision as of 19:29, 14 August 2022 by Lord-Giganticus (talk | contribs) (bti added)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

BTI is an image file format similar to TEX0, TPL and BREFT file formats. The only difference is the file header.

File Format

The file format is very simple and starts with a file header followed by the image data. All data is written in big endian.

File Header

The following table shows the file header. It is 0x20 bytes long. There is no magic to identify BTI files, so tools may do some plausibility checks to identify them.

File Header (Table inspired off of this')
Offset Type Description
0x00 Byte Image format
0x01 Byte Enable alpha (0x00 means alpha is disabled, anything higher means alpha is enabled)
0x02 UInt16 Width of the image in pixels
0x04 UInt16 Height of the image in pixels
0x06 Byte Wrap S[1] (0x01 for posteffect.bti, 0x00 for others). Probably repeat, clamp or mirror wraps for U projection maps
0x07 Byte Wrap T[2] (0x01 for posteffect.bti, 0x00 for others). Probably repeat, clamp or mirror wraps for V projection maps
0x08 UInt16 Palette format
0x0A UInt16 Number of palette entries
0x0C UInt32 Offset to palette data, relative to the start of the file header
0x10 Boolean Mipmap Enable Whether the texture will use mipmaps or not
0x11 Boolean EnableEdgeLOD
0x12 Boolean Clamp LOD Bias
0x13 Boolean Max Anisotropy
0x14 Byte Minification filter type
0x15 Byte Magnification filter type
0x16 Byte Min LOD The minimum LOD clamp, scaled by 8. Usually 0 so the 0th Mipmap level is used.
0x17 Byte Max LOD The maximum LOD clamp, scaled by 8. This should practically have the same value as MipmapCount.
0x18 Byte Total number of images, thus number of mipmaps + 1. Apparently unread by the engine itself, it only uses the MipmapEnable flag and the max LOD field.
0x19 Byte Unknown Probably Padding
0x1A UInt16 LOD Bias The LOD bias of the texture, scaled by 100.
0x1C UInt32 Offset to image data, relative to the start of the file header
0x20 End of file header

Palette Data

Image Formats (Table inspired off of this)
ID Name Bits per pixel Block width Block height Block size Type
0x00 I4 4 8 8 32 bytes Gray
0x01 I8 8 8 4 32 bytes Gray
0x02 IA4 8 8 4 32 bytes Gray + Alpha
0x03 IA8 16 4 4 32 bytes Gray + Alpha
0x04 RGB565 16 4 4 32 bytes Color
0x05 RGB5A3 16 4 4 32 bytes Color + Alpha
0x06 RGBA32 32 4 4 64 bytes Color + Alpha
0x08 C4 4 8 8 32 bytes Palette (IA8, RGB565, RGB5A3)
0x09 C8 8 8 4 32 bytes Palette (IA8, RGB565, RGB5A3)
0x0A C14X2 16 4 4 32 bytes Palette (IA8, RGB565, RGB5A3)
0x0E CMPR 4 8 8 32 bytes Color + 1 bit Alpha (compressed)

Tools

Wexos's Toolbox can convert PNG files into BTI images. (Only supports certain pallets.)
Wiimms SZS Tools can convert BTI and PNG images in any direction. It may also convert the image and palette formats and add or remove mipmaps on the fly.
Switch Toolbox can open BTI images and convert them into PNG files.
BTIConv is a cross platform solution to convert BTI and PNG images in any direction. Built in NET 6.0

Libraries

Hack.io.BTI Windows only C# library to help manipulating BTI images