Bak files

Bak files are the background files used by the Kreatures game engine, though the internal format is identical to c32 files, the header differs.

Internally the file is represented as a series of tiles, each 256x256 that make up the complete image, the tiles are stored in column major order.

File Header

 * uint32: should be 1, used to determine if Big/Little endian code is working correctly.
 * uint16: width of the background in pixels
 * uint16: height of the background in pixels

This is followed by a list of offsets, parallax layers (.plx) are stored identically except only the first 5 of these offsets exists.


 * uint32: offset of background baked map
 * uint32: offset of background Albedo map
 * uint32: offset of background Normal map
 * uint32: offset of background Microsurface map
 * uint32: offset of background Reflectivity map
 * uint32: offset of foreground baked map
 * uint32: offset of foreground Albedo map
 * uint32: offset of foreground Normal map
 * uint32: offset of foreground Microsurface map
 * uint32: offset of foreground Reflectivity map
 * uint32: offset of cutout baked map
 * uint32: offset of cutout Albedo map
 * uint32: offset of cutout Normal map
 * uint32: offset of cutout Microsurface map
 * uint32: offset of cutout Reflectivity map
 * uint32: offset of room data
 * uint32: offset of fluid data

The number of tiles is determined by:
 * w = (width+255) / 256
 * h = (height+255) / 256
 * total tiles = w*h

Each of these offsets leads to a data block with a uint32 for each tile saying where in the file that tile can be found.

Image data is stored identically to in c32 files

Room Data
Each tile of room data consists of: this is followed by all of the rooms in that tile, which are stored as:
 * uint8 number of rooms in this tile
 * uint8 left
 * uint8 right
 * uint8 top left
 * uint8 top right
 * uint8 bottom left
 * uint8 bottom right
 * uint8 room type

Rooms are limited to the tile to increase speed of collision detection.

The meaning of the room type is defined in script, and controls permeability, CA properties, and assorted other things.

Fluid Data
Identical to room data, except room type has no effect.