BFRES (File Format)/Switch: Difference between revisions

From Wexos's Wiki
Jump to navigationJump to search
(Imported from avsys wiki)
 
Line 2,485: Line 2,485:
* [[F-ZERO 99]]
* [[F-ZERO 99]]
* [[Kirby's Dream Buffet]]
* [[Kirby's Dream Buffet]]
* [[Paper Mario: The Thousand-Year Door]] (Nintendo Switch)
* [[Pokémon Scarlet]]
* [[Pokémon Scarlet]]
* [[Pokémon Violet]]
* [[Pokémon Violet]]

Revision as of 14:44, 23 May 2024

BFRES (Binary caFe RESources) is a file format used on the Nintendo Switch. It contains model data, texture data, animation data and shader data.

File Format

Header

The file format starts with the following header:

Offset Type Description
0x00 Char[8] File magic. Always FRES in ASCII, or 46 52 45 53 20 20 20 20.
0x08 UInt32 Version number.
0x0C UInt16 Byte-order-mark. FE FF for big endian, FF FE for little endian.
0x0E Byte Alignment shift. 2 raised by this value is the alignment required by this file when loaded into memory.
0x0F Byte Target address size. Size of a pointer in bits. Never set and therefore remains 0.
0x10 UInt32 File name offset. Points directly to the string, and not to the length unlike all other strings.
0x14 UInt16 A flag which is only used on runtime. One bit sets whether the file is relocated.
0x16 UInt16 Offset to the first section.
0x18 UInt32 Relocation table offset.
0x1C UInt32 Size of the file in bytes.
0x20 Int64 Name offset. The name of this file. Points to the same string as at 0x10.
0x28 Int64 FMDL array offset.
0x30 Int64 FMDL dictionary offset. Points to a dictionary containing the FMDL names.
If version ≥ 9.0.0
0x38 Byte[0x20] Reserved.
0x58 Int64 FSKA array offset.
0x60 Int64 FSKA dictionary offset. Points to a dictionary containing the FSKA names.
0x68 Int64 FMAA array offset.
0x70 Int64 FMAA dictionary offset. Points to a dictionary containing the FMAA names.
0x78 Int64 FBVS array offset.
0x80 Int64 FBVS dictionary offset. Points to a dictionary containing the FBVS names.
0x88 Int64 FSHA array offset.
0x90 Int64 FSHA dictionary offset. Points to a dictionary containing the FSHA names.
0x98 Int64 FSCN array offset.
0xA0 Int64 FSCN dictionary offset. Points to a dictionary containing the FSCN names.
0xA8 Int64 Buffer memory pool offset. Points to the memory pool where all model buffers are stored.
0xB0 Int64 Buffer memory pool info offset. Points to a structure containing information about the memory pool.
0xB8 Int64 Embedded files array offset.
0xC0 Int64 Embedded file dictionary offset. Points to a dictionary containing the external file names.
0xC8 UInt64 User pointer, set at runtime.
0xD0 Int64 String table offset.
0xD8 UInt32 Size of the string table in bytes.
0xDC UInt16 Number of FMDL sub files.
0xDE Byte[4] Reserved.
0xE2 UInt16 Number of FSKA sub files.
0xE4 UInt16 Number of FMAA sub files.
0xE6 UInt16 Number of FBVS sub files.
0xE8 UInt16 Number of FSHA sub files.
0xEA UInt16 Number of FSCN sub files.
0xEC UInt16 Number of embedded files.
0xEE Byte[2] Padding.
Else
0x38 Int64 FSKA array offset.
0x40 Int64 FSKA dictionary offset. Points to a dictionary containing the FSKA names.
0x48 Int64 FMAA array offset.
0x50 Int64 FMAA dictionary offset. Points to a dictionary containing the FMAA names.
0x58 Int64 FBVS array offset.
0x60 Int64 FBVS dictionary offset. Points to a dictionary containing the FBVS names.
0x68 Int64 FSHA array offset.
0x70 Int64 FSHA dictionary offset. Points to a dictionary containing the FSHA names.
0x78 Int64 FSCN array offset.
0x80 Int64 FSCN dictionary offset. Points to a dictionary containing the FSCN names.
0x88 Int64 Buffer memory pool offset. Points to the memory pool where all model buffers are stored.
0x90 Int64 Buffer memory pool info offset. Points to a structure containing information about the memory pool.
0x98 Int64 Embedded files array offset.
0xA0 Int64 Embedded file dictionary offset. Points to a dictionary containing the external file names.
0xA8 UInt64 User pointer, set at runtime.
0xB0 Int64 String table offset.
0xB8 UInt32 Size of the string table in bytes.
0xBC UInt16 Number of FMDL sub files.
0xBE UInt16 Number of FSKA sub files.
0xC0 UInt16 Number of FMAA sub files.
0xC2 UInt16 Number of FBVS sub files.
0xC4 UInt16 Number of FSHA sub files.
0xC6 UInt16 Number of FSCN sub files.
0xC8 UInt16 Number of embedded files.
0xCA Byte[6] Padding.

Buffer Memory Pool Info

The buffer memory pool info structure contains info about the buffer memory pool. The structure is as follows:

Offset Type Description
0x00 UInt32 Memory pool property.
0x04 UInt32 Size of the memory pool in bytes.
0x08 Int64 Offset to the memory pool. Points directly to the start of the data.
0x10 Byte[16] Reserved.

String Table

The string table is a table where all strings are stored. Each string has first the length written, which is a 16-bit integer, and then the string is stored as a null-terminated string. The string length does not include the null byte, and the 16-bit string length value is always aligned by 2. The string sorting algorithm is unknown.

Offset Type Description
0x00 Char[4] Section magic. Always _STR in ASCII.
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int32 Number of strings stored in the string table. The first string is always an empty string ("") and is not included in this count.

Dictionary

A dictionary (sometimes known as DICT) is a common structure used in many Nintendo formats such as BFRES and BNTX. It is used for fast name look-up, in order to find a specific array item by its name. It starts with the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always _DIC in ASCII. Note that in BFRES this magic is set to 00 00 00 00, most likely due to an export error.
0x04 Int32 Number of entries. This does not include the root entry.

After, the entries are specified. The root entry follows first, then all other entries are stored. Each entry has the following structure:

Offset Type Description
0x00 Int32 Ref bit.
0x04 UInt16[2] Child node indices. First the left node, then the right node.
0x08 Int64 Key offset, which points to the key name this entry stores.

User Data

User data is a common structure used in many Nintendo formats such as BFRES and BNTX. It allows game designers to store generic data into different files, in order to be used by the game. The data can be used for anything, and is not used by the actual data parser. Each entry has the following structure:

Offset Type Description
0x00 Int64 Name offset. Points to the name of this user data entry.
0x08 Int64 Data offset. Points to the actual data. What the data actually is depends on the data type.
0x10 Int32 Number of data entries.
0x14 Byte Data type.
Value Data Type
0x00 Int32
0x01 Float
0x02 String
0x03 Byte
0x15 Byte[43] Reserved.

Relocation Table

Offset Type Description
0x00 Char[4] Section magic. Always _RLT in ASCII.
0x04 UInt32 Table offset. The offset where this table starts.
0x08 Int32 Number of sections.
0x0C Byte[4] Padding.
Offset Type Description
0x00 Int64 Section pointer, set on runtime.
0x08 UInt32 Section offset.
0x0C UInt32 Section size.
0x10 UInt32 Entry ID.
0x14 UInt32 Number of entries.
Offset Type Description
0x00 UInt32 Entry offset.
0x04 UInt16 Array count.
0x06 Byte Offset count.
0x07 Byte Padding size.

Animation Curve

An animation curve is a common structure used in all animation sub files, which sets curve data for specific target type. Each entry has the following structure:

Offset Type Description
0x00 Int64 Key data offset. Points to the key data.
0x08 Int64 Frame data offset. Points to the frame value data.
0x10 UInt16 Flag. xxAA xxBB xCCC DDEE.
  • A: Post wrap mode.
Value Description
0x00 Clamp
0x01 Repeat
0x02 Mirror
0x03 Relative repeat
  • B: Pre wrap mode, same options as post wrap mode.
  • C: Curve type.
Value Description
0x00 Cubic float
0x01 Linear float
0x02 Baked float
0x04 Step integer
0x05 Baked integer
0x06 Step boolean
0x07 Baked boolean
  • D: Frame value format.
Value Description
0x00 Float
0x01 Int16
0x02 SByte
  • E: Key frame format.
Value Description
0x00 Float
0x01 Fixed point value. 1 bit sign, 10 bit exponent and 5 bit fraction.
0x02 Byte
0x12 UInt16 Number of key frames.
0x14 UInt32 Target offset. Specifies an offset into the base value, and thus specifies what type this structure animates.
0x18 Float Start key. Specifies the first key frame in the array.
0x1C Float End key. Specifies the last key frame in the array.
0x20 Int32/Float Frame data scale. Multiply the frame data values by this value to get the real value. This can both be an Int32 and a float. Not used by all curves.
0x24 Int32/Float Frame data add. After multiplying, add this value to the frame data. This can both be an Int32 and a float. Not used by all curves.
0x28 Float Delta value. Specifies the different between the last frame value and the first one.
0x2C Byte[4] Padding.
Step Curve

A step curve has no interpolations, and therefore only the frame value needs to be stored. Thus only 1 element per key frame is stored.

Linear Curve

A linear curve has linear interpolation, meaning that more data needs to be stored other than the frame value. Two elements are stored per key frame value. If is the first element, the second element, is the key frame and is the following key frame, then , , is the curve between and . For the last key frame is always set to . In practice this means that is the start value and is .

Hermite Curve

A hermite curve has hermite interpolation, which allows for complex curves controlled by two slopes. Four elements are stored per key. If is the first element and the second element and so on, is the key frame and is the following key frame, then , , is the curve between and . is controlled the post-slope of key , and and are controlled by the pre-slope of key .

Calculating the slopes and for key can be done as follows. The derivative of is . Then its known that and . However, since the slopes fit between and , it is necessary to scale the slopes. The curve is made for , but the correct slope value is when . Therefore the slopes need to be divided by , thus, the final calculation is as follows:



Calculating , , and from slopes , , for key frames and , can be done by solving the following equation system. Remember that the slopes need to be multiplied by to fit instead of .

The equation system gives the following unambiguous solution:

FMDL

The FMDL section (caFe MoDeL) stores model data. It contains the vertex data, skeleton data, materials and shape data, split into 4 different sections. Each model has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FMDL in ASCII.
If version ≥ 9.0.0
0x04 Byte[4] Reserved.
0x08 Int64 Name offset. Points to the name of this model.
0x10 Int64 Original path offset. Points to the filename this sub file was created from.
0x18 Int64 FSKL offset.
0x20 Int64 FVTX array offset.
0x28 Int64 FSHP array offset.
0x30 Int64 FSHP dictionary offset.
0x38 Int64 FMAT array offset.
0x40 Byte[8] Reversed.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this model.
0x18 Int64 Original path offset. Points to the filename this sub file was created from.
0x20 Int64 FSKL offset.
0x28 Int64 FVTX array offset.
0x30 Int64 FSHP array offset.
0x38 Int64 FSHP dictionary offset.
0x40 Int64 FMAT array offset.
0x48 Int64 FMAT dictionary offset.
0x50 Int64 User data array offset.
0x58 Int64 User data dictionary offset.
0x60 Int64 User pointer, set at runtime.
0x68 UInt16 Number of FVTXs.
0x6A UInt16 Number of FSHPs.
0x6C UInt16 Number of FMATs.
0x6E UInt16 Number of user datas.
0x70 Int32 Total number of processed vertices.
0x74 Byte[4] Padding.

FVTX

The FVTX section (caFe VerTeX) stores vertex data. The structure is based on two structures, attributes and buffers, which is the base structure of OpenGL vertex data. An attribute is a link into the shader, and the buffers store the actual data. Buffers are split into three different structures, and one buffer can contain multiple attributes. It starts with the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FVTX in ASCII.
If version ≥ 9.0.0
0x04 Byte[4] Reserved.
0x08 Int64 Vertex attribute array offset.
0x10 Int64 Vertex attribute dictionary offset.
0x18 Int64 Memory pool pointer.
0x20 Int64 Vertex buffer array offset.
0x28 Int64 Buffer pointer array offset. Points to an array of Int64s, which is buffer pointers, set at runtime.
0x30 Int64 Vertex buffer info array offset.
0x38 Int64 Vertex buffer info state array offset.
0x40 Int64 User pointer, set at runtime.
0x48 UInt32 Memory pool offset. Points to the start of the buffer data of this section.
0x4C Byte Number of vertex attributes.
0x4D Byte Number of buffers.
0x4E UInt16 Section index.
0x50 UInt32 Vertex count.
0x54 Byte Max number of bone influences per vertex.
0x55 Byte Padding.
0x56 UInt16 Vertex buffer alignment.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Vertex attribute array offset.
0x18 Int64 Vertex attribute dictionary offset.
0x20 Int64 Memory pool pointer.
0x28 Int64 Vertex buffer array offset.
0x30 Int64 Buffer pointer array offset. Points to an array of Int64s, which is buffer pointers, set at runtime.
0x38 Int64 Vertex buffer info array offset.
0x40 Int64 Vertex buffer info state array offset.
0x48 Int64 User pointer, set at runtime.
0x50 UInt32 Memory pool offset. Points to the start of the buffer data of this section.
0x54 Byte Number of vertex attributes.
0x55 Byte Number of buffers.
0x56 UInt16 Section index.
0x58 UInt32 Vertex count.
0x5C Byte Max number of bone influences per vertex.
0x5D Byte[3] Padding.

Vertex Attribute

Offset Type Description
0x00 Int64 Target name offset.
0x08 UInt32 Vertex buffer format. Specifies how the data is stored.
0x0C UInt16 Buffer offset. Offset into the linked buffer, where the data of this attribute is stored.
0x0E Byte Buffer index.
If version ≥ 9.0.0
0x0F Byte Flag. xxxx xxxA:
  • A: contains dynamic vertex buffer
Else
0x0F Byte Padding.

Vertex Buffer

Offset Type Description
0x00 Byte Buffer state.
0x01 Byte Buffer flag.
0x02 Byte[6] Reserved.
0x08 Int64 Nvn buffer offset, set at runtime.
0x10 Byte[48] Nvn buffer.
0x40 Int64 User pointer, set at runtime.

Vertex Buffer Info

Offset Type Description
0x00 UInt32 Buffer size. Size of the buffer in bytes.
0x04 UInt32 GPU access flag.
0x08 Byte[8] Reserved.

Vertex Buffer Info State

Offset Type Description
0x00 UInt32 Buffer stride. Stride of the buffer in bytes.
0x04 UInt32 Buffer divisor.
0x08 Byte[8] Reserved.

FSKL

The FSKL section (caFe SKeLeton) stores data about the skeleton, used for rigging. The skeleton root has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FSKL in ASCII.
If version ≥ 9.0.0
0x04 UInt32 Flag: xxxx xxxx xxxx xxxx xxAA xxBB CCxx xxDD.
  • A: Rotation mode. Quaternion = 0, Euler XYZ = 1
  • B: Scale mode. None = 0, Standard = 1, Maya = 2, Softimage = 3
  • C: Mirroring mode. X = 0, XY = 1, XZ = 2 (8.0.0.0)
  • D: Reset guard. None = 0, User Pointer = 1
0x08 Int64 Bone dictionary offset.
0x10 Int64 Bone array offset.
0x18 Int64 Bone index table offset. Points to an array of UInt16s.
0x20 Int64 Matrix offset. Points to an array of 3x4 float inverse transformation matrices, which is used for smooth skinning.
0x28 Int64 User pointer.
0x30 Int64 Mirroring bone table offset. Correspondence table between bone indexes and mirrored bone indexes, stored as Int16s. Only seen as 0.
0x38 UInt16 Number of bones.
0x3A UInt16 Number of bones which are smooth.
0x3C UInt16 Number of bones which are rigid.
0x3E Byte[2] Padding.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Bone dictionary offset.
0x18 Int64 Bone array offset.
0x20 Int64 Bone index table offset. Points to an array of UInt16s.
0x28 Int64 Matrix offset. Points to an array of 3x4 float inverse transformation matrices, which is used for smooth skinning.
0x30 Int64 User pointer, set at runtime.
If version ≥ 8.0.0
0x38 Byte[16] Unknown.
0x48 UInt32 Flag.
0x4C UInt16 Number of bones.
0x4E UInt16 Number of bones which are smooth.
0x50 UInt16 Number of bones which are rigid.
0x52 Byte[6] Padding.
Else
0x38 UInt32 Flag.
0x3C UInt16 Number of bones.
0x3E UInt16 Number of bones which are smooth.
0x40 UInt16 Number of bones which are rigid.
0x42 Byte[6] Padding.

Bone

Each bone has the following structure:

Offset Type Description
0x00 Int64 Bone name offset.
0x08 Int64 User data array offset.
0x10 Int64 User data dictionary offset.
If version ≥ 8.0.0
0x18 Byte[16] Reserved.
0x28 UInt16 Bone index.
0x2A Int16 Parent bone index. -1 if no parent exists.
0x2C Int16 Smooth bone index.
0x2E Int16 Rigid bone index.
0x30 Int16 Billboard index.
0x32 UInt16 Number of user datas.
0x34 UInt32 Flag: AAAA ABBB Bxxx xCCC xxxD xxxx xxxx xxxx.
  • A: Specifies the hierarchy transform mode.
ID Description
0x00 None
0x01 Scale uniform
0x02 Scale volume one
0x04 No rotation
0x08 No translation
  • B: Specifies the transform mode.
ID Description
0x00 None
0x01 Segment scale compensate
0x02 Scale uniform
0x04 Scale volume one
0x08 No rotation
0x10 No translation
  • C: Billboard mode.
ID Description
0x00 None
0x01 Child
0x02 World view vector
0x03 World view point
0x04 Screen view vector
0x05 Screen view point
0x06 Y-axis view vector
0x07 Y-axis view point
  • D: Specifies if this bone is visible.
0x38 Float[3] Scale of this bone.
0x44 Float[4] Rotation of this bone.
0x54 Float[3] Translation of this bone.
Else
0x18 UInt16 Bone index.
0x1A Int16 Parent bone index.
0x1C Int16 Smooth bone index.
0x1E Int16 Rigid bone index.
0x20 Int16 Billboard index.
0x22 UInt16 Number of user datas.
0x24 UInt32 Flag.
0x28 Float[3] Scale of this bone.
0x34 Float[4] Rotation of this bone.
0x44 Float[3] Translation of this bone.

FMAT

The FMAT section (caFe MATerial) contains information about how the objects should be rendered. It contains lots of different parameters, which is used in the shader, as well as texture references, and texture samples. Each material has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FMAT in ASCII.
If version ≥ 9.0.0
0x04 UInt32 Flag: xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxA.
  • A: Specifies if the material is visible.
0x08 Int64 Material name offset.
0x10 Int64 Render info array offset.
0x18 Int64 Render info dictionary offset.
0x20 Int64 Shader assign offset.
0x28 Int64 Texture pointer array offset. Points to an array of Int64s that are set at runtime.
0x30 Int64 Texture name offset array offset. Points to an array of name offsets, which are the texture names.
0x38 Int64 Texture sampler array offset.
0x40 Int64 Texture sampler info array offset.
0x48 Int64 Texture sampler info dictionary offset.
0x50 Int64 Shader parameter array offset.
0x58 Int64 Shader parameter dictionary offset.
0x60 Int64 Shader parameter data offset. Points to the start of the data used in all shader parameters.
0x68 Int64 User data array offset.
0x70 Int64 User data dictionary offset.
0x78 Int64 Volatile flag offset. Points to an array of booleans, which has the size as the number of shader parameters. The booleans are ordered from LSB to MSB.
0x80 Int64 User pointer, set at runtime.
0x88 Int64 Sampler slot pointer array offset. Points to an array of Int64s, which are sampler slots pointers set at runtime. The pointers are set to -1.
0x90 Int64 Texture slot pointer array offset. Points to an array of Int64s, which are texture slots pointers set at runtime. The pointers are set to -1.
0x98 UInt16 Section index.
0x9A UInt16 Number of render infos.
0x9C Byte Number of texture samples. This count also specifies the number of texture sampler info.
0x9D Byte Number of textures.
0x9E UInt16 Number of shader parameters.
0xA0 UInt16 Number of shader parameters which are volatile. Unknown usage, only seen as 0.
0xA2 UInt16 Total size of the shader parameter data.
0xA4 UInt16 Raw shader parameter size. Unknown, only seen as 0.
0xA6 UInt16 Number of user datas.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Material name offset.
0x18 Int64 Render info array offset.
0x20 Int64 Render info dictionary offset.
0x28 Int64 Shader assign offset.
0x30 Int64 Texture pointer array offset. Points to an array of Int64s that are set at runtime.
0x38 Int64 Texture name offset array offset. Points to an array of name offsets, which are the texture names.
0x40 Int64 Texture sampler array offset.
0x48 Int64 Texture sampler info array offset.
0x50 Int64 Texture sampler info dictionary offset.
0x58 Int64 Shader parameter array offset.
0x60 Int64 Shader parameter dictionary offset.
0x68 Int64 Shader parameter data offset. Points to the start of the data used in all shader parameters.
0x70 Int64 User data array offset.
0x78 Int64 User data dictionary offset.
0x80 Int64 Volatile flag offset. Points to an array of booleans, which has the size as the number of shader parameters. The booleans are ordered from LSB to MSB.
0x88 Int64 User pointer, set at runtime.
0x90 Int64 Sampler slot pointer array offset. Points to an array of Int64s, which are sampler slots pointers set at runtime. The pointers are set to -1.
0x98 Int64 Texture slot pointer array offset. Points to an array of Int64s, which are texture slots pointers set at runtime. The pointers are set to -1.
0xA0 UInt32 Flag.
0xA4 UInt16 Section index.
0xA6 UInt16 Number of render infos.
0xA8 Byte Number of texture samples. This count also specifies the number of texture sampler info.
0xA9 Byte Number of textures.
0xAA UInt16 Number of shader parameters.
0xAC UInt16 Number of shader parameters which are volatile. Unknown usage, only seen as 0.
0xAE UInt16 Total size of the shader parameter data.
0xB0 UInt16 Raw shader parameter size. Unknown, only seen as 0.
0xB2 UInt16 Number of user datas.
0xB4 Byte[4] Padding.

Render Info

The render info structure specifies basic OpenGL settings, such as culling. It can also be used as uniforms in a shader, but exactly how that works is unknown. Each entry has the following structure:

Offset Type Description
0x00 Int64 Parameter name offset.
0x08 Int64 Data offset.
0x10 UInt16 Number of entries in the data.
0x12 Byte Data type.
ID Description
0x00 Int32
0x01 Float
0x02 String
0x13 Byte[5] Padding.

Shader Assign

The shader assign structure is the link between the shader and the data in the model. It links the vertex attributes in FVTX to the vertex shader, the texture samplers to the fragment shader, and also specifies shader options used for shader variants. It has the following structure:

Offset Type Description
0x00 Int64 Shader archive name offset.
0x08 Int64 Shading model name offset.
0x10 Int64 Attribute array offset. Points an array of Int64s which points to the names of the vertex attributes.
0x18 Int64 Attribute dictionary offset. Points to a dictionary which contains the shader attributes which the vertex attributes are linked to.
0x10 Int64 Texture sampler array offset. Points an array of Int64s which points to the texture target of the texture sampler.
0x18 Int64 Texture sampler dictionary offset. Points to a dictionary which contains the shader uniforms which the texture samplers are linked to.
0x20 Int64 Shader option array offset. Points to an array of Int64s which points to the string data of the shader options. Even numeric values are stored as strings.
0x28 Int64 Shader option dictionary offset. Points to a dictionary which contains the shader option names.
0x30 UInt32 Revision. Unknown usage.
0x34 Byte Number of attributes.
0x35 Byte Number of samplers.
0x36 UInt16 Number of shader options.

Texture Sampler

Each texture sampler has the following structure:

Offset Type Description
0x00 Byte Sampler state. 1 if it's initialized.
0x01 Byte Unknown flags.
0x02 Byte[6] Reserved.
0x08 Int64 Nvn sampler pointer, set at runtime.
0x10 Byte[96] Nvn sampler.
0x70 Int64 User pointer, set at runtime.

Texture Sampler Info

Each texture sampler info sets settings for a texture. It has the following structure:

Offset Type Description
0x00 Byte Wrap U.
ID Description
0x00 Repeat
0x01 Mirror
0x02 Clamp
0x03 Clamp to edge
0x04 Mirror once
0x05 Mirror clamp to edge
0x01 Byte Wrap V. Same options as above.
0x02 Byte Wrap W. Same options as above.
0x03 Byte Comparison function.
ID Description
0x00 Never
0x01 Less
0x02 Equal
0x03 Less or equal
0x04 Greater
0x05 Not equal
0x06 Greater or equal
0x07 Always
0x04 Byte Border color type. White = 0, Transparent = 1, Opaque = 2
0x05 Byte Max anisotropy.
ID Description
0x01 Ratio 1 1
0x02 Ratio 2 1
0x04 Ratio 4 1
0x08 Ratio 8 1
0x10 Ratio 16 1
0x06 UInt16 Filter mode. xxxx xxxx xxAA BBCC.
  • A: Shrink filter. Points = 1, Linear = 2
  • B: Expand filter. Points = 1, Linear = 2
  • C: Mipmap filter. None = 0, Points = 1, Linear = 2
0x08 Float Min LOD.
0x0C Float Max LOD.
0x10 Float Load bias.
0x14 Byte[12] Reserved.

Shader Parameter

A shader parameter is a uniform variable which is loaded into the shader, into any of the stages. Each parameter has the following structure:

Offset Type Description
0x00 Int64 Callback pointer, set at runtime.
0x08 Int64 Parameter name offset.
0x10 Byte Parameter type. See below.
0x11 Byte Data size in bytes.
0x12 UInt16 Data offset, relative to the offset specified in the FMAT header.
0x14 Int32 Offset. Unknown usage. Set to -1 in file.
0x18 UInt16 Depended index.
0x1A UInt16 Depend index.
0x1C Byte[4] Padding.
Parameter types

There are many different types of parameters. A matrix is stored row by row in memory.

ID Size Description
0x00 0x04 Boolean
0x01 0x08 Boolean 2D
0x02 0x0C Boolean 3D
0x03 0x10 Boolean 4D
0x04 0x04 Int32
0x05 0x08 Int32 2D
0x06 0x0C Int32 3D
0x07 0x10 Int32 4D
0x08 0x04 UInt32
0x09 0x08 UInt32 2D
0x0A 0x0C UInt32 3D
0x0B 0x10 UInt32 4D
0x0C 0x04 Float
0x0D 0x08 Float 2D
0x0E 0x0C Float 3D
0x0F 0x10 Float 4D
0x11 0x10 2x2 float matrix
0x12 0x18 2x3 float matrix
0x13 0x20 2x4 float matrix
0x15 0x18 3x2 float matrix
0x16 0x24 3x3 float matrix
0x17 0x30 3x4 float matrix
0x19 0x20 4x2 float matrix
0x1A 0x30 4x3 float matrix
0x1B 0x40 4x4 float matrix
0x1C 0x14 2D SRT
Offset Type Description
0x00 Float[2] Scale.
0x08 Float Rotation.
0x0C Float[2] Translation.
0x1D 0x24 3D SRT
Offset Type Description
0x00 Float[3] Scale.
0x0C Float[3] Rotation.
0x18 Float[3] Translation.
0x1E 0x18 Texture SRT
Offset Type Description
0x00 UInt32 SRT mode. Maya = 0, 3ds Max = 1, Softimage = 2
0x04 Float[2] Scale.
0x0C Float Rotation.
0x10 Float[2] Translation.
0x1F 0x20 Texture SRT with matrix pointer, set at runtime.
Offset Type Description
0x00 UInt32 SRT mode. Maya = 0, 3ds Max = 1, Softimage = 2
0x04 Float[2] Scale.
0x0C Float Rotation.
0x10 Float[2] Translation.
0x18 Int64 Matrix pointer, set at runtime.

FSHP

The FSHP (caFe SHaPe) section stores information about the actual polygon shape. It connects FVTX, FMAT and FSKL in order to create a renderable model. Each shape has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FSHP in ASCII.
If version ≥ 9.0.0
0x04 UInt32 Flags. xxxx xxxx xxxx xxxx xxxx xxxx xxxx xABx.
  • A: Specifies if the sub meshes boundary are consistent.
  • B: Specifies if the shape has a vertex buffer.
0x08 Int64 Shape name offset.
0x10 Int64 FVTX offset. Points to the vertex buffer used by this shape.
0x18 Int64 LOD mesh array offset.
0x20 Int64 Skin bone index array offset. Points to an array of UInt16s which represents the skinning indices of the bones used by this shape.
0x28 Int64 Key shape array offset.
0x30 Int64 Key shape dictionary offset.
0x38 Int64 Bounding array offset. The number of boundings is calculated by taking the total amount of sub meshes in each LOD mesh, and then adding one more for each LOD mesh.
0x40 Int64 Radius array offset. Points to an array of floats, where each float is the radius of a spherical bounding box. The number of floats is the same as the number of LOD meshes.
0x48 Int64 User pointer, set at runtime.
0x50 UInt16 Section index.
0x52 UInt16 FMAT index.
0x54 UInt16 FSKL bone index. The shape is only influenced by this bone if the max number of bone influences is 0.
0x56 UInt16 FVTX index.
0x58 UInt16 Number of skin bone indices.
0x5A Byte Max number of bone influences per vertex.
0x5B Byte Number of LOD meshes.
0x5C Byte Number of key shapes.
0x5D Byte Target attribute count.
0x5E Byte[2] Padding.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Shape name offset.
0x18 Int64 FVTX offset. Points to the vertex buffer used by this shape.
0x20 Int64 LOD mesh array offset.
0x28 Int64 Skin bone index array offset. Points to an array of UInt16s which represents the skinning indices of the bones used by this shape.
0x30 Int64 Key shape array offset.
0x38 Int64 Key shape dictionary offset.
0x40 Int64 Bounding array offset. The number of boundings is calculated by taking the total amount of sub meshes in each LOD mesh, and then adding one more for each LOD mesh.
0x48 Int64 Radius array offset. Points to an array of floats, where each float is the radius of a spherical bounding box. The number of floats is the same as the number of LOD meshes.
0x50 Int64 User pointer, set at runtime.
0x58 UInt32 Flags.
0x5C UInt16 Section index.
0x5E UInt16 FMAT index.
0x60 UInt16 FSKL bone index. The shape is only influenced by this bone if the max number of bone influences is 0.
0x62 UInt16 FVTX index.
0x64 UInt16 Number of skin bone indices.
0x66 Byte Max number of bone influences per vertex.
0x67 Byte Number of LOD meshes.
0x68 Byte Number of key shapes.
0x69 Byte Target attribute count.
0x6A Byte[6] Padding.

LOD Mesh

A shape can have different level-of-detail meshes, which are drawn at different distances. LOD meshes decreases load on the GPU, since it can draw less primitives, but also increases memory usage. Each mesh has the following structure:

Offset Type Description
0x00 Int64 Sub mesh array offset.
0x08 Int64 Memory pool pointer, set at runtime.
0x10 Int64 Index buffer offset.
0x18 Int64 Index buffer info offset.
0x20 UInt32 Memory pool offset. Points to the start of the index buffer data.
0x24 UInt32 Primitive type which is used to draw either points, lines or triangles.
ID Description
0x00 Points
0x01 Lines
0x02 Line strip
0x03 Traingles
0x04 Triangle strip
0x05 Lines adjacency
0x06 Line strip adjacency
0x07 Triangles adjacency
0x08 Triangle strip adjacency
0x09 Patch list
0x28 UInt32 Index buffer data format.
ID Description
0x00 Byte
0x01 UInt16
0x02 UInt32
0x2C UInt32 Total number of points that can be drawn.
0x30 UInt32 Offset into the vertex buffers to start.
0x34 UInt16 Number of sub meshes.
0x36 Byte[2] Padding.
Sub Mesh

A sub mesh is used to draw a specific part of a mesh. It can either draw the full mesh, or a part of it which can be used if specific parts isn't visible in specific areas. Each entry has the following structure:

Offset Type Description
0x00 UInt32 Offset into the index buffer, in bytes, where to draw.
0x04 UInt32 Number of points to draw, starting at offset.

Key Shape

The key shape structure is very unknown. It seems to be used for FSHA shape animations. Each entry has the following structure:

Offset Type Description
0x00 Byte Target attribute position index.
0x01 Byte Target attribute normal index.
0x02 Byte[4] Target attribute tangent indices.
0x06 Byte[4] Target attribute binormal indices.
0x0A Byte[8] Target attribute color indices.
0x12 Byte[2] Padding.

Bounding

Each bounding specifies a AABB (axis-aligned bounding box) and has the following structure:

Offset Type Description
0x00 Float[3] Center position of the AABB.
0x0C Float[3] Extend vector of the AABB. Specifies the vector from the center to the corner where X, Y, Z are larger than center.

FSKA

The FSKA section (caFe SKeleton Animation) stores skeleton animations. Each animation has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FSKA in ASCII.
If version ≥ 9.0.0
0x04 UInt32 Flag. xxxx xxxx xxxx xxxx xxxA xxBB xxxx xCxD:
  • A: Rotation mode.
Value Description
0x00 Quaternion
0x01 Euler XYZ
  • B: Scale mode.
Value Description
0x00 None
0x01 Standard
0x02 Maya
0x03 Softimage
  • C: Loop flag, 1 if animation loops.
  • D: Baked flag, 1 if curve data is baked.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Original path offset. Points to the filename this sub file was created from.
0x18 Int64 FSKL offset. Points to the skeleton which will be animated. Set at runtime.
0x20 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x28 Int64 Bone animation array offset.
0x30 Int64 User data array offset.
0x38 Int64 User data dictionary offset.
0x40 Int32 Number of frames.
0x44 Int32 Total number of curves in this animation.
0x48 UInt32 Baked size.
0x4C UInt16 Number of bone animations.
0x4E UInt16 Number of user datas.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Original path offset. Points to the filename this sub file was created from.
0x20 Int64 FSKL offset. Points to the skeleton which will be animated. Set at runtime.
0x28 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x30 Int64 Bone animation array offset.
0x38 Int64 User data array offset.
0x40 Int64 User data dictionary offset.
0x48 UInt32 Flag.
0x4C Int32 Number of frames.
0x50 Int32 Total number of curves in this animation.
0x54 UInt32 Baked size.
0x58 UInt16 Number of bone animations.
0x5A UInt16 Number of user datas.
0x5C Byte[4] Padding.

Bone Animation

The bone animation structure stores animation data for a specific bone. Each entry has the following structure:

Offset Type Description
0x00 Int64 Name offset. Points to the name of the bone to animate.
0x08 Int64 Animation curve array offset.
0x10 Int64 Bone base value offset. Points to the base values of this bone.
If version ≥ 9.0.0
0x18 Int64 User data array offset.
0x20 Int64 User data dictionary offset.
0x28 UInt32 Flag. xxxx AAAA Axxx xxxx BBBB BBBB BBCD Exxx:
  • A: Transformation types.
Value Description
0x00 None
0x01 Segment scale compensate
0x02 Scale uniform
0x04 Scale volume one
0x08 No rotation
0x10 No translation
  • B: Curve type. Specifies the curve types this animation has.
Value Description
0x01 Scale X
0x02 Scale Y
0x04 Scale Z
0x08 Rotate X
0x10 Rotate Y
0x20 Rotate Z
0x40 Rotate W
0x80 Translate X
0x100 Translate Y
0x200 Translate Z
0x2C Byte Begin rotate. Always 3.
0x2D Byte Begin translate. Always 6.
0x2E Byte Number of animation curves.
0x2F Byte Begin base translate. Always 7.
0x30 Int32 Begin curve. The absolute index of the first curve in all bone animations.
0x34 UInt16 Number of user datas.
0x36 Byte[2] Padding.
Else
0x18 UInt32 Flag.
0x1C Byte Begin rotate. Always 3.
0x1D Byte Begin translate. Always 6.
0x1E Byte Number of animation curves.
0x1F Byte Begin base translate. Always 7.
0x20 Int32 Begin curve. The absolute index of the first curve in all bone animations.
0x24 Byte[4] Padding.

Bone Base Value

Offset Type Description
0x00 Float[3] Base scale.
0x0C Float[3] Base rotation.
0x18 Float[3] Base translation.

FMAA

The FMAA section (caFe MAterial Animation) stores material parameter animations. Each animation has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FMAA in ASCII.
If version ≥ 9.0.0
0x04 UInt16 Flag: xxxx xxxx xxxx xAxB.
  • A: Loop flag, 1 if animation loops.
  • B: Baked flag, 1 if curve data is baked.
0x06 Byte[2] Resereved.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Original path offset. Points to the filename this sub file was created from.
0x18 Int64 Bind FMDL offset, set at runtime. Points to the model affected by this animation.
0x20 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x28 Int64 Material animation array offset.
0x30 Int64 Texture pointer array offset. Points to an array of Int64s that are set at runtime. Used for texture pattern.
0x38 Int64 Texture name offset array offset. Points to an array of name offsets, which are the texture names. Used for texture pattern.
0x40 Int64 User data array offset.
0x48 Int64 User data dictionary offset.
0x50 Int64 Texture slot pointer array offset. Points to an array of Int64s, which are texture slots pointers set at runtime. The pointers are set to -1. Used for texture pattern.
0x58 Int32 Number of frames.
0x5C UInt32 Baked size.
0x60 UInt16 Number of user datas.
0x62 UInt16 Number of material animations.
0x64 UInt16 Total number of curves in all material animations.
0x66 UInt16 Number of shader parameter animations.
0x68 UInt16 Number of texture pattern animations.
0x6A UInt16 Number of material visibility animations.
0x6C UInt16 Number of textures.
0x6E Byte[2] Padding.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Original path offset. Points to the filename this sub file was created from.
0x20 Int64 Bind FMDL offset, set at runtime. Points to the model affected by this animation.
0x28 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x30 Int64 Material animation array offset.
0x38 Int64 Texture pointer array offset. Points to an array of Int64s that are set at runtime. Used for texture pattern.
0x40 Int64 Texture name offset array offset. Points to an array of name offsets, which are the texture names. Used for texture pattern.
0x48 Int64 User data array offset.
0x50 Int64 User data dictionary offset.
0x58 Int64 Texture slot pointer array offset. Points to an array of Int64s, which are texture slots pointers set at runtime. The pointers are set to -1. Used for texture pattern.
0x60 UInt16 Flag.
0x62 UInt16 Number of user datas.
0x64 UInt16 Number of material animations.
0x66 UInt16 Total number of curves in all material animations.
0x68 Int32 Number of frames.
0x6C UInt32 Baked size.
0x70 UInt16 Number of shader parameter animations.
0x72 UInt16 Number of texture pattern animations.
0x74 UInt16 Number of material visibility animations.
0x76 UInt16 Number of textures.

Material Animation

The material animation structure specifies the actual animation and contains the curves. It can contain shader parameter, texture pattern and material visibility animation. Each entry has the following structure:

Offset Type Description
0x00 Int64 Animation name offset.
0x08 Int64 Shader parameter animation info array offset.
0x10 Int64 Texture pattern animation info array offset.
0x18 Int64 Curve array offset.
0x20 Int64 Constant array offset.
0x28 UInt16 Begin shader parameter curve index. Index of the first shader parameter curve.
0x2A UInt16 Begin texture pattern curve index. Index of the first texture pattern curve.
0x2C UInt16 Begin visibility curve index. Index of the first visibility curve.
0x2E UInt16 Visibility curve index. Index of the visibility curve.
0x30 UInt16 Visibility constant index.
0x32 UInt16 Number of shader parameter animations.
0x34 UInt16 Number of texture pattern animations.
0x36 UInt16 Number of constants.
0x38 UInt16 Number of curves.
0x3A Byte[6] Padding.
Shader Parameter Animation Info

Each entry has the following structure:

Offset Type Description
0x00 Int64 Parameter name offset.
0x08 UInt16 Begin curve.
0x0A UInt16 Number of float curves.
0x0C UInt16 Number of integer curves.
0x0E UInt16 Begin constant index. Index of the first constant.
0x10 UInt16 Number of constants.
0x12 UInt16 Sub bind index. Index of the shader parameter into the bonded FMAT.
0x14 Byte[4] Padding.
Texture Pattern Animation Info

Each entry has the following structure:

Offset Type Description
0x00 Int64 Texture target name offset.
0x08 UInt16 Curve index.
0x0A UInt16 Constant index.
0x0C Byte Sub bind index. Index of the texture sampler into the bonded FMAT.
0x0D Byte[3] Padding.
Animation Constant

A constant can be specified for a specific value instead of creating a curve with one key frame. Each entry has the following structure:

Offset Type Description
0x00 UInt32 Target offset.
0x04 Int32/Float Constant value, can either be a float or an Int32.

FBVS

The FBVS section (caFe Bone ViSibility animation) stores bone visibility animations. Each animation has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FBVS in ASCII.
If version ≥ 9.0.0
0x04 UInt16 Flag: xxxx xxxx xxxx xAxB.
  • A: Loop flag, 1 if animation loops.
  • B: Baked flag, 1 if curve data is baked.
0x06 Byte[2] Reserved.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Original path offset. Points to the filename this sub file was created from.
0x18 Int64 Bind FMDL offset, set at runtime. Points to the model affected by this animation.
0x20 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x28 Int64 Curve array offset.
0x30 Int64 Base value offset. Sets the base values for the different curves, where each curve specifies an animation for an bone. The booleans are ordered from LSB to MSB.
0x38 Int64 Bone name array offset. Points to an array of Int64s which points to bone names.
0x40 Int64 User data array offset.
0x48 Int64 User data dictionary offset.
0x50 Int32 Number of frames.
0x54 UInt32 Baked size.
0x58 UInt16 Number of bone animations.
0x5A UInt16 Number of curves.
0x5C UInt16 Number of user datas.
0x5E Byte[2] Padding.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Original path offset. Points to the filename this sub file was created from.
0x20 Int64 Bind FMDL offset, set at runtime. Points to the model affected by this animation.
0x28 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x30 Int64 Curve array offset.
0x38 Int64 Base value offset. Sets the base values for the different curves, where each curve specifies an animation for an bone. The booleans are ordered from LSB to MSB.
0x40 Int64 Bone name array offset. Points to an array of Int64s which points to bone names.
0x48 Int64 User data array offset.
0x50 Int64 User data dictionary offset.
0x58 UInt16 Flag.
0x5A UInt16 Number of user datas.
0x5C Int32 Number of frames.
0x60 UInt16 Number of animations.
0x62 UInt16 Number of curves.
0x64 UInt32 Baked size.

FSHA

The FSHA section (caFe SHApe animation) stores shape animations. Each animation has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FSHA in ASCII.
If version ≥ 9.0.0
0x04 UInt16 Flag: xxxx xxxx xxxx xAxB.
  • A: Loop flag, 1 if animation loops.
  • B: Baked flag, 1 if curve data is baked.
0x06 Byte[2] Reserved.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Original path offset. Points to the filename this sub file was created from.
0x18 Int64 Bind FMDL offset, set at runtime. Points to the model affected by this animation.
0x20 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x28 Int64 Vertex shape animation array offset.
0x30 Int64 User data array offset.
0x38 Int64 User data dictionary offset.
0x40 Int32 Number of frames.
0x44 UInt32 Baked size.
0x48 UInt16 Number of user datas.
0x4A UInt16 Number of vertex shape animations.
0x4C UInt16 Total number of key shape animation infos.
0x4E UInt16 Total number of curves.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Original path offset. Points to the filename this sub file was created from.
0x20 Int64 Bind FMDL offset, set at runtime. Points to the model affected by this animation.
0x28 Int64 Bind index array offset. Points to an array of UInt16s with unknown purpose.
0x30 Int64 Vertex shape animation array offset.
0x38 Int64 User data array offset.
0x40 Int64 User data dictionary offset.
0x48 UInt16 Flag.
0x4A UInt16 Number of user datas.
0x4C UInt16 Number of vertex shape animations.
0x4E UInt16 Total number of key shape animation infos.
0x50 Int32 Number of frames.
0x54 UInt32 Baked size.
0x58 UInt16 Total number of curves.
0x5A Byte[6] Padding.

Vertex Shape Animation

The vertex shape animation structure specifies the actual shape animation. Each entry has the following structure:

Offset Type Description
0x00 Int64 Name offset.
0x08 Int64 Curve array offset.
0x10 Int64 Base values offset. Points to an array of floats, with a lengt of number key shape animation infos - 1.
0x18 Int64 Key shape animation info array offset.
0x20 UInt16 Number of curves.
0x22 UInt16 Number of key shape animation infos.
0x24 Int32 Begin curve.
0x28 Int32 Begin key shape animation info.
0x2C Byte[4] Padding.

Key Shape Animation Info

Each entry has the following structure:

Offset Type Description
0x00 Int64 Name offset.
0x08 Byte Curve index.
0x09 Byte Sub bind index. Unknown meaning.
0x0A Byte[6] Padding.

FSCN

The FSCN section (caFe SCeNe) stores scene animations. Each scene animation can contain three different types of animations, camera, fog and light. Each animation has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FSCN in ASCII.
If version ≥ 9.0.0
0x04 Byte[4] Reserved.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Original path offset. Points to the filename this sub file was created from.
0x18 Int64 FCAM camera animation array offset.
0x20 Int64 FCAM camera animation dictionary offset.
0x28 Int64 FLIT light animation array offset.
0x30 Int64 FLIT light animation dictionary offset.
0x38 Int64 FFOG fog animation array offset.
0x40 Int64 FFOG fog animation dictionary offset.
0x48 Int64 User data array offset.
0x50 Int64 User data dictionary offset.
0x58 UInt16 Number of user datas.
0x5A UInt16 Number of FCAMs.
0x5C UInt16 Number of FLITs.
0x5E UInt16 Number of FFOGs.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Original path offset. Points to the filename this sub file was created from.
0x20 Int64 FCAM camera animation array offset.
0x28 Int64 FCAM camera animation dictionary offset.
0x30 Int64 FLIT light animation array offset.
0x38 Int64 FLIT light animation dictionary offset.
0x40 Int64 FFOG fog animation array offset.
0x48 Int64 FFOG fog animation dictionary offset.
0x50 Int64 User data array offset.
0x58 Int64 User data dictionary offset.
0x60 UInt16 Number of user datas.
0x62 UInt16 Number of FCAMs.
0x64 UInt16 Number of FLITs.
0x66 UInt16 Number of FFOGs.

FCAM

The FCAM section (caFe CAMera) stores camera animation. Each entry has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FCAM in ASCII.
If version ≥ 9.0.0
0x04 UInt16 Flag: xxxx xxxx xAxB xCxD.
  • A: Projection mode.
ID Description
0x00 Orthographical
0x01 Perspective
  • B: Rotation mode.
ID Description
0x00 Aim
0x01 EulerZXY
  • C: Loop flag, 1 if animation loops.
  • D: Baked flag, 1 if curve data is baked.
0x06 Byte[2] Reserved.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Curve array offset.
0x18 Int64 Base value offset.
0x20 Int64 User data array offset.
0x28 Int64 User data dictionary offset.
0x30 Int32 Number of frames.
0x34 UInt32 Baked size.
0x38 UInt16 Number of user datas.
0x3A Byte Number of curves.
0x3B Byte[5] Padding.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Curve array offset.
0x20 Int64 Base value offset.
0x28 Int64 User data array offset.
0x30 Int64 User data dictionary offset.
0x38 UInt16 Flag.
0x3A Byte[2] Padding.
0x3C Int32 Number of frames.
0x40 Byte Number of curves.
0x41 Byte Padding.
0x42 UInt16 Number of user datas.
0x44 UInt32 Baked size.

Camera Animation Base Value

The base values for a camera animation has the following structure:

Offset Type Description
0x00 Float Base near Z.
0x04 Float Base far Z.
0x08 Float Base aspect.
0x0C Float Base height or fovy.
0x10 Float[3] Base position.
0x1C Float[3] Base aim or rotation.
0x28 Float Base twist.

FLIT

The FLIT section (caFe LIghT) stores light animation. Each entry has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FLIT in ASCII.
If version ≥ 9.0.0
0x04 UInt16 Flag: ABCD EFGH xxxx xIxJ.
  • A: Specifies if base color 1 is used.
  • B: Specifies if base color 0 is used.
  • C: Specifies if the base angle attenuation is used.
  • D: Specifies if the base distance attenuation is used.
  • E: Specifies if base direction is used.
  • F: Specifies if the base position is used.
  • G: Specifies if the base enabled is used.
  • H: Specifies if the curves are enabled.
  • I: Loop flag, 1 if animation loops.
  • J: Baked flag, 1 if curve data is baked.
0x06 Byte[2] Reserved.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Curve array offset.
0x18 Int64 Base value offset.
0x20 Int64 User data array offset.
0x28 Int64 User data dictionary offset.
0x30 Int64 Light type name offset.
0x38 Int64 Distance attenuation function name offset.
0x40 Int64 Angle attenuation function name offset.
0x48 Int32 Number of frames.
0x4C UInt32 Baked size.
0x50 UInt16 Number of user datas.
0x52 Byte Number of curves.
0x53 SByte Light type index.
0x54 SByte Distance attenuation function index.
0x55 SByte Angle attenuation function index.
0x56 Byte[2] Padding.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Curve array offset.
0x20 Int64 Base value offset.
0x28 Int64 User data array offset.
0x30 Int64 User data dictionary offset.
0x38 Int64 Light type name offset.
0x40 Int64 Distance attenuation function name offset.
0x48 Int64 Angle attenuation function name offset.
0x50 UInt16 Flag: ABCD EFGH xxxx xIxJ.
  • A: Specifies if base color 1 is used.
  • B: Specifies if base color 0 is used.
  • C: Specifies if the base angle attenuation is used.
  • D: Specifies if the base distance attenuation is used.
  • E: Specifies if base direction is used.
  • F: Specifies if the base position is used.
  • G: Specifies if the base enabled is used.
  • H: Specifies if the curves are enabled.
  • I: Loop flag, 1 if animation loops.
  • J: Baked flag, 1 if curve data is baked.
0x52 UInt16 Number of user datas.
0x54 Int32 Number of frames.
0x58 Byte Number of curves.
0x59 SByte Light type index.
0x5A SByte Distance attenuation function index.
0x5B SByte Angle attenuation function index.
0x5C UInt32 Baked size.

Light Animation Base Value

All values may not necessary be stored. The base values for a light animation has the following structure:

Offset Type Description
0x00 Int32 Base enabled.
0x04 Float[3] Base position.
0x10 Float[3] Base aim or direction.
0x1C Float[2] Base distance attenuation.
0x24 Float[2] Base angle attenuation.
0x2C Float[3] Base color 0.
0x38 Float[3] Base color 1.

FFOG

The FFOG section (caFe FOG) stores fog animation. Each entry has the following structure:

Offset Type Description
0x00 Char[4] Section magic. Always FFOG in ASCII.
If version ≥ 9.0.0
0x04 UInt16 Flag: xxxx xxxx xxxx xAxB.
  • A: Loop flag, 1 if animation loops.
  • B: Baked flag, 1 if curve data is baked.
0x06 Byte[2] Reserved.
0x08 Int64 Name offset. Points to the name of this animation.
0x10 Int64 Curve array offset.
0x18 Int64 Base value offset.
0x20 Int64 User data array offset.
0x28 Int64 User data dictionary offset.
0x30 Int64 Distance attenuation function name offset.
0x38 Int32 Number of frames.
0x3C UInt32 Baked size.
0x40 UInt16 Number of user datas.
0x42 Byte Number of curves.
0x43 SByte Distance attenuation function index.
0x44 Byte[4] Padding.
Else
0x04 UInt32 Next section offset.
0x08 UInt32 Size of this section in bytes.
0x0C Byte[4] Reserved.
0x10 Int64 Name offset. Points to the name of this animation.
0x18 Int64 Curve array offset.
0x20 Int64 Base value offset.
0x28 Int64 User data array offset.
0x30 Int64 User data dictionary offset.
0x38 Int64 Distance attenuation function name offset.
0x40 UInt16 Flag.
0x42 Byte[2] Padding.
0x44 Int32 Number of frames.
0x48 Byte Number of curves.
0x49 SByte Distance attenuation function index.
0x4A UInt16 Number of user datas.
0x4C UInt32 Baked size.

Fog Animation Base Value

The base values for a fog animation has the following structure:

Offset Type Description
0x00 Float[2] Base distance attenuation.
0x08 Float[3] Base color.

Embedded File

An embedded file can be any file, but usually it is a BNTX texture file or a BFSHA shader file. Each entry has the following structure:

Offset Type Description
0x00 Int64 Data offset. Points to the data.
0x08 UInt32 Data size in bytes.
0x0C Byte[4] Padding.

Version List

Version Found in
5.0.2
5.0.3
8.0.0
8.1.1
8.1.3
  • Nintendo Switch System BIOS (6.0.0 – 6.2.0)
8.2.1
9.0.0
9.1.0
9.1.1
10.0.0

BNTX Version

Most BFRES files contain a BNTX file named textures.bntx. This table shows the relation between BNTX and BFRES versions.

BFRES version BNTX version
5.0.2 – 9.0.0 4.0.0
9.0.0 – 10.0.0 4.1.0

Tools

The following tools can handle BFRES files:

  • (none)