Nahka's pony compiling tutorial

18 min read

Deviation Actions

Poninnahka's avatar

NOTE: This tutorial is a little outdated ever since the Steampipe -update at summer 2013! Most of the tips still work but the SDK in this tutorial won't, so you'll have to use SFM's SDK instead. Yes, even if you are compiling for Gmod.

In this tutorial I'm going to tell you how to set up some tools, how to compile models for Source and some ways that are useful for model development, at least in my opinion. This is specifically meant for my male pony source files, so some ways may or may not work for other models due to the way I work on them.
This might not be suitable for beginners even though I'll try to explain this as well as possible, so if you're fairly new to Gmod, I suggest you try to learn some basics first about how the engine handles models, materials and textures.

Oh and this stuff can't be explained by pictures for the most part. You just have to read... A lot...

First, get the source files here:…

How I work

Before we start, a few explanations might be in order, otherwise some solutions might not make much sense for everyone.

First, I compile all my models for HL2 Ep2 before moving them to Gmod. This is for easy testing using Source SDK's Model Viewer. Model Viewer is only a renderer, so it loads up fast instead of loading up everything Gmod uses and spending half a day just waiting to see the results. It also has some useful tools and options, like loading an item that will be bonemerged on the model, previews for sequences, flexes, physics, attachments, hitboxes and the list goes on. Pretty much everything can be tested in Model Viewer with the exception of ragdoll properties like flexibility, weight and stuff like that, but those can be tested in Gmod after the model is otherwise done.

Every time I compile a model, it will be available for viewing as soon as it's done compiling and all I need to do there is to press refresh to see the newest version. Same thing when working on textures, it'll be ready as soon as new texture or material is installed or edited and pressing refresh will show it immediately. Fast and easy, and the only drawback is the additional step of installing the model in Gmod afterwards.

Another thing I do differently is modularity. I always make a base model which has the facial animations and all the fancy stuff and all the details that make the character are added on the base model as separate models. If done right, it'll save a lot of time when making new characters that share mane or tailstyles or accessories with other characters, because then you only need to edit the QC and hit compile. Plus, in some cases merging stuff on the base model breaks some features, for example for bodygroups separate meshes are a necessity and flexes might move some points around from merged meshes. Twilight's mom -reskin is one example of this, the front hair get pulled down when closing eyelids. This wouldn't happen if the mane was added on the model using bodygroups. More of that later, now off to the first actual part of this tutorial.

If you're a modeler and want to add your own manes / tails / accessories on this model, here's a few tips how to make it fit:
- First import the reference.smd and make the mesh fit it. That way you get the skeleton for your custom part.
- After you're done, rig your part to the skeleton and test how it bends.
- Remove the reference when you're happy, you should have only one mesh object in the scene, in this case yours.
- Now export the mesh and add it on the model as a bodygroup. That's it, for every mesh.

Setting up tools

First things first, in order to get your model compiled, you need a couple of tools for it. First one is easy, you need one game that uses the Orange box -version of the engine (HL2 -series, Portal, TF2) and Source SDK, which can be found from the tools -section in Steam. Make sure you have installed and started up the game at least once. Open Source SDK and choose "Source Engine 2009" if you're going to use Portal or HL2 (I prefer using HL2 Ep2), or "Source Engine MP" if you're using TF2, then choose the game you're using. After you have those selected, start up Model Viewer. This will enable some of the SDK functionalities, so keep it running, you'll need it later.

Next step is getting the compiler. I use GUIStudioMDL (… ) as a compiler since it acts as a graphical interface on the original compiler. Plus, unlike some people have been having serious problems with Cannonfodder's StudioCompiler, I haven't had any problems with GUIStudioMDL. Besides, it's not too picky about the engine, I have L4D2 compiler set up as the Ep1 -option and it just works.

After you have installed GUIStudioMDL, it will tell you that the compiler paths need to be set up. You need to set up the Orange box -path, but this might take some trial and error. For me path "...steamapps//sourcesdk/bin/ep1/bin/" works just fine, but for some people it might not work. Having "orangebox" instead of "ep1" might also work, my suggestion is to try out all options (ep1, orangebox, source2007 and source2009) and test which one works.

To test the compiler, you can try to compile the template.qc provided in the pack. Before you even try to compile, open the file using Notepad++ (this is the text editor we're going to use, normal Notepad won't do it, it'll only corrupt your files), find the line that starts with $cd and change the filepath in that line to the one where the template.qc is located. Now, in the compiler you need to load the QC, so click File → Load QC File... and find the correct file. Then choose Orange Box as the SDK version, select the game you want to compile it to (the one you're using in Source SDK, for me it's HL2 Ep2), check "Ignore Warnings" just in case and then hit Compile. If everything goes well, you should see a lot of text running in the output -area (it might stop responding at some point while compiling, nothing to worry about) and then you can browse for a model called male_template.mdl in Model Viewer. You should see a textureless male pegasus with a vest and RD's mane and tail. If the output jams at "Created command line: ...", the compiler is not responding and you need to start up the Model Viewer, then recompile. If it still doesn't work, change the path and try again.

If you get in trouble in this part, check the end of the tutorial for possible solutions. Otherwise, tools should now be working and you can proceed to the next part.


I made it a tad easier to find and read the files by sorting them into folders. Each folder contains only certain types on files and the names should be pretty self explanatory, but some files cannot be used with other files without getting bugs. In this section I'll try to explain what you can and what you can't do with these files.

So, the first thing you should see is the template.qc and a bunch of folders. We'll start up with the QC, which is the compiling script for Source-models. Basically it tells the compiler how all the meshes should be used, what features, what properties and what kind of physics the model should have. Furthermore, it's the only file you need to edit in this tutorial.
The template.qc has all the most important commands expained in comments and some extra stuff, so you should know everything you need by just carefully reading the comments. The easiest way to compile a custom model with these source files is to make a copy of the template.qc and just change the names and make it point to correct parts (check the bodygroup -part in the QC for that)

Now the folders. I'll just briefly explain what they contain and will go into detail if needed:

accessories: This folder contains all the clothing and gear ponies have at the moment, like the vest, Wonderbolt -goggles etc. Braeburn's hat is not included here, it requires modifications to the mane to be usable
bodyparts: This folder contains all bodyparts, like the body, separated wings and the horn
flexes: All the flex files that are used on the ponies
manes: All the manesyles here. Depending on the type, there are different physics and skeletons for you to use, more of those in a sec. There are three types of manes:
normal: No additional bones. Files using this type: caramel, nightlight, noteworthy, pokeypierce, scratch_bleh, soarin, spitfire, thunderlane and whooves
RD: Ragdolled hair on back. Files using this type: derpy, lyra, RD and twilight
Braeburn: longer hair on back, hangs on right side. Only the files marked as braeburn use this type
phymodel: This means physics, or collision models. Currently there's 12 different models to choose from, so choose carefully and remember to read the comments at the end of the physics -part of the QC to . They are named so it should be easy to tell which contains what, so use their names to determine which ones to use:
pegasus/earth: pegasus means that the character must be a pegasus. The file contains physics for both closed and spread wings. Use pegasus for pegasi only, otherwise the pony falls apart because of broken physics.
normal/braeburn/RD: This is the manetype the model is using. Make it match to the type you're using, otherwise you'll get a decapitated pony or messed up physics
short_tail/long_tail: This is the tail type the model is using. Making it match is encouraged, but there won't be any serious problems if it doesn't match. The collision models are just different size, making grabbing easier.
QC: This folder contains example QC's made for the male pony pack. They are a bit outdated because I had to organize the files, but you might find something useful in there
ragdoll: This folder contains two sequences, one for the normal/RD types of manes and one for Braeburns type of mane. All tail types have the same skeleton, earth ponies have the wing bones, the only difference is the mane type. Make it match to the mane, otherwise it'll be positioned wrong way. Ragdoll.smd for the normaland RD, ragdoll_braeburn.smd for braeburn
tail: All the tailstyles. There are two types of tails, long ones and short ones. They share the skeleton so the difference is only visual.
Short tails: braeburn, caramel, nightlight, pokeypierce, thunderlane, whooves
Long tails: derpy, lyra, RD, soarin, spitfire, twilight

Editing and Compiling

Now you should know where to find all the files, so it's time to start creating the model. There's only a few parts in the template.qc that you need to edit in order to create a new character, they are commented in the QC but I'll explain them here again.

$cd "F:\Nikon Tiedostot\projects\source\male_ponies"
This line tells the compiler where the QC is located, so you need to change the path to the one where you extracted the source files. All filepaths in the QC are relative to the path in this line, so if files are in sub-folders like in this case, the filename would be for example "bodyparts/reference.smd" or if the files are in parent folder, you can go back in folders with "..", for example "../../bodyparts/reference.smd" means two times up in folders, then into bodyparts -folder and there reference.smd.

$modelname "male_template.mdl"
This line defines the model location and name. It'll always go under models -folder in the game you're compiling it to, so if you have a path "mystuff/mymodel.mdl", it'll go into game/models/mystuff -folder and is named as "mymodel.mdl". All ponies I know have been put under models -folder, so You can just add the pony's name into this line.

$bodygroup "vest"
studio "accessories/vest.smd"
Bodygroups, there are several of them and they are the main things that determine the looks of your model. Source has a limit for them but so far I haven't managed to hit it, so you should be fairly save (had 13 groups with plenty of subgroups, the limit might be 16). I use bodygroups to add separate pars of the model on the base model, that way the model will be modular and easy to change if necessary. Read the comments in the QC, there I have explained how to use the bodygroups to add new parts to the model.

$cdmaterials "models\mlp\male_template\"
This is where the game will look for materials for the model. You can have several lines for that, in that case the game looks for all files in the first folder, then looks for the remaining files in the second folder, then remaining ones in the third and so on. All materials must be under materials -folder in the game you're compiling this model to, so in this case the path would  point to "game/materials/models/mlp/male_template/" -folder.

$texturegroup skinfamilies {
Skingroups, I use them for different pupil sizes and for Wonderbolt suit when creating new ponies. Inside every bracket you see one group of textures, in this case the body and hair materials. Those groups are variations, there can be only one enabled at a time in game, so you need to think how you want to change the materials. For example it's ok to have two variations with several materials in them, but adding more variation will grow the number fast. Two materials with maximum combinations means four groups, three means nine. For Wonderbolts it would be body with two variations and eyes with three variations, that means there's six groups. You might not even need them at all, so if you don't want to reskin all eye sizes, just remove the skingroups.

$sequence ragdoll "ragdoll/ragdoll" ACT_DIERAGDOLL 1 fps 30.00
This is kinda like the glue that keeps the model in shape, without it all bones would be loose, the character wouldn't be intact and and physics wouldn't be connected to the mesh. This is why compiling fails without this line, there has to be at least one sequence, aka animation in the model. In this case you have only two choices, ragdoll_breaburn for Braeburn's hairstyle and ragdoll for everyone else.

$collisionjoints "phymodel/phymodel_pegasus_RD_long_tail.smd" {
$mass 50.0
$inertia 10.00
$damping 0.20
This section handles all the physics of the model. The only parts you need to change are the filename in the first row and some of the joint constraints at the end of the section. The filename needs to match on the character's hairstyle, tail and race and the jointconstraints also need to be changed according to that. Read the comment carefully, I have explained what to do for them in the QC.

That's all the parts you need to change in order to make your character. After you're done, save it, load the QC in the compiler and compile it. After it's done, you should see the results in the Model Viewer. The model doesn't have any textures yet, so that's what we'll take care of next.


Most of you already know how to make new skins or hex models, but I'm still going to cover this part just in case. This is exactly the same as the material editing part when hexing a model, so you can skip this one if you know how to do it.

So, in order to have the model have other colors than just black and purple, you need materials and textures. You can get a good start with this by copying the correct materials from existing models, you can find them under materials/models/mlp -folder. To find out what materials your pony is using, check "Dump Materials" in the compiler under Orange Box Options -tab. You can then find the material names and their index numders listed in the compiler output. Then just find and copy all the correct materials and textures from existing ponies, and move them to the folder you specified with the "$cdmaterials" -command in the QC.

Now, you need to do a small change into the material files (.vmt). Each material has several commands for textures and shading, and some of them contain filepaths. These paths point to the textures the model will be using, so it doesn't matter is you have all your materials and textures in the correct folder, it might still fail. The material -files need to point to the correct textures, otherwise you won't see any change even if you edit your textures, so edit the filepaths. Open the material with Notepad++ or VTFEdit and look for lines "$basetexture", "$lightwarptexture" and in some cases "$bumpmap", basically any line that contains a filepath. I'm not going to specifics what all the commands mean, for that I suggest you check this out:…

After you have edited all vmt's, hit refresh in the Model Viewer. If you have missing textures, check the "VMT's Loaded" -box in the Model -tab. If you see "*** ERROR *** Model attempted to load one or more VMT's it can't find", you missed at least one vmt when copying them. You can try to compare the found ones to the list you got when dumping the materials or try to find a missing texture on the model and figure out the name from that. If you have all the materials in place, then one or more filepaths are not correct in the vmt's, so double check them for typos. When everything goes well, you should see the original textures and they are now ready for editing. Again, if you don't see any change after editing textures and refreshing, check the filepaths.


Problems will occur, that's the only certain thing when working with models. Here are some of the most common problems and possible solutions.

ERROR: f:\...\template.qc(233): - could not load file 'F:\...'
ERROR: Aborted Processing on 'male_template.mdl'
WARNING: Leaking 1 elements

This one is caused by missing model file (surprise). Check the line in question for typos or other mistakes and that the file you're trying to load actually exists.

ERROR: f:\...\template.qc(218): - unknown model option "$opaque"
ERROR: Aborted Processing on 'male_template.mdl'

This and other unknown command -errors are mostly caused by human error, usually a missing bracket or quotation mark. Check the commands above the line in question, especially the ones you've recently edited.

The compiler gets stuck right after Created command line: "D:\Program Files\Valve\Steam\steamapps\..."
In this case the real compiler fails to start. Open Source SDK, start up Model Viewer and recompile when both are running. This will enable some headers for the compiler to use.

Model part is added on the base model, but it doesn't show up in Model Viewer
This might happen if the .smd you tried to load has been exported incorrectly. Unlikely with these source files, but still possible. If you exported it yourself, check the scene if there are more than one mesh objects or something else that might break it. If this happens with these source files, let me know as soon as possible.

Model crashes the game or falls apart in game
Usually the model won't crash the game unless there's something really wrong in it. For me in most cases it's broken physics and model falling apart proves that. That only happens if there are bones with physics but no mesh for them to attach to, for example when using pegasus physics for an earth pony, wing physics break the parent bone, giving you a pony with a really flexible midsection.
To fix this, make sure you're using the correct parts with matching physics. Enabling "Physics Model" in Model Viewer shows you the physics of the model, handy for finding extra physboxes.

I think that's all for now, if you get in trouble, find mistakes, errors or bugs from the source files or from this tutorial, let me know as soon as possible.
© 2012 - 2023 Poninnahka
Join the community to add your comment. Already a deviant? Log In
UnbeatableGameRL's avatar

I keep getting no user info in guistudio, and SteamAppData.vdf is missing. any way arround this?? I need help please!!