BFRES Tutorial! Importing Models and Textures!

A Tutorial for Mario Kart 8

Yo, buddy. We are one of the oldest mod sites on the Interwebs. Sign up and maximize your browsing experience.

  • Subscribe: Get notified of new submissions like this.
  • Say Thanks: Show your appreciation by sending KillzXGaming points.
  • Post: Give KillzXGaming your thoughts on this Tutorial.
  • Vote: Help KillzXGaming win the Monthly Awards.
  • Rate: Give this Tutorial a rating out of 10.
  • Flag: Alert moderators and warn members of a problem with this Tutorial.
  • Watch: Get notified when this Tutorial is updated.
Mascot

Interested?

Sign up

Already a Bananite? Login

Updates

New Stuff
  • Added how to make a bfres base higher poly to inject into. (Higher poly character rigs)
  • Added how to have perfect normals using a new tool smb123w64gb made.
Comparisons of using the new tool smd2csv.
 
FunkyKong
Kirby (No more seam around eyes)
Banjo
KillzXGaming avatar
Member Joined 1y
4,213 points Ranked 1084th
21 medals 2 legendary 4 rare
  • Reached 100 subscribers Medal icon
  • 30 submissions featured Medal icon
  • Returned 1000 times Medal icon
  • Reached 50 subscribers Medal icon
  • 10 submissions featured Medal icon
  • Received thanks 50 times Medal icon
KillzXGaming
27d
I decided to make a quick bfres tutorial since it can be quite tricky, and also there is a few errors some people get that i know how to fix. 

This tutorial is primarily focused towards MK8 however can apply to many other games like:
  • LOZ Breath of the Wild
  • Super Mario 3D World
  • Wind Waker
  • And many more! To get particular games working please look below and i will explain!

1. Things we will need for Modeling.

-Wii U zip or Uwizard (to unpack szs files)
-A dump of Mario Kart 8 via DDD or similar. 
-Model Importing script. 
-3DS MAX. Student License is free for 3 years

Lets get to this!

First the locations of things are easy to find. Drivers in the driver folder, karts in the kart folder, ect. However knowing which one is which is kinda hard. 

2. Character List: (Will skip over ones with proper names)

BbDaisy - Baby Daisy
BbLuigi - Baby Luigi
BbMario - Baby Mario
BbPeach - Baby Peach
BbRosetta - Baby Rosalina 
DaisySuit - Biker Daisy
DK - Donkey Kong
Heyho - Shyguy
Jugem - lakitu
Kinopico - Toadette
Kinopio - Toad
Koopa - Bowser
Nokonoko - Koopa
MetalPeachSuit - Biker Metal Peach
PeachSuit - Biker Peach
MiiF - Mii Female
MiiM - Mii Male
Rosetta - Rosalina
RosettaSuit - Biker Rosalina

3. Kart List will come soon.

Select one of these with either uwizard or wii u zip and extract the file. With wii u zip you will get a content.bin. Rename this file to content.bfres. 

Now in 3DS max click MaxScript - Run Script and click on BFRES Script_R4_Debug.ms from the importer. 

Then use this tool by clicking Load BBFRES and select your model you extracted. 



Now click import BFMDL. The dropdown list on the right could have multiple models however isn't too common in mk8 for characters or karts. 

Now lets get started on the model part!

1. Modeling and Skinning!

1.1. Optaining Models

Now you can import any model you'd like! However considering the limitations take note of these things!!!

-Press "7" in 3ds max. This will be the max poly and vert count you can work with for your model you are importing. generally it is around 3k-6k polys. Delete the layer meshes to see the actual amount you will be dealing with. This max count applies per mesh however mk8 really only uses 1 or so main mesh with some smaller ones. Courses or other games ie botw will need to take this into account!
-Karts will need to fit with the original one very well to get both the wheels and character to fit well.
-Characters will need to be aligned well with the original bone set. 

Now that we got that out of the way, here is a good site for models. Models Resource. There is plenty more, though i often rip them myself or google if it has been ripped anywhere else. 

Blender models also work fine, simply export them as an fbx and import into max. 

1.1. UV Layers:

Layer 2 = Shadow Map

Layer 3 = Emblem Map.

UV layers allow the user to edit a completely different UV set without adding any extra polygons nor disturbing the base UVs.

Editing these will come soon, however if you know how to edit UV channels, make sure you check merge UVs first in the importer for editing existing ones or you can make your own. 

1.2. Making a Higher Poly Bfres File. 

This only works in MK8 and a few other games. BOTW will not work!

This can be used to bypass the poly limit of a bfres file to be higher. This however is only ideal for characters, everything not rigged can be done with Wexos Toolbox which will get it's own tutorial soon

First download this script. Extract it in a folder.

Then grab your bfres file and put it in the folder.

Download blender and import the model you want into the program. It does not need to be rigged or anything. This will be how high poly you want the bfres to be. I highly suggest to not go above 15k polys as it may cause lag. 

Then Select your model (must be one model only!) then export as an obj file. If you want eyes to be seperate, you can import those as a second mesh with the model import script later, just need to stay in the poly count for those.

Use these settings. 



Save it where the script is. 

Lastly open cmd in folder by doing this. 

Then type

BFRES_Injector_CMD.exe (bfres name) (obj name).

It will then output a higher poly bfres file to use for the next step once you start injecting the data to the model. 

1.2.1. Rigging and Aligning

So you'll need to first align your model to fit their T pose. I don't wanna go too much into detail as you really need to know the basics of max before doing these kind of things. Here is what it should look like. 



Does not need to be perfect, aslong as it looks good with being animated. 

1.2.2. Getting ready to rig! Attach models and UV Fixes!

First select your model. Before the rigging process, we need to combine all our parts before doing anything else (If your model uses a separate eye texture you can use those for an eye mesh). If your model that your are trying to import is one model/mesh you do not need to do this! This is because of the limited amount of models we have to work with. Right click in the viewport on the model, then click the "Attach" button. 



Then select a model separate from this. Keep doing this till it is one model. Failure to do this can make certain models not show. The importer will only import existing models of the object/character!

Now that we got that done. Rename the object to the same name as the original object. DK's model is called Body__m_Body so i'll rename this new model Body__m_Body. 

Now that we have done this we need to combine all textures into one map. 

Here I have 2 separate textures. 



Lets combine these with a photo editor! Of course all i did was resize canvas to a square size and then added the texture to it. The reason is because DK's main texture is a square and we have to keep the same size as the original. 



Now that this is done lets drag this texture into max!



Oh NO! It looks kinda broken. Well the reason for this is because the UVs stay in the same place so we need to edit them. 

Goto the modifiers tab and add a UV Unwrap modifier like this:



Now click Open UV editor.



We need to fit these UVs so they are with the texture but also in the box. (It has to be in the box or else you will get an error)

Right click and use the "Freeform Gizmo". This tool lets us scale and move the UVs in a very controllable manner. 



Nice we got it! Though separate textures are still not working?



Lets fix this! Select the white box and select the model you separated. It will then highlight the UVs



Remember we need to scale the UV to fit the texture like before! I suggest adding the left hand corner at the corner of the texture  and scale it so it fits. You may need to zoom in with the mouse wheel to get a more accurate look of how it fits. 



Nicely done!  Time for skinning!

1.3. Rigging and skinning a model!

This is VERY important! DO NOT just allign the model and add a skin modifier. You need to weigh everything aswell. Lets get to the basics.

First select your model. Now add a skin modifier. At the end of exporting make sure this is on the top of the list!! You can drag and move modifiers around to order them. 



Now click on the add button. 



The bones in red are important. you may wanna select the ones in light blue but it may not be too noticeable unless you are viewing a replay or something. I suggest choosing all of them unless you model may not work with some bones like fingers, or it doesn't use a Tie. Fingers are alot easier to rig in this game, with them moving 4 fingers at once and then another for the thumb. 

Goahead and set this to frame 1 with autokey enabled. 



What this does is allow your character to stay in T pose in frame 0, and allow you to pose in frame 1. This is extreemly useful for testing your weights and rig. 

Lets gointo wireframe and select a bone!



Now right click and press "Rotate". Rotate the bone a bit like this. 



We got a few messed up areas . This is where weighting comes into play. With the model selected, in the skin modifier click edit envelopes and then check Vertices. 



What this can do is select the verticies that broke, and we can then weigh them to move correctly to a particular bone.

Scroll down and click on the wrench. 



With this tool we can select bones in this list and move vertices towards those bones. 

The way the weight table works. 
  • 1 can make a vertice stay always next to a bone
  • .5 is half to one bone, and to another one. 
  • - and + decreases and increases weight amount of bone selected
  • Blend greatly helps even out weights. I recommend using this alot. Downside however can possibly break some areas. If this happens you can weigh the area to a bone with a value of 1 so they go back together or undo the blend. 

For DK i am going to weigh his body more to the Spine2 bone as that is where the body is.

Though this model is fairly complicated so let me talk about Select Element. This Can select all verticies of a polygon which is basically a group of faces on a mesh. The body can then be entirely selected and i can rig to the Spine2 bone. 



Quick rig for shoulder area!



The rest is up to you! Do this to all bones so it looks good!
I suggest looking online for some other rigging tutorials and guides! I found this one useful!.

1.3.1. Exporting the model data!

First delete any original models that you do not wanna keep. 

At this point make sure ALL fmdl models are imported that you wanna keep. Some will have multiple objects for weapons or other pieces. The model import script has a drop down for you to select other fmdl models to import. 

Instead of using the max script, i will show how to use smd2csv which allows us to have proper normals and no UV seams. 

1.4. Exporting With Proper Normals: SMD2csv

There are multiple ways to do this however i have had the best results with blender to create our .smd file. 

First download blender

Then in 3DS max, export as an fbx.

Open up blender and goto file - import - fbx. Click this and edit the settings to match mine. 



If it ends up being too big in game, set the scale to 1 instead. 



The model should import rotated like this where the grid is on the side similar to how 3DS max is. 

Now i highly suggest selecting all objects with CTRL + A and then joining them with CTRL + J. Then click the Tab key (goes into edit mode) then press W. Remove doubles. 

Now we need to install the plugin. Get it from here

As noted on the page:

  1. Select File > User Preferences
  2. Move to the Addons tab
  3. Click Install From File... in the bottom of the window
  4. Find the downloaded zip file and select it (Double click)
  5. Under 'Categories' on the left, click 'Import-Export'
  6. Find 'Blender Source Tools' in the list and check the box to the right. Wait a moment for activation to complete.
  7. Click Save User Settings and close the window.

So now that we have that installed. Goto the scenes tab. 



Now scoll down. 



Edit the export path to where you want it. Then set the option to SMD from DMX as shown. 

Then after all that, click the Export button. 

Now in that folder, download this and drag it into the same folder. 



Make sure you have python installed. Drag your smd file into smd2csv.py. It should output a .csv file. 

If not then open a cmd in the folder, then type python27 smd2csv.py (smd file)

Now that is all done. Open the csv in notepad. 



You need to edit this back to your object name. 

Blender will show which material is which in the material tab. Alternatively you can see this in 3DS max by going to Rendering - Material Explorer.

Rename this to what your model original name was. 

Characters in MK8 are often

Body__m_Body for body
Body__m_Eye for eyes


Now get the model import script. 

Drag it in there

In the same folder make sure your original bfres model is in there. 

In the folder open cmd  by typing in "cmd" on top box.



Type in:

BFRES_Vertex.py (Name of bfres file).bfres (csv name)



Boom it is done! 
 If you get an error on this part you may have a too high poly of a model. 

Now for the last step! Goto the yaz0fast folder from the model importer and drag the bfres file over to yaz0fast(x64).exe or yaz0fast(x86).exe. Rename the file to the original name of the szs file you extracted, IE DK.szs.

If you have any errors please goto the bottom below where I discuss these. 

2. Course Creation:

Just a note on making courses.
  • Use YazoDec to decompress bfres files. Do not use wii u zip, that can cause crash issues. 
  •  Use wszst to compress courses. This fixes long compress times. Simply goto the bin folder. open cmd in it and type without quotes "wszst.exe compress (bfres name)"
  • Texture editing is the same and model stuff is the same. Stay at polygon count of object replacing. Courses have many objects so you have more freedom on doing these.
  • For advanced usage. Use this template. You can hex edit and do lots of neat edits.
  • Useful blank byaml for a base thanks to MasterFOx
  • Useful byaml editor Ray made for editing object placement and adding them.

I plan on doing a full separate course tutorial soon including lap paths, gravity paths, kcl collision editing, and more.

3. Textures

A character, kart, and and courses are made up of 4 textures. 
Shadow Map
Normal Map
Diffuse Map
Spec Map

These 4 things will need to change in order for your character to look good. 

A shadow map can make something darker or brighter. 
A normal map gives lots of details. Crazybump is great for this!
Diffuse is the main texture you see. 
Specular is the shininess. White is very shiny, black is no shine. 

3.1. GUI Easy Method

3.1.1. Programs Needed:

-Photoshop with DDS plugin, or Paint dot net, or Gimp with DDS plugin or any other photo editor.
-Python 2.7 or higher needed!
-AboodXD BFRES Texture Tool 

With AboodXD's inject pack downloaded. unzip it and click on bfres_tool.exe. This will launch a window. Click file and then open the bfres file. 

You will then see the file format in the cmd. 

Click on the texture you wanna edit and then when saved, it will automatically be added into the bfres file. 

3.2. Manual Way

3.2.1. Programs Needed

-Python 2.7 or higher 
needed!

-Compressonator (Optional but recommended)
-inject Pack
-TexConv2 for inject pack (copyrighted can't link)

For this particular step, you'll need to get the Injectpack above along with a copy TexConv2.

Have your bfres file in the same folder as the inject pack. Now tpye in "cmd" in the file explorer bar on the top. 



You will now have a cmd window open. Now type in this cmd:
Bfres_check.py (BFRES name).bfres

With the name of your bfres filled in of course. 



Take note of the texture numbers extracted



This will come useful after the next step to figure out which texture is what. 
Keep in mind:
Alb = main texture/diffuse
Nrm = Normal Map
Spm = Spec Map

Now drag Convert GTX.bat into the cmd. 

This tells us which format the DDS file is. 



The name of the DDS is in orange. Format in blue. 

Goto OutDDS_Lossless and select the file you want to edit. What is what is on the list from easier. Open these in any photo editor and you can edit away. 

Some Tips

  • Making the shadow map darker can often fix brightness issues.
  • The spec map can make particular areas shiny if you leave particular areas white, and some black. The lighter it is, the more shiny it gets.
  • Facial expressions can be done via textures however only applies to certain characters like villager or toad. Simply replace the original ones with your own. Make sure the UVs fit correctly with your model.

Now that you have your textures edited, time to properly export these.  There will be many ways to go about this, but i will be explaining with Compressonator and also photoshop as I have had the most success for each format using these. 

3.3. Format List:

BC1 = DXT1. Used most often for the main texture.
BC3 = DXT5.  Can also be used for spec maps and sometimes other textures. 
BC4 Used for normal and spec maps
BC5 Used for normal and spec maps

3.3.1. Exporting textures Compressonator

What you wanna do is save every texture you have as a .png file. 
Open your .png in Compressonator.



Click on "Add destination settings"



Choose the format of the DDS according to what was shown by Convert GTX. You then want to select where you put the inject pack and also rename the file so it is just a number like 0.dds and then click save. 

Right click the file and now process with settings.



Should turn green! If not then resave the png in another program  and try again or use a different method.

3.3.2. Exporting textures with photoshop

I will go over one more method and that is using photoshop.

You will need this DDS plugin and this for bc4 and bc5 DDS files.

Simply open the texture you edited. Click "Save As" then choose

 this one if it is BC1 (DXT1) or BC3 (DXT5)



And the intel one if it is BC4 or BC5



Now here is a settings list for these!!!

BC1  DXT1
BC3 DXT5
BC4
BC5

Now for the Final Step!!!!

3.3.3. Finalizing Textures. Inject Time!

Lets do this! Open EasyInject_BFRES.bat with notepad then add the path of Bfres_inject.py from the injectpack like this. 



Now in the cmd from earlier, drag Bfres_inject.py to the cmd and press Enter. Success! The textures are now injected! If you want to do a quick test you can extract them with bfres_check from before and use Convert GTX. If that doesn't crash then it worked!

3.4. Error troubleshoot!

  • E: Unable to convert: undefined to type: Integer (After using the CSVExport.ms script.)

 A: Export the model as an fbx in 3ds max. Open noesis (found here). Right click on the fbx from max, click export. Make the type a fbx file. Open fbx in max, make scale factor one before clicking Ok. Then you should be fine. Rerun the script and it should work! If this still happens make sure your UVs are in the box and polycount is below original amount of the mesh you are putting over.

  • E:  Object does not have all polygons exported?

A: You must stay within the poly limit of that mesh you are putting over or polys may be not be exported. 

  • E:  Object doesn't show in game?

A: Make sure your object has the same name as original. If not, it will not export. Also make sure you model is rigged. Moving the bones should move the model. 

  • E:  BOTW has objects like armor that have hats and lower pieces of that armor set that do not show in game even though i only edited the upper piece
A: BOTW may use multiple BFMDL files. Once you rigged and finished everything, make sure you import all BFMDL files before exporting by selecting each one in the dropdown and clicking import.

  • E: BOTW has duplicating player model pieces when i edit Link's model. 
A: Make sure you edit DefautArmor.sbfres aswell. 

  • E: Super Mario 3D World has glitchy textures for model imports. 
A: use this custom Uwizard build and make the padding to 2000 when rebuilding a szs file. 
  • E: Wind Waker has many bfres files that won't import into max?
A: This is a current issue with the bfres max importer script.
  • E: struct.error: 'H' format requires 0 <= number <= 65535
A: UVs out of box, make sure they stay in this!

  • E:  vertex index face out of range error
A: You model is too high poly! Make sure it matches original model you are replacing or lower.

Todos

Explain materials whenever that gets figured out.

Posts

  • 2d
    Maybe we can finnaly import Bayonetta
    My Neighbor Totoro avatar
    Mantra
    My Neighbor Totoro
  • 26d
    modmaker avatar
    modmaker Offline
    Member Joined 4mo
    195 points Ranked 18096th
    I imported the model in 3ds Max and it has no textures. How can I get it to have textures?
    Bananite
  • 27d
    modmaker avatar
    modmaker Offline
    Member Joined 4mo
    195 points Ranked 18096th

    Is this option shown in blender?
    Bananite
  • 1mo
    modmaker avatar
    modmaker Offline
    Member Joined 4mo
    195 points Ranked 18096th
    Where do I put the model importing script in?
    Bananite
  • 2moEdited 2mo
    BabyLuigiOnFire avatar
    BabyLuigiOnFire avatar Offline
    Member Joined 3mo
    614 points Ranked 7246th
    For making rigs easier, I have several suggestions.

    When selecting arms and legs vertices, try selecting the edge of the limb, and use "Grow" and "Shrink" on the weight table tab to make selection of fingers and arms far easier and you don't have to worry about selecting vertices that overlap in one plane.

    Also, if your model is perfectly aligned, using the "Mirror" function on the Skin modifier helps ease the rigging process of bilateral models, as it copies and pastes vertices from one part to the other part of the model. It has to be bilateral though, and you should always check the integrity of the rig before you assume Mirror is perfect.
    Baby Luigi
  • 2moEdited 2mo
    Downloaded a model of the internet already with bones and animations running, however when I open the model in the MK8, he is invisible, what can it be?
    :)
  • 3mo
    Miniblu avatar
    Miniblu Offline
    Member Joined 3mo
    Im trying to make a BOTW animation and i have ripped a bokoblin model though i still need the animations. When i tried importing the Enemy_Bokoblin_Animation.bfres it just came as the skeleton and no animations because i think you havent implemented animations in the R5 importer. If you know how, could you find a way to import animations please?
    Thanks
    Bananite
  • 3mo
    D3 Gaming avatar
    D3 Gaming avatar Not Here
    Azure Gaming and Co. Flag Affiliation: Azure Gaming and Co.
    Member Joined 8mo
    D3 Gaming avatar
    D3 Gaming
    Azure Gaming and Co. Flag
    Azure Gaming and Co.
    I tried to import the Flameblade from Botw into 3dsMax, but it keeps saying "~~Unable to convert: undefined to type: Integer". Can someone help me with this?
    Modder
  • 3mo
    user619 avatar
    user619 Offline
    Member Joined 8mo
    418 points Ranked 10109th
    Do you know how to open .sblwp file its in the map folder of legend of zelda breath of the wild?
    Bananite
  • 3mo
    I imported a track, but when I export to dope.csv I get the error: "--Runtime error: Map support is not enabled for specified map channel: 1"
    Any solution?
    Bananite

Share

Shareable Image:
Share banner
HTML embed code:
BB embed code:
Markdown embed code:

More embeddable images

Bookmark and Share

Credits

Key Authors
KillzXGaming
Member Joined 1y
4,213 points Ranked 1084th
21 medals 2 legendary 4 rare
  • Reached 100 subscribers Medal icon
  • 30 submissions featured Medal icon
  • Returned 1000 times Medal icon
  • Reached 50 subscribers Medal icon
  • 10 submissions featured Medal icon
  • Received thanks 50 times Medal icon
Made tutorial
Special Thanks
smb123w64gb
Model Import script. Helping with issues and custom uwizard build.

Submitter

KillzXGaming avatar
Member Joined 1y
4,213 points Ranked 1084th
21 medals 2 legendary 4 rare
  • Reached 100 subscribers Medal icon
  • 30 submissions featured Medal icon
  • Returned 1000 times Medal icon
  • Reached 50 subscribers Medal icon
  • 10 submissions featured Medal icon
  • Received thanks 50 times Medal icon

KillzXGaming
Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!
  • Paypal Donate
Sign up to access this!

Category

Details

Difficulty Level
Intermediate Difficulty

Stats

Posts
79
Views
7,372
Date Added
5mo
Date Modified
27d
Date Updated
27d

Featurings

  • Today's Pick May 9 2017
  • Best of Yesterday May 10 2017
bcp.crwdcntrl.net tracking pixel