Source Filmmaker

Source Filmmaker

79 ratings
Importing Garry's Mod addons into SFM and Blender
By Jocelyn
A comprehensive guide to importing content from Garry's Mod addons into SFM, and importing Source models into Blender for use in non-Source applications.
   
Award
Favorite
Favorited
Unfavorite
Introduction
For most Source engine mods, mod files are packaged in the .vpk structure. Garry's Mod, however, uses the .gma structure for its user content. It is not a difficult process to extract files from a .gma, and from there it is very simple to get the files into Source Filmmaker or Blender.

Required Programs:

Optional Programs:
Downloading the addons
First of all, you'll want to make sure you can see web urls for workshop items in the Steam client. To do this, in the Steam client go to Steam > settings > interface and check the box "Display Steam URL address bar when available". This will show a web URL below the Store link, which can be copied.

Choose an addon that you want to use. This can only be a model, texture, sound, or map. Garry's Mod scripts will not work as they are written in LUA, a language that SFM cannot understand. For this guide I'm going to use Apple's Steam Award model.

Now, there are two ways to do this next part. You can subscribe to your chosen addon, go into your Garry's Mod addon folder at steamapps\common\GarrysMod\garrysmod\addons, and find the addon in the list. The addons are typically organized using their workshop IDs, which is the number on the end of the URL on their workshop page.

***
EDIT: As of September 2017 the below method no longer works for most addons. You'll get a generic file that is not a .gma and thus cannot be used. I say most addons because it may or may not work for some, and you're welcome to try because this way is much more convenient.
***

This next method does not require you to subscribe to the addon, and I think it is much easier. There is a great web tool called Steam Workshop Downloader[steamworkshopdownloader.com]. This tool works for anything on the steam workshop. Note that sometimes this tool doesn't work, in which case you will need to use the other method above.


Go to the addon's page on the steam workshop, copy the URL just underneath the Store link (should be of the form steamcommunity.com/sharedfiles/filedetails/?id=number; you may have other parameters at the end of that but don't copy them) and paste it into the bar on Steam Workshop Downloader. The tool will pop up with a green download button next to an image of the addon you want to use. Make sure it has found the right addon.


This will put the addon files into your downloads folder. Note that the file name won't necessarily be the title of the addon; when I downloaded the Steam Awards addon, the file name was a string of numbers. However the file will be in .gma format.
Extracting the addon .gma
Now that you have your .gma, you can get the files you need out of it. In your Garry's Mod bin folder, you have a program called GMAD, which is used to create and extract Garry's Mod addons. You can download GUI wrappers for this program, but I like to just use the command line (this only works on Windows OS). For more information on GMAD, reference this thread[www.facepunch.com]. (dead link, see Appendix A)

First, open up a Windows Command Line. It does not need to have administrator priviledges. To open the command line, press Windows Key + R, type cmd in the box, and press enter. If you haven't used the command line before, don't be alarmed. This is essentially a text version of the Windows operating system.

Now, in the box type the following commands:

cd "your steam folder/steamapps/common/GarrysMod/bin" gmad.exe extract -file "path to the .gma you downloaded" -out "path to where you want to extract it"

Replace the arguments in quotes with the appropriate file paths (keeping the quotes).

You can also navigate to your Garry's Mod bin folder and drag the .gma onto GMAD to extract it.

Once GMAD begins extracting it could take a few minutes depending on the size of your addon.
When it finishes and you can type in the command line again, you can close the command line. Navigate to the folder you specified in the -out parameter, and you should see some new folders. Probably one or more of lua, materials, models, sound, and maps.
Importing the content into Source Filmmaker
This is where the guide branches off. If you are here only to import the models into Blender, skip this section. The Blender section starts at "Importing Content into Blender".

There is no more extracting that needs to be done, as Source Filmmaker needs the files to be in normal folders. This will just be a copy and paste operation.

You will need to paste the contents of your folders into specific folders in SFM. Navigate to your Source Filmmaker directory (located at steamapps/common/SourceFilmmaker). Open the folder game, then usermod. The usermod folder is where you should put miscellaneous files, when you are not importing an entire game into Source Filmmaker (if you need to do that you should make a new folder in the game directory, put your game files in it, and then add the folder to your gameinfo.txt in usermod. But that's for another guide.)

In usermod, you should see folders called maps, materials, models, sounds, etc. Note that although there is a scripts folder in usermod, you will not be able to use Garry's Mod scripts as those are written in LUA, and SFM requires scripts to be written in Python. I'm sure if you have the knowledge you could covert your LUA scripts, but that is beyond the scope of this guide.

You will need to put your addon files into the right folders. For example any addon files you have in the materials folder will need to go into the materials folder in usermod, models will go in the models folder, etc. I would also make a new folder within the usermod folders for organizational puposes, although you don't have to. An example file structure would be "game/usermod/materials/steamawards/example.vtf". The folder you create can be named anything, but I would avoid using spaces.

Making sure models have the right textures
Before I begin, I feel it is appropriate to go over Source engine file structures.

All Source engine models have the following file types:
  • .mdl - a compilation of various .smd files and a .qc file (more on that in the Blender portion of the guide)
  • .vvd, .vtx - don't worry about what these are, just know that you need them.
  • .ani - contains information about model animations. I have only seen CSGO models use this.

All Source engine models are associated with the following texture file types:
  • .vtf - a specialized image type that contains a flattened out model texture and an alpha mask
  • .vmt - a text file that goes along with the .vtf, containing information about envmaps, base textures, normal masks, etc.

There are two versions of Source models that are meant to be held by a character (such as weapons). There is a view model, which is the model used in first person mode, and a world model which is used in third person mode. These are denoted by the v_ and w_ prefixes respectively. Some Source engine games use c_models, which are essentially a combination of a model's view and world models. They work the same as other models in SFM. If you're using models in SFM, you will most definitely want the world models, and you don't necessarily need the view models as well.

So, in the process of moving your addon files to SFM, you might not have kept the same file structure. That's okay, you will just need to change the file path the .mdl references. Open the .mdl file you want to work on in a text editor (I would recommend using Notepad++; if you have it installed you can just right click on the .mdl and click "open with notepad++"). Don't be alarmed, you will be seeing a lot of junk characters that you can't read. This is because a .mdl is not a normal text file, it is more like an archive. Scroll down to the very bottom of the file, and you should see a line (in plain english) that looks like a file path. This path is relative to the materials directory. Change it to the path to your addon materials in the usermod/materials folder. An example path would be "steamawards/example.vtf".

If you don't do this process correctly, your model will show up in SFM with purple and black squares for a texture. The purple and black squares show up when Source cannot find the textures in the directory specified in the .mdl; they mean "missing textures".
Source Filmmaker Conclusion
All the files from your Garry's Mod addon should now be in Source Filmmaker. To use them you will just have to create an animation set for a new model in SFM. To more easily find them in the model browser, select usermod from the mod list.

Please be sure to give credit for any addons you use in your SFM projects to the original author!
Importing content into Blender - Introduction
Importing models into Blender is a way to get them into more universal file types, such as .obj. You can then get the models into games that do not run on Valve's Source engine.

It is very important that if you choose to do this, you need to ask permission of the original author whether that is Valve or a Steam user, especially if you are using them in a project you expect to be paid for. Following this process could lead you into uncertain legal territory; please avoid infringing on someone else's copyright or claiming their work as your own. Obviously I'm not responsible for what happens after you follow this guide.

With that out of the way, it is a relatively easy process to get Source content into Blender. You should have already done the process described in the addon extraction section of this guide.
Decompiling Source models
As I said before, Source .mdl files are actually compilations of .smd and .qc files. Blender can only work with those files, so any models you want to use must be decompiled.

Here is a breakdown of what .smd and .qc files are:
  • .smd files are 3D models, and most .mdl files contain multiple .smd files
  • .qc files are text files which contain information about how the .smd files should be put together to form the .mdl. Each .mdl contains one .qc file, and they are program generated.

You should have installed Crowbar, which is used to decompile and compile Source models. We are going to use it to decompile the models from your Garry's Mod addon. Crowbar is a GUI wrapper for studiomdl, a program that comes with your Garry's Mod installation. For more information, reference this page.

Open Crowbar and navigate to the Decompile tab:

Click the browse button near the top and browse to the .mdl you want to decompile. After you have selected your model, go to the Output Folder section. You can either select "Subfolder", in which case it will make a folder with the name you enter in the same folder as the .mdl, or you can choose "Full Path" in which you can specify the exact location of the folder to put the files in. It doesn't matter which one you choose, just remember where you are putting your decompiled model. You can ignore the options in the middle of the Crowbar window unless you know what you are doing. Click the decompile button at the bottom of the window. The program will show some text ouput.

Navigate to where you decompiled the models. You should see several things:
  • A folder ending in _anims containing various .smd files with model animations
  • A .qc file which was generated by Crowbar
  • A file ending in _reference.smd, which is the default .smd file for your mdl.

You have successfully decompiled your .mdl into a format that Blender can use.



Blender Source tools
You will need to install the Blender Source tools plugin. This plugin will allow you to import .smd and .dmx files, and to export files as those types.

The Valve Developer WIki has a guide on downloading and installing the plugin.

Once you have installed the plugin, in Blender you can go to File > Import > Source Engine > .smd, and from there you can open any .smd in Blender. Once the files are open, you can go to File > Export and export the files as any file type you need. Note that I have not touched on getting Source textures into Blender, because I don't know how to do that. However, I believe that Blender can use normal image types but not Source .vtf files. The best tool for working with .vtf files (and exporting them to normal image types) is Nem's VTFEdit[nemesis.thewavelength.net].
Conclusion
You should now be able to import Garry's Mod addons into Source Filmmaker and Blender easily. I believe that this process is one of the simplest ones out there.

For more information on the wonderful world of modifying the Source engine, the Valve Developer Wiki is a good resource.

Again, please be sure that you have the addon creator's permission to use their content in your own project. The best way to reach many of the authors on the Steam Community is to make a comment on their addon page.

Thanks for reading!
Appendix A: GMAD Details
Author's Note: Below is a recreation of a post written by Garry on the old Facepunch Forums detailing usage of GMAD. The original page is available (for now) in the Google webcache[webcache.googleusercontent.com].

Windows/Linux/OSX: These files are available in the bin folder of your Garry's Mod install.
Source code: https://github.com/garrynewman/gmad
Usage:
gmad <command> <options> //To create a new .gma file (folder should contain an addon.json - see below) gmad.exe create -folder "C:\path\to\addon\folder" -out "C:\where\to\save\file\out.gma" //To extract an existing .gma file into its parent folder gmad.exe extract -file "C:\steam\etc\garrysmod\addons\my_addon_12345.gma" //To extract an existing .gma file into another folder gmad.exe extract -file "C:\steam\etc\garrysmod\addons\my_addon_12345.gma" -out "C:\this\folder"

You can also simply drag'n'drop a .gma or an addon folder onto the .exe to extract the .gma or create a .gma respectively.

addon.json
When creating an addon the folder should have an addon.json - which looks like this..
{ "title": "My Test Addon", "type": "ServerContent", "tags": [ "fun", "cartoon" ], "ignore": [ "*.psd", "*.vcproj", "*.svn*" ] }

title is the name of your addon.
ignore is a simple wildcard list of files to ignore. You can have as many of these as you want - and they don't have to be wildcarded, they can be specific files.
type is the type of addon, one of:
"ServerContent" "gamemode" "map" "weapon" "vehicle" "npc" "tool" "effects" "model"
tags is up to two of these:
"fun" "roleplay" "scenic" "movie" "realism" "cartoon" "water" "comic" "build"
13 Comments
Catmithril Apr 14 @ 3:50am 
The downloadable crowbar zip on the site link has a trojan on it. Is there any alternative?
Pops Aug 4, 2024 @ 6:14pm 
yes.
Scary shrek Aug 2, 2024 @ 3:36pm 
yo can i do this roblox studio?
Jad_chou Mar 5, 2023 @ 1:38pm 
gmad <command> <options>

//To create a new .gma file (folder should contain an addon.json - see below)
gmad.exe create -folder "C:\path\to\addon\folder" -out "C:\where\to\save\file\out.gma"

//To extract an existing .gma file into its parent folder
gmad.exe extract -file "C:\steam\etc\garrysmod\addons\my_addon_12345.gma"

//To extract an existing .gma file into another folder gmad.exe extract -file "C:\steam\etc\garrysmod\addons\my_addon_12345.gma" -out "C:\this\folder"
C̷O̷S̷M̷I̷C̷>V̳R̳ Jan 20, 2023 @ 3:10pm 
nope nothing happend:steamsad:
raspberry s-pii Apr 23, 2021 @ 8:10pm 
i tried using the cmd prompt way but failed horribly, pls help
Pops Apr 17, 2021 @ 7:54am 
"windows cannot find cd"
ZeqMacaw Nov 12, 2020 @ 2:16am 
When unpacking the GMA via gmad.exe, make sure the unpacking actually finishes before trying to decompile the MDL with Crowbar. If that still fails, try using Crowbar's Unpack tab to unpack the GMA.