This guide is meant to introduce the average player of Source engine based games (Left 4 Dead, Team Fortress 2, Counter Strike: Source and many others) to the world of the engine’s spray feature and it’s transparency and animation options.
I will be mostly using Photoshop terms, but you can create transparent or animated sprays in any other suitable software (like freeware GIMP or Paint.net) using similar methods. Mind that at least a tiny bit of experience with graphics editing is required in order to do this properly (at least in Photoshop, it can be a lot easier in GIMP and Paint.net in many cases).
Source can use 4 formats – JPEG, BMP, TGA and VTF. While it is easy to crop and resize a JPEG to use as a spray, it cannot have any transparency applied to it (simply a JPEG limitation). Since BMP is inferior due to various reasons, I will only talk about TGA (Truevision Targa) format and it’s transparency. VTF is the Source SDK compiled texture file, which is created during any of the other format import process (or you can create it yourself using VTFEdit).
Valid spray dimensions are (512×512) 256×256, 128×128, 64×64 etc… Anything less /2 down to the size of 1×1 will work, but will be too small at the same time. The maximum importable file size is currently 120kb. 256×256 is probably the best choice.
Layer based editors usually use a default checkerboard background that defines the alpha channel. With GIMP and Paint.net, that is the case for TGA alpha channel definition, just like with PNG and others. Unfortunately, it does not work that way in the almighty Photoshop which makes TGA editing way less straightforward (although it does make a bit more sense in case of TGA itself and gives you more options that you don’t really need in this case however).
In order to save a TGA with transparency in Photoshop, you have to create an alpha channel. Basically everything that is not covered by the alpha channel will be visible in the final texture. In case you are creating just some text or importing an already transparent content, feel free to simply refer to this tutorial at this point as I will be focusing more on methods on how to achieve transparency when using an original JPEG graphic or a format with no existing transparency, which is many times desired to create a new spray from existing content.
At this point, you need to do everything manually since every image and the best methods to achieve perfectly clean transparency cut-out varies. I can only show you your new best friends in that regard, which are the following tools, accesible either through the usual toolbar, right click menu or the Select menu in the main bar:
Magic Wand tool is useful for selecting a specific range of a color with adjustable intensity (Tolerance).
Color Range is useful to select multiple levels of a single color. This process is handy when cleaning up images that highly blend in a single color background or slight gradients (many cases).
Refine Edge is a great way to adjust the edges of your selection to avoid the jaggy effect that Magic Wand produces.
Similar resembles the Color Range, but is automatic and not adjustable (usable when you already have made a selection).
Expand /Contract are useful to hard adjust the current selection by the specified amount of pixels. This is helpful in reducing the undesired effect of “white halo” that can appear on your spray ingame or when you don’t want to bother with the perfect alpha levels.
Select Inverse does exactly what it says and can be quite handy in the whole process.
Save Selection / Load Selection are meant to be used after every step of the cleaning up process. The current selection can be saved as a new channel and thanks to the “Add to Channel” functionality, you can easily swim through the whole cleaning up process in multiple steps.
You might as well create the alpha channel manually in the Channels tab and then apply the selections to it if you so desire.
GIMP, Paint.net TGA
The checkerboard background in these editors serves as the alpha channel definition when saving TGA, so you don’t need to dabble with applying transparency through a new separate channel. This simplifies the process a lot and in many cases produces way better results than creating channels from selections in Photoshop does with no white halo whatsoever. Due to the lack of advanced selection tools however, these editors are not the best choice when it comes to perfection.
Save in the TGA format with 32 bits/pixel, Alpha Channels ticked, no RLE compression (!). Once you have the TGA, you can import it through the game menu and it will automatically get converted to the Source native VTF format.
The Source internal VTF conversion is not perfect, so using VTFEdit to generate the VTF/VMT files yourself can produce better results with less halo (which can be the case of Photoshop created TGA). Just note this if you want to produce precise masking with the least amount of white halo.
The Source native VTF format is in fact a container and can hold several frames in a similar fashion as GIF does for an image sequence. The only limit to the number of frames used is the maximum file size of importable content (120kb atm). Why not more? Well obviously because of network traffic needed to transfer the content to other players in-game. For compiling the frames into a VTF file, you will need a tool like VTFEdit.
Now – think of the texture animation process as a sequence of a couple spray textures you created. For ex. – you want to create a blinking eye spray with 2 frames repeating. Well – all you have to do is independently create each of the frames (one with the eye opened, one with the eye closed) and convert them to VTF with the VTFEdit tool mentioned above.
- When you have your frames ready, name them in an incremental fashion (1.tga, 2.tga, 3.tga…).
- Open up VTFEdit and press CTRL+I (or File -> Import). Select the frames and click OK.
- A lot of settings will come up – ignore them unless you know what you’re doing and click OK. You can then view the sequence by pressing Play. In the Info tab, make sure your spray is not bigger than 120kb.
- Save the sequence in the custom sprays directory (default C:Program FilesSteamsteamappscommon……materialsvguilogoscustom)
- In VTFEdit, click Tools and Create VMT File. Save it to the custom spray dir as well (this file has directory structure saved inside, so if you for some reason did not save the VTF in the directory I mentioned, you will fail).
- Import through game menu and enjoy.
Useful console commands
cl_playerspraydisable 1 – a client-side console variable that will make the spray textures invisible for you (useful when you don’t want your kids to see hentai porn or jumbo wing-wangs during online games)
Paint.net – a freeware editor equipped with all the mandatory features
GIMP – another freeware GNU editor
VTFEdit – Source SDK texture compiler (for animated sprays)
Photoshop VTF plugin – for creating simplified VTF files from Photoshop (32bit only)