Adding Fog Effects to a Course BMD

Fog is an effect that causes course.bmd file geometry to be tinted the further away from the player it is. It does not apply to skyboxes or to certain .bol objects. The limitation on the skybox can be accounted for by making the skybox the same color as the fog or by making it part of the main course.bmd file.

Creating a SuperBMD .bat file
Fog is enabled on a per-material basis in the .bmd. Additionally, by default, SuperBMD will create materials without the fog effect. This means that every material that requires the fog effect will have to have a custom material defined in a material .json file during conversion to .bmd.

Create a .bat file for converting to .bmd using SuperBMD that has, at the very least, the option for a material.json file. At its most basic, this looks like  %1 -m  A bigger list of options can be found in on the Using SuperBMD page.

Creating and editing the material .json
Obtain a materials .json file with every material in the .bmd list. One way to do this is to convert a track to .bmd, then running the newly created .bmd back through SuperBMD to obtain the materials .json file. It will be named _materials.json. In order to not override existing assets, it is best to do this a new folder. The other outputs from the .bmd -> .dae conversion are not relevant for creating the fog effect, and can be deleted.

Towards the bottom of each material's entry in the .json, there will be a structure that defines the fog information. This can be found by searching for "Fog" in a text editor with searching enabled, such as Notepad++. The SuperBMD default material has it defined as such:

"FogInfo": { "Type": 0, "Enable": false, "Center": 0, "StartZ": 0.0, "EndZ": 0.0, "NearZ": 0.0, "FarZ": 0.0, "Color": { "R": 0.0, "G": 0.0, "B": 0.0, "A": 0.0 },

To enable the fog effect, replace that entire structure with: "FogInfo": { "Type": 2, "Enable": false, "Center": 320, "StartZ": 17529.2969, "EndZ": 200000.0, "NearZ": 5.0, "FarZ": 200000.0, "Color": { "R": 1.0, "G": 1.0, "B": 1.0, "A": 1.0 }, in every material where a fog effect is desired. These settings are used in the vanilla Luigi Circuit course.bmd. Once this is done, save the .json, and use it to convert to .bmd using the .bat file described above.

Many .bmd viewers such as noclip.website and J3dView will not render fog, even with the proper settings. Thus, it must be tested in-game.

Editing the BOL
The .bol header contains fog data settings:
 * Fog Type: Must be 0-4
 * Fog Color: Defined by an RGB value
 * Fog Near / Fog Far: Distances from the player at which the fog starts and ends