BREFF (File Format)

From Custom Mario Kart
Jump to navigation Jump to search

Introduction

Read BREFF and BREFT (File Format) for an introduction.

File Format

The Sub File Item explained here points to this structure.

Offset Size Type Description
0x00 0x04 UInt32 Pointer to effect name (calculated at runtime)
0x04 0x04 UInt32 Size of emitter data.
0x08 Start of Emitter data

Emitter

An emitter usually has size 0x14c.

Offset Size Type Description
0x00 0x04 Unknown flags
0x04 0x03 Emit flags
0x07 0x01 Byte Emitter shape
Value Description
0x0 Disc
0x1 Line
0x5 Cube
0x7 Cylinder
0x8 Sphere
0x9 Point
0xA Torus
0x08 0x02 UInt16 Emitter life
0x0a 0x02 UInt16 Particle life. Hardcoded for environment effects.
0x0c 0x01 Byte Particle life random
0x0d 0x01 Bool Inherit child particle translation
0x0e 0x01 Byte Emit interval random
0x0f 0x01 Byte Emit random
0x10 0x04 Float Emission rate. Hardcoded to 0.5 for most environment effects.
0x14 0x02 UInt16 Emit start
0x16 0x02 UInt16 Emit end
0x18 0x02 UInt16 Emit interval
0x1a 0x01 Bool Inherit particle translation
0x1b 0x01 Bool Inherit child emitter translation?
0x1c 0x18 Float[6] Emitter dimensions. The total size is the sum of the radius of the empty inner area and the size of the shape. A point emitter has no dimension settings.
Index Disc Line Cube Cylinder Sphere Torus
0 X-size Length X-size
1 Inner radius X-rotation Y-size Inner radius
2 Angle start Y-rotation Z-size Angle start
3 Angle end Z-rotation Inner radius Angle end
4 Z-size Y-size
5 Z-size
0x34 0x02 UInt16 Emit diversion?
0x36 0x01 Byte Velocity random
0x37 0x01 Byte Momentum random
0x38 0x04 Float Power radiation
0x3c 0x04 Float Power Y-axis value
0x40 0x04 Float Power random
0x44 0x04 Float Power normal
0x48 0x04 Float Diffison emitter normal
0x4c 0x04 Float Power spec
0x50 0x04 Float Diffusion spec
0x54 0x0C Float3 Emission angle
0x60 0x0C Float3 Scale
0x6C 0x0C Float3 Rotation
0x78 0x0C Float3 Translation
0x84 0x01 Byte LOD nearest distance
0x85 0x01 Byte LOD farthest distance
0x86 0x01 Byte LOD minimal emission
0x87 0x01 Byte LOD alpha
0x88 0x04 UInt32 Random seed
0x8C 0x08 Unknown
0x94 0x02 UInt16 Draw flags bitfield, see table below.
0x96 0x01 Byte Alpha comparison 0
0x97 0x01 Byte Alpha comparison 1
0x98 0x01 Byte Alpha compare operation
0x99 0x01 Byte Number of TEV stages
0x9A 0x01 Byte Unknown
0x9B 0x01 Byte Enabled indirect TEV stages (bit X corresponds to indirect stage X)
0x9C 0x04 Byte[4] Texture used by each TEV stage
0xA0 0x10 Byte[4][4] Four color input sources per TEV stage
0xB0 0x14 Byte[4][5] One of the struct below for each TEV stage. For possible values, see Wii Graphics Code.
Offset Size Type Description
0x0 1 Byte Operation
0x1 1 Byte Bias
0x2 1 Byte Scale
0x3 1 Byte Clamp
0x4 1 Byte Out register
0xC4 0x10 Byte[4][4] Four alpha input sources per TEV stage
0xD4 0x14 Byte[4][5] Repeat of 0xB0, but for the alpha TEV stages.
0xE8 0x04 Byte[4] Constant color selectors
0xEC 0x04 Byte[4] Constant alpha selectors
0xF0 0x01 Byte Blend mode type
0xF1 0x01 Byte Blend source factor
0xF2 0x01 Byte Blend destination factor
0xF3 0x01 Byte Blend operation
0xF4 0x08 ColorIn Assigns particle colors to TEV color registers
0xFC 0x08 ColorIn Assigns particle alpha to TEV alpha registers
0x104 0x01 Byte Z-compare function
0x105 0x01 Byte Alpha flick type
Value Description
0 None
1 Triangle
2 Sawtooth 1
3 Sawtooth 2
4 Square
5 Sine
0x106 0x02 Short Alpha flick cycle length
0x107 0x01 Byte Alpha flick max. cycle random deviation
0x108 0x01 Byte Alpha flick amplitude
0x109 0x01 Byte Lighting mode: 0 = off, 1 = simple, 2 = hardware
0x10A 0x01 Byte Lighting type: 0 = none, 1 = ambient, 2 = point
0x10C 0x04 Byte[4] Lighting ambient color
0x110 0x04 Byte[4] Lighting diffuse color
0x114 0x04 Float Lighting radius
0x118 0x0C Float[3] Lighting position
0x124 0x18 Float[2][3] Indirect texture matrix
0x13C 0x01 SByte Indirect texture matrix scale
0x13D 0x01 SByte Piviot X
0x13E 0x01 SByte Piviot Y
0x13F 0x01 Padding
0x140 0x01 Byte Particle type
Value Description
0 Point
1 Line
2 Free
3 Billboard
4 Directional
5 Stripe
6 Smooth stripe
0x141 0x01 Byte Particle type option, see below.
0x142 0x01 Byte Movement direction
Value Description
0 Velocity vector
1 Relative to emitter position
2 Emitter direction
3 Relative to the previous particle
4 Relative to both neighbours (billboard only)
6 Relative to both neighbours (other types)
0x143 0x01 Byte Rotation axis (0 = X, 1 = Y, 2 = Z, 3 = XYZ)
0x144 0x01 Byte

Directional: Y is derived from speed if 1
Smooth stripe: number of tube vertices (min. 3)

0x145 0x01 Byte

Directional: 0 = XY surface, 1 = XZ surface
Smooth stripe: number of interpolation divisions (min. 1)

0x146 0x01 Byte

Directional: convert to billboard if 1.
Stripe and smooth stripe: 1 = connect both ends, 2 = connect newest particle to emitter

0x147 0x01 Padding
0x148 0x04 Float Z-Offset

Draw flag bitfield values

Offset Byte Description
0 0x0001 Enable Z-compare
1 0x0002 Enable Z-update
2 0x0004 Compare alpha before texture
3 0x0008 Disable alpha clipping
4 0x0010 Enable texture 1
5 0x0020 Enable texture 2
6 0x0040 Enable indirect texture
7 0x0080 Project texture 1
8 0x0100 Project texture 2
9 0x0200 Project indirect texture
10 0x0400 Make invisible
11 0x0800 Reverse draw order
12 0x1000 Enable fog
13 0x2000 XYLinkSize
14 0x4000 XYLinkScale

Particle type options

Billboard type

Value Description
0 Normal
1 Y-axis billboard
2 Movement direction axis
3 Normal, no roll

Stripe type

Value Description
0 Normal
1 Cross
2 Always face the screen
3 Tube shaped

Other types

Value Description
0 Normal
1 Cross

Particle

Like the emitter, the particle structure has a UInt32 telling how large this section is.

Offset Size Type Description
0x00 0x04 UInt32 Size of particle data.
0x04 Start of Particle data

Afterwards comes the particle data.

Offset Size Type Description
0x00 0x04 Byte[4] Color1A.
0x04 0x04 Byte[4] Color1B.
0x08 0x04 Byte[4] Color2A.
0x0C 0x04 Byte[4] Color2B.
0x10 0x08 Float[2] Size.
0x18 0x08 Float[2] Scale.
0x20 0x0C Float[3] Rotation.
0x2C 0x08 Float[2] Texture Scale 1.
0x34 0x08 Float[2] Texture Scale 2.
0x3C 0x08 Float[2] Texture Scale 3.
0x44 0x0C Float[3] Texture Rotation.
0x50 0x08 Float[2] Texture Translate 1.
0x58 0x08 Float[2] Texture Translate 2.
0x60 0x08 Float[2] Texture Translate 3.
0x68 0x04 UInt32 mTexture1.
0x6C 0x04 UInt32 mTexture2.
0x70 0x04 UInt32 mTexture3.
0x74 0x02 UInt16 Texture Wrap.
0x76 0x01 Byte Texture Reverse.
0x77 0x01 Byte AlphaCompareRef0.
0x78 0x01 Byte AlphaCompareRef1.
0x79 0x01 Byte Rotate Offset Random 1.
0x7A 0x01 Byte Rotate Offset Random 2.
0x7B 0x01 Byte Rotate Offset Random 3.
0x7C 0x0C Float[3] Rotate Offset.
0x84 0x02 UInt16 L1 = Length of texture reference 1 including the terminating NULL byte.
0x86 L1 String Texture Reference 1 (including a NULL byte).
0x86 + L1 0x02 UInt16 L2 = Length of texture reference 2 including the terminating NULL byte.
0x8C + L1 L2 String Texture Reference 2 (including a NULL byte).
0x8C + L1 + L2 0x02 UInt16 L3 = Length of texture reference 3 including the terminating NULL byte.
0x8E + L1 + L2 L3 String Texture Reference 3 (including a NULL byte).
0x8E + L1 + L2 + L3 End of this structure

Between this and the next structure there might be some padding to make the next structure aligned.

Animation Table

Offset Size Type Description
0x00 0x02 UInt16 A = Particle animation Count.
0x02 0x02 UInt16 PtcllnitTrackCount.
0x04 A * 4 UInt32[A] Pointers to animations, filled in during runtime.
0x04 + A * 4 A * 4 UInt32[A] Animation Sizes.
0x04 + 2(A * 4) 0x02 UInt16 B = Emitter animation Count
0x06 + 2(A * 4) 0x02 UInt16 EmitlnitTrackCount.
0x08 + 2(A * 4) + B * 4 B * 4 UInt32[E] Pointers to animations, filled in during runtime.
0x08 + 2(A * 4) + 2(B * 4) B * 4 UInt32[E] Animation Sizes.
0x08 + 2(A * 4) + 2(B * 4) End of this structure

Animation

Offset Size Type Description
0x00 0x01 Byte Animation identifier. Always 0xAB or 0xAC.
0x01 0x01 Byte Kind Type.
0x02 0x01 Byte Curve Flag.
0x03 0x01 Byte Kind Enable.
Value Description
0 Disabled
1 X
2 Y
3 XY
4 Z
5 XZ
6 YZ
7 XYZ
0x04 0x01 Byte Process Flag.
0x05 0x01 Byte Loop Count.
0x06 0x02 UInt16 Random Seed.
0x08 0x02 UInt16 Frame Count.
0x0A 0x02 UInt16 Padding.
0x0C 0x04 UInt32 KeyTable Size.
0x10 0x04 UInt32 RangeTable Size.
0x14 0x04 UInt32 RandomTable Size.
0x18 0x04 UInt32 NameTable Size.
0x1C 0x04 UInt32 InfoTable Size.
0x20 End of this structure

It seems like the tables contain the actual animation data. The tables comes directly after this section and they appear in the order KeyTable, RangeTable, RandomTable, NameTable and InfoTable.

KeyTable

RangeTable

Offset Size Type Description
0x00 0x02 UInt16 N = Number of entries.
0x02 0x02 UInt16 Padding?
0x04 End of this structure
Offset Size Type Description
0x00 0x04 Float Unknown.
0x04 0x04 Float Unknown.
0x08 0x04 Float Unknown.
0x0C 0x04 Float Unknown.
0x10 End of this structure

RandomTable

Offset Size Type Description
0x00 0x02 UInt16 N = Number of entries.
0x02 0x02 UInt16 Padding?
0x04 End of this structure
Offset Size Type Description
0x00 0x04 UInt32 Unknown.
0x04 End of this structure

NameTable

This table seems to link to one or more sub file item.

Offset Size Type Description
0x00 0x02 UInt16 N = Number of entries.
0x02 0x02 UInt16 Padding?
0x04 N * 0x04 UInt32[N] Padding?
0x04 + N * 0x04 End of this structure

After comes the sub file item name references. All entries comes after each other and after the last, there might be some padding to align the next structure.

Offset Size Type Description
0x00 0x02 UInt16 L = Length of the sub file item name including a NULL byte.
0x02 L String Sub file item name reference (including a NULL byte).
0x02 + L End of this structure

InfoTable

Tools

The following tools can handle BREFF files: