Posted on June 18, 2017, 12:03 a.m. by Ganonmaster • Last updated on Aug. 29, 2017, 11:22 p.m.
Hey everyone, here's a little tutorial on importing Source Filmmaker models into Blender. I get a lot of questions from people who stumble upon a model on SFMLab, download it, and then struggle to import it into Blender or other model tools. So here's a little tutorial to help you all along.
Download any model you want. I choose this pack of Witcher models. Unzip/rar these files and let's take a look at these files that we just downloaded. Most downloads will contain a folder structure similar to this.
So let's get in there. Let's see what's in these model folders. First thing you will notice is that a single model is made up of 5 or 3 different files. You can tell from the file name and the extension. There's a whole bunch of technical reasons for that, but for now we're just going to look at the .mdl file. What kind of file is that? Let's open it in Notepad++ and see. Ok, so it's pretty much unreadable. This is because it is a binary file. It was generated by the compiler based on scripts and text files. This isn't a format that's useful to us unless we are using Source Filmmaker.
So the files we have are in a binary format that Blender doesn't understand. What we want is the original files that the artist used to compile these models. The problem there is that the artist may not always provide those publicly. That's why we have to reverse the work the compiler did. This is what we call decompiling. The process of decompiling is never 100% accurate. It should be seen as a "best effort". Some parts of models may not get decompiled properly, but results are usually pretty good.
If you have any issues with the decompiler, make sure to read the message output, as it will usually tell you if you did something wrong. If the decompiler fails to properly decompile your model, visit the Crowbar Steam community or their Discord server for help.
So for this, we are going to download Crowbar. It is a decompiling tool for the Source Engine and a whole bunch more. Just download it from their Steam Community page, unzip it and run Crowbar.exe.
There are several decompilers for the Source Engine model format. However, most of them are outdated and only work with models compiled for older generations of the Source engine. At time of writing, Crowbar is the only one that works with the more recent versions of the Source engine.
So with Crowbar open, go to decompile tab. There are a lot of buttons and settings here, but we're pretty much fine with the default settings. The only thing we need to do is select the MDL file or folder. I'm just going to select the main folder of the model pack I downloaded as it's only about 6 or 7 models. The Output folder is set to be a subfolder of the .MDL file location, which is fine for me, but you can adjust this if you want. Hit decompile, and see what it does.
If you downloaded a big pack of models, it's usually better to select the .MDL file directly instead of converting the entire folder. It's also advisable to not run this in your Source Filmmaker
Ok, so it seems to be done processing the models. Let's look in the model directory to see what it's generated.
The model now consists of several other files. You should see the following:
For this tutorial we will use Blender, but there are SMD importers for Maya and 3ds Max as well. They don't work quite the same, but the same concepts apply. If you can't figure out the 3ds Max or Maya importers on your own, you can always follow along with this tutorial and export the files out of Blender as FBX or Collada/DAE.
Structured text files! This is a format we can use with a simple importer. Assuming you have already downloaded and installed Blender, you can go ahead and download the Blender Source Tools. Don't unzip this file. In Blender, Select File > User Preferences. Go to the Addons tab. Click Install From File... in the bottom of the window. Find the downloaded zip file. Find and check the Source Tools' box. Wait a moment for activation to complete. Click Save User Settings. The plugin should now be installed.
Go to File -> Import -> Source Engine. Now, navigate to the directory where you decompiled your models, and select the .QC file you want to import. The importer will read the QC file and try to import all the SMD files automatically. It will also read flex definitions and the VTA file and attempt to match those to the SMD files. This last part doesn't always work, but it does a good job most of the time.
If everything went well, you should now have your model in Blender! Hurray! From here on, you can edit, animate and render the model as you would like. You can also export the model in a different format like DAE or FBX if you want to use a different tool. The only thing that's missing is the textures.
So now we finally get to dive into the materials folder. In here, you will find .VMT files and VTF files. VMT files are just text files that define which textures the shader should load in the Source engine. The VTF files are the actual textures. However, Blender doesn't read VTF textures. We need to convert them, and for that we need VTFEdit.
Once you have VTFEdit open, go to Tools -> Convert Folder. This will open up the Batch convert window. First select your Input folder. Set this to the folder that contains the VTF files, or simply the materials directory of the zip you downloaded. Set the output folder to where you want the converted files to be. This can also be the same folder. Next, if the radial toggle is set to "To VTF", change it to "To tga".
You can also pick "To PNG", but in my experience, Blender and Photoshop work better with TGA for textures. This is because VTF files will often have an ALPHA channel which controls the transparency. TGA files will keep this data as a separate channel, while PNG files will bake the transparency data onto each RGB color channel, making it more difficult to separate and use this data effectively.
Lastly, tick "Recursive" and untick "Make VMT files". Finally, hit Convert. Look at the message window below to see what it's doing. Depending on the number and size of the textures, this should be finished rather quickly.
Once the converting done, you have all the TGA files and can start assigning them in Blender. For this part of the process I'm going to assume you have some basic knowledge related to setting up materials in Blender. You can make the shaders as crazy as you want. Sometimes people aren't sure which textures belong to a specific material, so here's some pointers for that. Remember the VMT files? Basically each Material in Blender points to a VMT file with the same name. If you open that VMT file in a text editor, you can see several Source Engine material parameters like
$bumpmap. These point to VTF files. Based on those filenames, you can match up textures to the right material. It's that simple.
You now know how to decompile Source engine models, import them into Blender and convert their textures. I hope you found this tutorial useful.