Team Fortress 2

Team Fortress 2

379 ratings
Creating Animated Sprays
By Jimo
I will explain how to create an animated spray in Team Fortress 2. This technique can also be applied to other Source games that allow animated sprays. For this guide you will require Adobe Photoshop, GIMP or PAINT.NET and VTFEdit.
This guide will explain how to create an animated spray in Team Fortress 2. This technique can also be applied to other Source games that allow animated sprays.

What You Will Need
Before we get started you are going to need a few tools so you can follow along with the guide.

You will need some form of image editor. In the guide I will be using Adobe Photoshop CS5 but other revisions of the program should work just fine. You can use GIMP or PAINT.NET as a free alternative to Photoshop as well.

Additionally you will need VTFEdit (Valve Texture File Editor) which is a tool used to convert your image in to the game world. I have provided links to all of the required software below.

Getting Started
Before we start you will need to find something you want to turn in to your spray. I'm a big fan of Adventure Time, so I found this GIF of Gunter which I will be using for this guide.

The next few steps in this guide will show you how to break an existing GIF down so you can fit it within the size limits that the game has. If you have your own design, you can step ahead.

If you are feeling adventurous you can add transparency to your animated spray. Combine the techniques in this guide with my transparent spray guide to see what you can come up with.
Image Preparation
In order to make your spray animate it has to fit within the size restrictions. The full GIF cannot exceed 512 KB so this means a GIF such as the one we are using will be far too large. It also has to be either:

  • 512 by 512 pixels (This size is not recommended for animated sprays)
  • 256 by 256 pixels
  • 128 by 128 pixels

Because we want to make it as small as possible we are going to be using 128 by 128 pixels.

Open up Photoshop and navigate to File > Open and select your GIF. You will notice that when Photoshop opens the file it will pull up each frame of the GIF on its own separate layer, which is really handy for editing it down.

The resolution of the GIF right now is 499 by 281 pixels. In order for it to work in TF2 we will need to change that to one of the sizes listed above. Seeing as all of the interest in the image is on the penguin I am going to create a new canvas by going to File > New and setting the height and width to 128 by 128 pixels.

Open up the original image and the new smaller canvas side by side. Select every layer on the original image so they are all highlighted in blue, and then drag and drop the layers on to the smaller canvas.

With every layer selected on our new 128 by 128 pixel image, select the Move tool and make sure you have Show Transform Controls turned on located on the top bar.

Grab one of the corners and hold down Shift on your keyboard. This will keep the image constrained perfectly so it's impossible to make it look squished or deformed.

This is what mine looks like at this point.

We now have a 128 by 128 pixel image loaded in Photoshop with every frame we need to create a loop. In order for it to fit the size requirements we will need to shorten the loop, which is what we will be doing in the next section.
Shortening the Loop
As it stands our image currently has 18 frames, within those 18 frames the bottles clank together three times, while the mouth and the eyes open once. This means we have some room when it comes to deleting frames to make the loop shorter.

You can play around with the frames by showing and hiding them using the eye button located on the left hand side of the layer. I've highlighted this in the image below.

In my example I deleted everything but four layers. This creates a loop with only four frames which means the size will end up being rather small. The loop won't be perfect, but that's the nature of the beast.

You will now need to save each frame individuality. Hide every layer but the first frame and do File > Save As... and choose Targa (.TGA) as the image type. Name the image "frame1". Repeat this process until you have saved every frame in order in to its own TGA file.

You should now have four separate TGA files, all of which are a different frame in your animation.

Creating the VTF with VTFEdit
We're getting closer and all that is left to do now is convert the TGA images in VTFEdit to a single VTF. If you don't have VTFEdit yet, you can download for free here.[] For those wondering, VTF stands for Valve Texture File.

Choose File > Import and Shift click every TGA file you just created. The screen should look similar to this right before you click Open.

After you open your TGA files you will be greeted with a VTF Options menu. Below are the settings which I used, I changed my clamp to 128 by 128 as that is the size of the images, but everything else is set to the defaults. I've attached a screenshot of what I used below.

Your animation is now loaded in VTFEdit. If you would like to preview it you can do so by clicking on the Play Button located on the left hand side.

The last thing we need to do in VTFEdit is check two options under Flags on the left. Make sure No Mipmap and No Level Of Detail are checked, this will ensure the spray appears high quality in the game no matter who is viewing it. I've highlighted these settings below.

All you need to do now is File > Save As.

You will also want to do Tools > Create VMT. Simply choose the defaults when you get the options window for this, and select Create. VMT stands for Valve Material File.
Importing Into TF2
You have now finished creating your spray, and the only thing left to do is try it out. All you need to do is paste your VTF and VMT file in to your TF2 directory. For most people this is located here:

VTF: C:/Program Files/Steam/steamapps/common/team fortress 2/tf/materials/VGUI/logos
VMT: C:/Program Files/Steam/steamapps/common/team fortress 2/tf/materials/VGUI/logos/UI

If you are missing any of those folders, simply create them.

Once you have everything in the correct directory, load up TF2 and go to Options > Multiplayer. Underneath the Spraypaint Image tab you should now see your brand new spray.

If it's not on the drop down menu you will need to choose Import Spray and navigate to it within the Steam directory. If the preview of the spray appears to be either flashing, or black, that doesn't exactly mean it's not working, you'll need to try it in game to find out.

Apply your changes and join a server, if everything was done correctly you should now be finished! Keep in mind that some servers disable sprays as part of their config.

I created a short YouTube video showcasing how my spray turned out. The speed of it is a restriction of the Source engine, unfortunately there is no way around that at this time.

If you would like to download my Gunter Spray you can do so by clicking here[].
Closing Notes
If you have any questions or comments regarding this guide please feel free to leave a comment below or get in touch with me on Steam or through my website[].

You can also check out all of my other Steam Guides here.
< >
Oct 23 @ 7:16pm 
It seems jungle inferno has totally broken animated sprays, all of mine show up but are now static sprays. Rest in peace masturbating furry girl, rest in peace.
Luna Aug 24 @ 12:43am 
The killer is in the math. 262144 pixels (512) @ 16 bit color will end up at exactly 512 KB. So will 1024x @ 4 bit. The show stopper is metadata and things like mipmaps, when removed will bring a file down to filesize + .063 KB. RIP.
MasonatorRoblox Aug 10 @ 10:59pm 
Crippling depression has struck me, for I have realized that the file size is 512.359KB
MasonatorRoblox Aug 10 @ 10:30pm 
I just realized mine is 1000KB. No wonder it wasn't working.
depthbomb Jul 17 @ 11:01pm 
If you are having trouble with the sprays appearing invisible despite being under 512kb, try saving both the vtf and vmt file in a different directory. I saved mine to /tf/custom/sprays/ and the spray worked.
Juyo Apr 6 @ 11:01am 
Mine ended up with 513KB..... fml
Coyotein Mar 17 @ 5:52pm 
I converted the spray and did everything correctly, but it won't let me import the spray in tf2. I can find the file in the directory, but it won't let me import it.
VorBex Feb 17 @ 2:12pm 
I spent 2 hours trying to get this correct, and when I finally fucking got it all done, it doesn't work. I want to fucking kill myself right now, for the love of god, what did I do wrong?
ViciousViridian Feb 17 @ 1:01pm 
Spiffy, if a frame doesn't have all of the image, make enough previous frames visible so that the image is filled in.
Lord Spiffy Feb 6 @ 9:53pm 
Using GIMP, any advice for when the image uses transparancy and each frame doesn't have all the image? The frames start with background and are alternating a clear (combine) frame and a partial (replace) frame. Other then copy/pasting the missing imagery frame by frame hopefully.