Introduction

These instructions will tell you how to import Source Film Maker (SFM) models into Unity, through Blender.

They are based primarily off the now-dead instructions by Digitalzombie.

Software Requirements

  • Unity - download.
  • Blender - download. Used to convert 3d models to FBX format.
  • Blender Source Tools - download. Used to load decompiled SFM files into Blender.
  • BoneFix - download. Optional - used to fix skeletons.
  • Crowbar (ZIP Version) - download. Used to decompile SFM files.
  • VTFEdit - download. Used to convert VTF textures to PNG.

Download SFM model from Steam Workshop

To download a model from the Steam Workshop you can use a website like steamworkshop.download or steamworkshopdownloader.io.

Installation

Installing Unity & Blender

Install Unity and Blender as normal - the default options should be fine.

Installing Blender Source Tools

  1. Load Blender and click on the Edit menu and choose Preferences.
  2. Click the Add-ons tab then click the Install button.
    Screenshot
    Install an add-on
  3. Locate the blender_source_tools.xxx.zip file you downloaded earlier and click the Install Add-on button.
    Screenshot
    Select Plugin File
  4. Check the plugin is active by typing "source" into the addon search box, and making sure the checkbox is checked next to Import-Export: Blender Source Tools.
    Screenshot
    Ensure Plugin is Active

Installing BoneFix

  1. Create a folder to store the scripts, and move BoneFix.py into it.
  2. Load Blender and click on the Edit menu and choose Preferences.
  3. Click the File Paths tab and set the Scripts folder to where you placed BoneFix.py, then click the Save User Settings button.
    Screenshot
    User Scripts Folder

Installing Crowbar & VTFEdit

Extract the each zip file into its own folder.

Convert the Model

Your SFM file will probably be a zip file - extract it and find the folder with the .mdl file you want to use.

Before starting, it's best to create a new folder to store your converted model and textures in.

  1. Load Crowbar and on the Decompile tab, open your .mdl file.
    Screenshot
    Choose your File
  2. Click the Full path radio button and choose folder you want to put the decompiled files in, then click the Decompile button. You can leave all the options at their default values.
    Screenshot
    Decompile the Model
  3. When decompilation is complete your model will be ready to import into Blender, but the textures need converting separately.

Convert the Textures

  1. Open VTFEdit and click the Tools menu then choose Convert Folder.
  2. Select the input folder that has the .vtf and .vmf files in it. Select an output folder for the .png files - use the folder you created for the decompiled model. Click the Convert button to convert the textures.
    Screenshot
    Decompile the Textures

Load into Blender

  1. Open Blender and delete the Camera, Cube and Lamp objects.
  2. Click the File menu and go to the Import submenu and choose Source Engine (.smd, .vta, .dmx .qc).
    Screenshot
    Blender Import Menu
  3. Locate the folder you extracted the model into and select the *.qc file. Click the Import SMD/VTA, DMX, QC button. This can take quite a while - don't worry if Blender seems unresponsive.
    Screenshot
    Blender Import *.qc File

Fix the Skeleton (Optional)

This is an optional step - follow it if your model has a skeleton you want to use in Unity

  1. Click the mode tool and select Object Mode then right-click on any bone to select the skeleton.
    Screenshot
    Select the Skeleton
  2. Go to the Python console by clicking the window button and selecting Python Console. Note - this was called Scripts in older versions of Blender.
    Screenshot
    Go to the Python Console
  3. Run the script using the following code (don't forget to change the script path!):
    exec(open("c:\\users\\RoBorg\\Documents\\Blender Scripts\\BoneFix.py").read())

    If you're using Python 2, you can use this instead:
    execfile("c:\\users\\RoBorg\\Documents\\Blender Scripts\\BoneFix.py")

Export to Unity

  1. Click on the File menu then choose the Export and click on FBX (.fbx).
    Screenshot
    Blender Export Menu
  2. Type a filename and click the Export FBX button.
    Screenshot
    Blender Export FBX

Load into Unity

  1. Load Unity and open your project or create a new one.
  2. In the Project window, create a new folder for your model and under that folder create two more, called Materials and Textures.
  3. Drag-drop your .fbx file into your model folder, and the *.png files into the Textures folder
  4. Export the materials from the model by selecting the model and going to the Inspector and choosing the Materials tab. Make sure the Import Materials checkbox is checked, then click the Extract Materials button. Choose the Materials folder you created previously.
    Screenshot
    Extracting Materials
  5. Assign the correct texture to each material by going to the Materials folder in the Project windows and clicking on each material in turn. Click the circle icon next to Albedo and choose the correct texture from the Textures folder - it should have the same name as the material. Note that not all materials will have a texture - they may just be solid colours.
  6. Remove the colour cast from your materials by selecting all of them in the Project window then clicking the colour swatch next to Albedo and set it to white.
  7. Go to the Textures folder and select all the textures, then in the Inspector check the Alpha Is Transparency checkbox and click the Apply button.
    Screenshot
    Texture Transparency
  8. You can now add the model to your scene!