BFG (File Format)

From Custom Mario Kart
Jump to navigation Jump to search

BFG (Binary FoG) files are one of the multiple post-effect controllers Mario Kart Wii provides. It controls fog used in tracks, and they appear in the "./posteffect" folder inside U8 files.

File Format

The structure of the file is based in four fog entries, 0x1C (28) bytes long each.

Table showing fog types, with their curve equations
Offset Type Description
0x00 Int32 Fog type:
  • 0x0 = No fog.
  • 0x1 = Perspective projection linear.
  • 0x2 = Perspective projection exponential.
  • 0x3 = Perspective projection exponent squared.
  • 0x4 = Perspective projection inverse exponent.
  • 0x5 = Perspective projection inverse of the square exponent.
  • 0x6 = Orthographic projection linear.
  • 0x7 = Orthographic projection exponential.
  • 0x8 = Orthographic projection exponent squared.
  • 0x9 = Orthographic projection inverse exponent.
  • 0xA = Orthographic projection inverse of the square exponent.
0x04 Float StartZ: stores the Z value where fog generation begins inside the view space.
0x08 Float EndZ: stores the Z value at which fog density is maximum inside the view space.
0x0C Byte[4] Fog color, stored in RGBX format (alpha is ignored).
0x10 UInt16 Fog range correction:
  • 0x0 = Disabled.
  • 0x1 = Enabled.
0x12 UInt16 Maybe center to which the range correction is applied?
0x14 Float Affects the transition speed when swapping fog entries. 1.0 is instant; lower values create longer fades. Whether it affects swapping to this entry, from this entry, or both is unknown.
0x18 UInt16 Unknown. 0 in most Nintendo tracks, 5544 in N64 DK's Jungle Parkway.
0x1A UInt16 Unknown.
0x1C End of fog entry

Usage

Controlling the density of the fog can be a process of trial and error, and it is recommended that you have extracted your iso (link), and boot the game in Dolphin (link) through the main.dol file found in files > race > course, to quickly test the changes that you have made. The settings below are similar to various other Nintendo courses, and is most easily controlled by changing startZ from -10,000 to +10,000. IMAGE HERE https://cdn.discordapp.com/attachments/940631309313785930/983503593208442900/rii_bfg.png The Fade Speed corresponds to 1/x frames to transition. For instance, if you wanted a 2 second (120 frame) transition, you'd want a speed of 1/120 (0.0083). A speed of 0 defaults to a transition of 33 seconds.

Other notes: In the material settings in Brawlcrate or Brawlbox, the fog index should be set to 0, for the material to receive the fog effect as well. Additionally, each bfg entry needs an area to activate it. Below is a picture showing what this AREA could look like within kmp cloud. IMAGE HERE https://cdn.discordapp.com/attachments/940631309313785930/983503566964686878/cloud_area_bfg.png The Type should be type 2 to enable bfg. Additionally, the setting underlined is what determines which bfg the AREA should enable, noting that bfg entries start at 0.

Tools

The following tools can handle BFG files: