SHP0 (File Format)

From Custom Mario Kart
Jump to navigation Jump to search


This page describes the SHP0 file format, as found within BRRES files. They are used for polygon morphing, a smooth transition from one set of vertices to another, commonly used in flags. Another notable usage is the opening and closing of a Chain Chomp's mouth. Other than vertices, SHP0 can also be used to morph normals and vertex colors. For simplicity, this article only references vertices.

File Format

File Header

Offset Type Description
0x00 String The magic "SHP0" to identify the sub file. See »BRRES Sub Files« for other magics.
0x04 UInt32 Length of the sub file.
0x08 UInt32 Sub file version number. The number of sections (N) is dependent of this version number. See »BRRES Sub Files« for details.
0x0C Int32 Offset to outer BRRES File.
0x10 Int32[N] N section offsets. N is implied in the version number (offset 0x08).
0x10+N*4 Int32 String offset to the name of this sub file. This name equal to the name of the entry name of the BRRES Index Group pointing to this data.
0x14+N*4 End of this header
  • All offsets are relative to the start of the header.
  • Mario Kart Wii uses SHP0 v4 with (N=) 3 sections.
  • The first section points to a BRRES Index Group structure for the data sections.

The meaning of each section is defined by numbers as below:

Section description
0 Animation data
1 Vertex data names
2 Unknown. Not seen in Mario Kart Wii or v4 SHP0's.

SHP0 header

Following the section offsets, there is a MDL0 header structure.

Offset Size Description
0x00 0 String offset to path of file — Unused
0x04 2 Number of animation frames
0x06 2 Size of the vertex data name array
0x08 4 Looping (0x00=disabled 0x01=enabled).

Section Formats

Section 0 - Animation Data

This section contains controllers for the animations. Each controller can contain multiple animations; generally only one animation is used.

Offset Size Description
0x00 4 Four bitflags, add together to enable multiple:
  • 0x01 = Always set
  • 0x02 = Enable position update
  • 0x04 = Enable normal update
  • 0x08 = Enable vertex color update
0x04 4 Name offset. This is the name of the target vertex set.
0x08 2 Index to a section 1 entry
0x0A 2 Number of animation entries (N)
0x0C 4 Animation flags, if the Xth bit (LSB first) is set, the Xth animation entry is a constant float, otherwise it contains a pointer to the actual animation data.
0x10 4 Offset to an index conversion array, whereby each entry is a 2-byte index to an entry in section 1. The Xth entry is used by the Xth animation entry. This table is used to link an animation entry index to the name of the target set of vertices.
0x14 N*4 Offsets to N animation entries, or a float if the corresponding bit in the flags is set.
0x14 + N*4 End of entry/Start of index conversion array

The name offset is relative to the start of the entry, the offsets to the animation entries are relative to the offset address itself.

Animation Entry

Each animation entry contains a collection of key frames that are used to animate an object. It contains a small header, followed by a list of key frames. An animation entry has the following layout:

Offset Size Description
0x00 2 Number of key frames (N)
0x02 2 Padding
0x04 4 A float of the inverse of the number of frames this animation is active (1/X). This value is usually derived from the number of frames of the SHP0 file itself, but this is not obligatory.
0x08 N*12 N key frame entries

The key frames have the following layout:

Offset Size Description
0x00 4 Frame number
0x04 4 Animation value
0x08 4 Slope (Hermite interpolation)

All values are stored as float.

The animation value describes how far the target vertices (the name of the controller) have to be morphed into the destination vertices (the name of this entry). This is a value between 0 and 1.

Section 1 - Vertex Data Names

This section contains a list of pointers, and is referenced by the animations in section 0. Each pointer points to the name of a vertex list in the MDL0.

Example of Usage

A Chain Chomp model with its default vertices (left, wanwan_body), and when a SHP0 morph has been fully applied (right, wanwan5_body)

SHP0 animations are sparsely used in Mario Kart Wii. The most common usage is in waving flags, but a more notable example is the Chain Chomp object making use of SHP0 for opening and closing its mouth. The MDL0 for the Chain Chomp contains two sets of vertices and normals for each polygon to achive this, whereby one of each pair is linked to the polygon itself as default. The pair of vertices belonging to the body have the names wanwan_body (default) and wanwan5_body (mouth open).

To animate the body of the Chain Chomp, a SHP0 is created with an entry (controller) with the name wanwan_body, which references the default set of vertices. An animation with the name wanwan5_body is then added to this entry, which references the set of vertices used for a fully opened mouth. The key frames are used to determine how far the original set of vertices have to be morphed into the target set. A value of 0 equals a closed mouth, 1 equals a fully opened mouth, and 0.5 equals a partly opened mouth. When animated, this leads to the biting animation of the Chain Chomp.


The following tools can handle SHP0 files:


All about BRRES files

BRRES fileIndex GroupSub Files