Lafi's Step-By-Step Animated Spray Tutorial

Status
Not open for further replies.

Lafinass

Poster Extraordinaire
Joined
Oct 29, 2007
Messages
2,341
Today we are going to make an animated spray with transparency.

First some particulars. Sprays in the Source engine are composed of a VTF and a VTM file. The VTF file is an all purpose texture file used by Valve and is found in almost every nook and cranny of their games. The VTM is a descriptor for that VTF file.

- Limitations -
File Size: The VTF file must be under 128K. To be safe, aim for 125K.
Dimensions: The dimensions must be a power of two (16, 32, 64, 128, 256, etc.) and do not need to match. Many people swear by square sprays, but I find that a 256x128 can have 3 frames with transparency whereas a 256x256 is too large and 128x128 lacks detail. Note that the game's "Import Spray" functionality will make your spray square regardless of the dimensions you define, which is one reason I don't use it.

- Programs -
I use Photoshop. If you can't afford photoshop and are against piracy, choose your program of choice and find a tutorial on how to make TGA files with an alpha channel. I also use [link=http://nemesis.thewavelength.net/index.php?p=41]VTFEdit[/link] which is a free program. Simply select your version based on the .NET you have (1.1 or 2.0).

- Transparency -
VTFEdit will handle almost any file type, but for animated files you want to use TGA with an alpha channel. If you are not going for animation, you may want to use a PNG as it does blended alpha for transparency. This gives you a smoother, softer, edge to transparencies as well as doing varied levels of opacity.

- Animation -
Be warned, there is no way to regulate frame timing in a spray. If you need for a part of your animation to take longer the only means of doing this is to duplicate frames to create the illusion of frame timing, but this is very file size costly, so when you're planning your spray try and make it something with a constant framerate.

- The Process -
For this spray, we'll make a simple flashing eGO™. It will be 2 frames at 256x128 with transparency.

To start off we make the first frame in photoshop.

spray01.jpg


Now that you have the first frame of the animation, we're going to create the alpha channel. Hold CTRL+SHIFT and click on the little preview box of each layer you WANT visible.

spray02.jpg


What you should get is a shimmering dotted selection line around the border of everything that is supposed to be visible.

spray03.jpg


Switch over to the Channels tab and choose 'Save selection as channel' from the buttons at the bottom. This will create a new channel called 'Alpha 1'. If you click on the box to the left of the channel, it should put a red screen on the image. This red is everything that will be transparent.

spray04.jpg


spray05.jpg


Now we save this frame as a TGA by pressing SHIFT+CTRL+S, being sure 'Alpha Channels' is checked. On the next screen be sure '32 bits/pixel' is checked and 'Compress (RLE)' is not.

spray06.jpg


spray07.jpg


Now repeat this process for each frame. If you need to change what part of your image is transparent, be sure to delete the old Alpha channel by selecting it and clicking on the trashcan. Once you have all of your frames in TGA, we're going to open VTFEdit and choose 'File > Import'. Find the TGA files you just created, hold down CTRL and select the frames IN THE REVERSE ORDER YOU WANT THEM TO APPEAR. On the next screen, make your options match those in the screenshot below. We don't want it resized, we don't want mipmaps on a spray (provides varied detail at different viewing distances, but costs a great deal in file size), and we don't need a normal map.

spray08.jpg


You should be on the Image tab. Hit the 'Play' button to make sure the animation is in the right order and to look for any artifacts. VTF uses compression to create the animation, so try not to have any high contrast colors (Red and Blue for example) directly next to eachother without a decently thick black or white line dividing. And don't mind the epileptic framerate in the preview window, in game it is significantly slower. Next, click over to the Info window and verify the 'Size' is under 125K. If so, then you're ready to save this. You want to save the VTF to your steam folder in the subfolder 'steamapps\<USER>\team fortress 2\tf\materials\vgui\logos' where <USER> is your steam account name. Some of the subfolders may not exist (materials, vgui, and logos did not for me) and if so you must create them. Once this is done select 'Tools > Create VMT File' and then 'Create', this should save the VMT file wherever the last VTF file was saved. If not, navigate to the same subfolder of your steam directory.

Now just start up TF2 and choose the spray from the dropdown menu.

Morbid: Added Animated to the thread title for less confusion. :O
 
Status
Not open for further replies.

Latest posts

Back
Top