Team Fortress 2

Team Fortress 2

68 ratings
Detailed Written TF2 Hat Making Tutorial
By Monsterman
If you're having trouble fully understanding the tutorial videos out there about making a TF2 hat, try out this more detailed written tutorial made especially for beginners. Please like, favourite and share if it helped :)
   
Award
Favorite
Favorited
Unfavorite
Programs required
Programs you'll need:
First download Source SDK (download it by clicking the "Games" tab in steam then "View Games Library" then click where it says "ALL GAMES" (above your game list) and navigate down to "Tools" and click Source SDK and install it).
Run Source SDK once, then make sure you have these:
Blender
Notepad ++ (you could also use the normal one)
GCFScape (You need version 1.71 or better)
VTFedit
GUIstudioMDL
Texturing software (e.g. GIMP, photoshop etc.)
MDLDecompiler (make sure you download the fixed version here: http://gamebanana.com/steam/tools/5083 and paste it in: C:\Program Files (x86)\Steam\steamapps\***user_name***\sourcesdk\bin\ep1\bin

The last thing you need to do is download blender smd tools here: https://developer.valvesoftware.com/wiki/Blender_SMD_Tools
Copy and paste the two files io_smd_tools.py and datamodel.py into: <your blender location>\2.63(could be a different number depending on your version)\scripts\addons
Creating the model
Please note: ONLY if you run windows 32 bit, when I mention Program Files (x86) just think of it as Program Files
In this example we will make a hat for heavy named "helmet". When I refer to helmet throughout this tutorial, remember to just replace helmet with your hat's name. And if your hat is for a different class just replace whenever I say heavy with that class. Basically just use your common sense.

1.Create a folder with the name of your hat. In this case I'll create a folder called helmet. Open up blender. Go to file->user preferences->addons. Enable "Import-Export: SMD\DMX Tools" and also enable "Import-Export: UV Layout". Click save as default then you can cancel the user preferences window.

2.If you want to build your hat around the heavy model to make it easier, download this: http://media.steampowered.com/apps/tf2/workshop/TF_heads.zip
Make sure you extract it to a location. Then in blender go to file->import->wavefront(.obj) and select the heavy.obj you downloaded.

3. Create your model, I'm not going to explain how to model with blender, there are plenty of tutorials on youtube.

4. Once you have created your model you need to mark seams. These are the places you will cut it to make a "2d net layout" so to speak. It is called the uv layout. For the next few steps make sure only your hat is selected, and not the heavy model.

5. In blender drag the 3 grey diagonal lines in the top right hand corner to the left. This will allow you to have two different views. Then click the small white cube icon for the second view and change it to "UV/Image Editor". Then, in edit mode, select all of you item and press U then click Unwrap. The UV layout should appear on the right. After that you can try to move around shapes in your UV layout to utilize as much space as possible.

6. With all of your UV layout selected, press the "+ new" bar just below it then set it to 256 by 256 then click OK (for a weapon, 512 by 512 would be good). Now we will bake the model. Select all of your UV layout then click the small world icon on the right hand side of the screen. Enable Ambient Occlusion, click Approximate, enable Pixel Cache and set the correction to 1. Then click the camera tab, set the bake mode to Ambient Occlusion, set the margin to 8, and finally click bake. You now have a base texture that you can colour/edit later.

7.Next, whilst making sure all of your UV layout is selected, click UVs->Export UV Layout. Call it helmet_uv and save it in the helmet folder.
Then click image->Save A Copy and call it helmet_ao and put it also in the helmet folder.
Applying texture
8.Use your texturing application to change the colours of the helmet_ao.png. You could also just make your own fresh texture without the ambient occlusion one by importing the helmet_uv.png and making a texture on top. Once done save the texture as helmet.tga (make sure its saved as a tga format).
Then in blender apply this new texture to your UV layout. This is done by selecting Image->Replace Image and selecting your tga.
Then in the bar right below the UV layout which says "untitled" as default, make sure it is helmet.tga If it isn't, just rename it.
Also click the material icon on the right hand side of the screen, which looks like a circle with dark red and light red. There should be a material there called "Material". It may be called something else, but in any case, rename it to helmet.tga
Compiling
9.Open GCFScape and navigate to C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf and open "tf2_misc_dir.vpk"
Go to models->player->items->heavy and drag and drop one of the heavy hats into any location on your drive (I suggest you make a folder to put them in to make it more tidy, and make sure you drag and drop all 6 files).
Then create another folder and call it anything. In this example we will call it "output". Then open up MDLDecompiler, go to the location you dropped the 6 files and open up the mdl then choose the output directory as the "output" folder you made and click extract (or whatever you click to make it decompile)

10. In your output folder you should now have an smd file and a few other files. In blender, in object mode, select your hat and press N. Make sure all 3 locations and rotations are set to 0 and all 3 scales are set to 1. It does not matter if your hat moves position or changes size.

Then in EDIT MODE (IMPORTANT!) select all of your hat and move it back onto the heavies head. KEEPING IN EDIT MODE rescale the hat to the correct size.

Next change to object mode and delete the heavy model and all the bones too. Then deselect all, then click file->import->Source Engine (smd....) and navigate to the output folder you made earlier and import the smd. The model of the hat you chose should now show in blender (eg. if you chose the Hound Dog then the Hound Dog will show up.) It doesn't matter which hat you chose. Then deselect all again then select just your hat.

IN EDIT MODE select all of your hat and superimpose (place directly on top) your hat on to the one you imported. Use your common sense when doing this to know that the internal rim of the hat (the part where the heavies head goes) should be in the same place. You may also have to rotate your hat remember keep in edit mode for this too. Keep in edit mode the whole time you are superimposing your hat on to the other one.

Next we need to delete the other hat we imported, but at the same time keep the bip_head bone that came with the hat. The easiest way to do this is to do this:
Go into object mode and select the other hat you imported, then go into edit mode and select all of the hat and delete it. The bip_head bone should remain. If there are also other bones which are not the bip_head, delete them.

11. Now we need to parent the bip_head to your hat. Remember that the key to select multiple objects in blender is shift. In object mode first select your model then select the bone and press ctrl+P and select "with empty groups". Then in edit mode select all of your hat and click the object data tab (its the icon that looks like 3 squares joined with lines to make a triangle). In the Vertex Groups panel select the bip_head bone, and click assign.

12. Go back into object mode and select your hat, then click the object tab icon (with the orange square) and whatever the object is called, rename it to helmet
Then click file-> export->Source Engine(.smd)->helmet.smd and export it to your helmet folder. Now exit blender
Make sure in your helmet folder the smd file is called helmet.smd otherwise rename it.

13. Go to the ouput folder and copy the qc file, the idle.smd and the phymodel.smd to your helmet folder.
Rename the qc to helmet.qc
Then open helmet.qc with notepad++
Delete the $cd "<filepath>" line
Delete the $cdmaterials "" (NOT the other $cdmaterials with the file path)
In this example we are not making the hat paintable so delete the five lines involving skinfamilies. It should look like this:

$texturegroup skinfamilies
{
{ "models/player/items/heavy/randomhat.vmt" }
{ "randomhat_blue.vmt" }
}

Delete any lines with double quotes at the start, as they are just comments. They look something like this:

// Model uses material "models/player/items/heavy/randomhat.vmt"
// Model uses material "randomhat_blue.vmt"

Finally, the rest should be pretty obvious.

Change: $modelname "player/items/heavy/<a heavy hat name should be here>.mdl"
To: $modelname "player/items/heavy/helmet.mdl"

Change: $model "Body" "<heavy hat name>.dmx.smd"
To: $model "Body" "helmet.smd"

The line with $cdmaterials "models\player\items\heavy\" should be left the same because we will put the texture in the same folder as all the other ones.
Save and then you can close notepad++

14. Now we need to make sure the necessary folders (directories) exist

Make sure: C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\materials\models\player\items\heavy exists. If not, create all the folders necessary so that this directory does exist

Also make sure C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\models\player\items\heavy exists, and again, if not, make the necessary folders

15. Open up VTFEdit and import helmet.tga from your helmet folder. Save it as helmet in the directory C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\materials\models\player\items\heavy (yes this is the directory you created just a minute ago).

Then open up GCFScape and navigate to C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf and open "tf2_misc_dir.vpk"
Go to materials->models->player->items->heavy
Select a hat vmt file for heavy hat with similar shading/lighting to yours and drag and drop it into C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\materials\models\player\items\heavy

For example if your hat was a hairpiece for heavy, you would want lighting effects similar to the Hound Dog, so you would copy hounddog.vmt to C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\materials\models\player\items\heavy

Then rename that vmt file to helmet
Open it up and
change: "$baseTexture" "models/player/items/heavy/<heavy hat name>"
to: "$baseTexture" "models/player/items/heavy/helmet"

Note: if your hat turns out to look a lot different to your texture ingame, try copying a different vmt file.

16. Finally open up GUIstudioMDL and it is normal for it to show some error/notification about filepaths, just click OK. Go to Config->Set Orange Box Tools Path and go to C:\Program Files (x86)\Steam\steamapps\<your-username>\sourcesdk\bin\orangebox\bin (when the second bin folder is highlighted click ok). If you did it correctly it shouldn't show any message. Make sure Team Fortress 2 is selected in the drop down box. Then click file->load QC file and go to your helmet folder and open helmet.qc
Then click compile, and if everything was done correctly there shouldn't be any errors.

Note: if you get "unable to find gameinfo.txt" replace gameinfo.txt in C:\Program Files (x86)\Steam\steamapps\<your-username>\sourcesdk\bin\orangebox\bin\vconfig with gameinfo.txt in C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf

Note: if you get a "MountAppFilesystem() failed" error do the following:
Open notepad and paste the following code:
"C:\Program Files (x86)\Steam\steamapps\common\team fortress 2\bin\studiomdl.exe" -game "C:\Program Files (x86)\Steam\steamapps\common\team fortress 2\tf" mdldecompiler.qc
pause
Save it as a .bat file in the directory that guistudiomdl is in. Run it and now retry step 16.

If you go to C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf\models\player\items\heavy there should be 6 new files!
If not, they may be in C:\Program Files (x86)\Steam\steamapps\<your-username>\Team Fortress 2\tf\models\player\items\heavy so in that case just copy them over.
You have completed your tutorial :D

You can view your hat by clicking workshop in tf2 and loading the test map. Then press F7, select the class the item is for, and in headgear load <your-hat>.mdl
Example Hat (with LODs and team colours)
You can download the files for one of the hats I've created called The Tartan Topper http://steamcommunity.com/sharedfiles/filedetails/?id=125813658
Visit here to download {LINK REMOVED}

I have included this so you may compare your hats files so it is easy to spot any errors in your qc, vmt etc.

You may also notice that it is team coloured and has 4 LODs. These are both fairly easy to implement and you may figure out how to add team colours merely by looking at the qc. For example it has some extra code for skinfamilies, and two vmt's and vtf's exist for each colour.

LODs are slightly harder to add but again you may figure out how to add it just by looking at the qc. For example it has an extra section for LODs at the bottom. The 22, 33 and 44 correspond to the distances at which each LOD should occur. 4 smd's exist for each LOD.

Hopefully I will be adding a section to this guide for team colours and LODs shortly.

If you just wanted to see a custom hat in action you can copy the material and model folders to C:\Program Files (x86)\Steam\steamapps\common\Team Fortress 2\tf then load the test map in tf2, press F7 and load tartan.mdl
32 Comments
↭ Dэʟɪʀɪᴜм ↭ Sep 14, 2022 @ 8:14am 
Is there a way to make parts of hats glow?
MetaName Apr 6, 2021 @ 5:22pm 
The download link no longer works. Is this intentional?
Kaiser Akita Jan 26, 2021 @ 4:53am 
So its not possible to use a software like 3DSmax ? Its only blender ?
Space Bear Feb 8, 2020 @ 5:13pm 
VTFEdit doesn't work for team fortress 2 files anymore
TinaJd187 Jan 8, 2017 @ 11:12am 
do i download the installer or archive for GCFScape?
also when o go to put MDLDecompiler in program files, i cant find anything related to my username. help?
Monsterman  [author] Apr 26, 2015 @ 12:58pm 
Just a heads up, I have no idea if this guide still works with all the updates and the new tf2 ingame importer etc. I'm also sorry I haven't replied to any messages. It's been so long and I've actually forgotten almost everything about making hats.... I may have to use my own guide again to refresh my memory xD

Anyway, does anyone know how the tf2 ingame importer works? I may add another section on it but it would be helpful if someone could tell me what I would do differently if I were to use to ingame importer. Thanks =)
Sunny Superficial Dec 2, 2013 @ 3:47am 
Thanks for this.
Doctor Too-Much Oct 19, 2013 @ 6:47am 
good word by word tut. works well, model, qc file, file directories all setup and ready to go etc.. sad thing is, i am not able to compile anything. neither with guistudio nor with the smd tools in blender. tf2 ingame importer too. error code at the end of the log. no workaround helped so far. all i get is errorcodes and workarounds which dont solve anything....
Nanakisan Oct 10, 2013 @ 8:32pm 
I have a interesting question for you. I intend to make a simple misc for the spy that really suits him. However modeling i'm ok with and ...maybe texturing. The only thing that will escape me is i want to apply a particle effect to it. Mainly for aesthetics related to the item. How does one go about adding particle effects?
Monsterman  [author] Aug 29, 2013 @ 7:31am 
@Snipe Thanks mate, jigglebones, paintability and glowing have been the three things I've always wanted to know how to do =) And yeah that's absolutely fine ^^