Creating custom Team Fortress 2 Sprays for a PC

Gaming Hobby

This little tutorial will cover making custom TF2 sprays. How to make a static spray, a transparent spray, and animated sprays.

First, to give credit where credit is due. I found the information on making sprays from a few blogs/sites. Unfortunately, there was no comprehensive information for dealing with transparency and animation so this article you are reading now attempts to bring it all together in one place. Here are the direct links to the articles I used as a base:

Tools you will need:
  • – An image editing utility like Adobe’s Photoshop ($$$) or gimp (Free!). The tool must supporting saving to TGA (Targa) file-format and must support Alpha channels (for transparency)
  • – VTFEdit (v.1.2.5 Full seems to be the latest though it was release on 9/14/2007, also requires the .NET 2.0 Runtime and the Microsoft Visual C++ 2005 SP1 runtime as well, which likely your computer already has)
A note on Spray Image Resolutions and Spray file sizes:

Resolution: Sprays resolution maximum is: 256 x 256 pixels
They can be smaller, but they can’t be larger! If they are larger the 256 in either width or height, the spray simply will not show.

File Size: Currently the Source Engine (the Valve game platform that Team Fortress 2 is built on) has a file size limit for sprays of 120 KB do not exceed that or the spray will simply not work. This usually isn’t an issue with Non-Animated sprays, but Animated ones use 1 image per frame so you’re probably not going to get more than 4 or 5 frames with a resolution of 128 x 128 (note that is smaller then the largest supported spray resolution, we choose that to allow for more frames.)

In all cases, when we import images into VTFEdit, they are re-sampled to align to a resolution that is a power of 2, this is due to the rendering engine and an optimization for faster and easier rendering. Suffice it to say. the engine just needs them that way. VTFEdit gives you a drop-down box to give you further control. It defaults to “Nearest Power of 2” but there are options for “Smallest Power of 2” and “Largest Power of 2”.

During the import, VTFEdit looks at the dimensions of the image, for an example, let’s say our image is 220 x 220. If the image’s dimensions do not align to a power of 2 in both their X and Y dimensions, VTFEdit figures out the next largest and next smallest even power of 2 to align to and re-samples the image to these new dimensions. It uses the value in the drop-down list as a guide-line. In our case the next smallest is: 128 x 128 and the next largest is 256 x 256. If “Nearest Power of 2” is chosen, since 220 is closer to 256 then it is to 128, 256 x 256 is used. If our image size was 130 x 130, the next smallest is: 128 x 128 (again) and the next largest is: 256 x 256 (again), and 128 x 128 would be used. If you select “Next Smallest Power of 2” it will always pick the next smallest value, and likewise, should you choose “Next Largest Power of 2” it will always choose the next largest.

How do I know what the next powers of 2 are? Well I wrote a simple program to dump a bunch out for me and I just compared 😉 Below is a convenient table for your use:

2 to the Power of         Dec. Value         Bin Value
2 ^ 0                            1                        0000000001
2 ^ 1                            2                        0000000010
2 ^ 2                            4                        0000000100
2 ^ 3                            8                        0000001000
2 ^ 4                          16                        0000010000
2 ^ 5                          32                        0000100000
2 ^ 6                          64                        0001000000
2 ^ 7                        128                        0010000000
2 ^ 8                        256                        0100000000
2 ^ 9                        512                        1000000000

Using square images (same X and Y dimensions) is easiest. But in the case of a rectangular image, the X and Y and handled separately, so an 65 x 130 image, using “Nearest Power of 2” ends up being 64 x 128, which may or may not stretch / compress your image inappropriately and you’ll want to either force the re-sampling or manually resample it with padding in the image to make the resolutions easier to work with. Square, as I mentioned is the easiest 😉

Usually, leaving the default of “Nearest Power of 2” is sufficient, but I feel it’s better to resample the image yourself during the image preparation phase of the procedure because it is likely Gimp or Photoshop have a highly superior re-sampler then VTFEdit. I’m not saying it is, I’m just saying it’s likely, especially as the tool hasn’t been updated in 2+ years at this point. Plus it’s nice to know what’s really going on under the hood.

A note on Team Fortress 2 directories for saving the Spray to:

Sprays are stored in 2 places for Team Fortress 2. By default they are:

C:Program FilesSteamsteamapps<STEAM_ACCOUNT_NAME>team fortress 2tfmaterialsVGUIlogos

C:Program FilesSteamsteamapps<STEAM_ACCOUNT_NAME>team fortress 2tfmaterialsVGUIlogosUI

where <STEAM_ACCOUNT_NAME> is the login name associated with your Steam account.

-If the C:Program FilesSteamsteamapps<STEAM_ACCOUNT_NAME>team fortress 2tfmaterials directory does not have a sub-directory called “VGUI” create a new folder with that name there.

-If the VGUI folder does not have a logos directory, create a new folder with that name there. Once the .vtf is in here, you can import it from here using the TF2 Options –> Multi-Player, Import Spray option and browse to this directory. The importing process will create a file with the same name as the .vtf file but will have a .vmt extension (not sure what that is though, any thoughts?) This will also copy the .vtf and .vmt to the logos/UI directory.

-If the logos directory does not have a UI directory, create a new folder with that name there. One the .vtf and .vmt files are in this directory, they will appear in the Choose Spray drop-down list for choosing.

A note on image file naming for use while importing to VTFEdit

For most cases it does not matter what you name the image file that you import into VTFEdit. Whatever the file is named, will be used by VTFEdit as the default .vtf name for saving but you can always type a different name.

For Animated Sprays, it DOES matter however. Animated sprays are created by making a series of images, 1 per frame, and giving them a sequential file name so that VTFEdit recognizes them as multiple frames for the same spray. Basically, they just need to be alphabetized so when VTFEdit sorts the multi-selected images, it sorts the filenames alphabetically and frame 1 goes to the 1st file, frame 2 goes to the second, and so on. For ease of use you could use filenames like: “1-MySprayImage.tga”, “2-MySprayImage.tga”, “3-MySprayImage.tga”, etc.

Summary of the process:

The process is relatively simple, create or find an image you want to use as a spray. Make sure it is cropped or scaled down to a resolution of (at largest) 256 x 256. Open VTFEdit, on the File Menu, choose the Import item. Browse to the spray image and select it, verify the VTFEdit import options are correct (the tool remembers it’s last settings so typically you’ll only need to set it up the first time you make a spray) and hit OK.

A screenshot of pretty useable settings follows:

Non-Animated Spray:

VTFEdit Non-Animated Spray Settings

Animated Spray:

VTFEdit Animated Spray Settings

Please note, the only difference in the above two screen-shots is the value of the “Texture Type” drop-down list item. Non-Animated sprays use “Volume Texture”, animated ones use “Animated Textures”. It would be fine to use an Animated Texture with a 1 frame animation, but I have found no information to say use one method or another. I’ve successfully created non-animated sprays with Volume Texture and animated sprays with Animated Texture.

At this point VTFEdit will display to you the imported image and you simply go to the File menu again, choose the "Save As” item, browse to your local logos directory and save the file with whatever name you’d like with a .vtf extension.

You’re ready to use it! Just start Team Fortress 2, go to Options, then the MultiPlayer Options tab, then press the import spray button and browse to your logos directory (as mentioned above) and choose the new spray. Click apply, connect to your favorite server and spray away!

VTFEdit makes the whole process of creating the .vtf file for use by TF2 a very easy process. The hard part is preparing the image before importing it into VTFEdit. Non-Animated, Non-Transparent images are the easiest, they only require the correct 256 x 256 or smaller size constraint. Transparency requires Alpha channels and TGA file format.

Some of the Articles I listed at the beginning have more detail on making transparent images and animation image preparation, I urge you to check them out if you are unsure.

Good luck!

Spray in action, click for larger view!

Here is a link to a Quicktime movie of the actual spray in game showing the animation. Not very exciting but enjoy! Click here to view the movie!