Making an Animated Texture

- By Raeven0
This tutorial was last updated on Jul 20, 2005.

The reader must be familiar with basic material creation in order to understand this tutorial.

We're going to make an animated texture. This special kind of texture contains several images written to the same VTF file, so that the images flash one after the other, much like an animated GIF.

As with normal material creation, we need TGA images whose dimensions are powers of 2. The TGAs we use must be 32-bit this time, though! Each frame of the animated texture you'd like to make must be a separate TGA image. The naming convention should be image000.tga, image001.tga, adding to the number until you reach the final frame.

All of these TGAs must be in some subdirectory of <game>/<mod>/materialsrc, so I will place mine in half-life 2/hl2/materialsrc/rae. Also in this folder must be a text file called image.txt (where image is the name of all of the images, minus the numbers and .TGA extension).

If I have five frames I want to combine into a single texture, this gives me the following files in half-life 2/hl2/materialsrc/rae:

- image000.tga
- image001.tga
- image002.tga
- image003.tga
- image004.tga
- image.txt

The text file, as mentioned in the material creation tutorial, contains special compile parameters for the material. In this case, the text file will tell us that the files marked 000 through 004 should all be compiled into the same VTF file.

Write the following into the text file:

"startframe" "0"
"endframe" "4"


Because of this, you can number the images however you like, as long as they go in order. startframe should be set to the first frame in the animation, and endframe to the last one.

If you have all your 32-bit TGAs and a proper TXT file to reference them, you must now compile the text file. Not all VTEX GUIs may support this, but since image.txt contains information for referencing the other textures, this is necessary. The GUI you use may have a special way of making animated textures; consult its documentation. For VTEX, just drag and drop the TXT file onto the VTEX executable.

If image.txt is compiled correctly, you will simply get a VTF called image.vtf. For instance, I would find that there exists a file half-life 2/hl2/materials/rae/image.vtf.

This VTF can now be referenced by a VMT and used as a normal texture. However, the VMT needs a small change to make it useful. Let's take a standard VMT for this texture:

"LightmappedGeneric"
{
   "$basetexture" "rae/image"
}


Inside the VMT, we can declare a few properties of the animation. Behold:

"LightmappedGeneric"
{
   "$basetexture" "rae/image"
   "Proxies"
   {
      "AnimatedTexture"
      {
         "animatedtexturevar" "$basetexture"
         "animatedtextureframenumvar" "$frame"
         "animatedtextureframerate" 30
      }
   }
}


In this example, we're calling on a proxy, essentially a special way of controlling material behavior, to set a few properties. Animatedtexturevar is the texture (in variable form) that should cycle through all of its frames; animatedtextureframenumvar is a variable in which the current frame will be placed; animatedtextureframerate is the framerate at which the texture will cycle through its frames, in frames per second.

Tada! Animated texture.

[With a special thank-you to Cheeko for getting me to try 32-bit TGAs. My meager 24-bit ones weren't working.]



Still need help? Ask your questions in one of our HELP FORUMS
Post A Comment
Name:
Email: Links Not Allowed In Comments
Comment:
What is the capital of France? Need Help?
Comments
Clay - May 19, 2009
Hmm Im using VTEXGUI 0.5 beta by Ti133700N
And this just doesn't work at all.
It still creates multiple VMT and VTF files even though I made the txt file. So obviously that software doens't work with animation. Can someone please recommend something that actually works?

I have tried like all possible ways I could think of by actually writing 000, image000, image000.tga etc in the txt file to see if that was the problem but it wasn't.

The images alone work but they wont become an animation which really bugs me.
Thx for any help
//Clay
Tal-N - Mar 25, 2009
The 32-bit TGA is the critical factor here. Without it VTEX simply does not function. I have tried applications like VTFEdit and despite saying they'll create an animating VTF they don't. The texture doesn't animate when in-game. You can create 32-bit TGA using a freeware app called Paint.NET.
Jonas - Sep 29, 2008
can these animated textures be controled in hammer? like a trigger that starts/stops it?
Derek CLifton - Apr 23, 2008
I'm working on the same thing. I'm trying to animate a texture with its normal map. I haven’t done it yet and was looking for a tut. But in my search I notice that your

"$bumpmap" "screencn"
needs to be re-named to

"$bumpmap" "screenc_normal"
This is because when you compile your textures it looks for the "_normal"
at the end of the name to compile the bump effect. Try that it might help.

Derek Clifton
If I get it to work I will re-post. :)
drschelter - Apr 2, 2008
This was useful, thx. Is there a way to
A) Randomize the starting frame of the animation
and
B) To switch frames in-game with the "use" button?
Javier DL - Oct 7, 2007
I have even a simpler question ; )
I have created the actual animated spray, so that is done. Now all I need is to slow down the speed at which it's playing.

These are the steps I follow:

1. So I open the VTM file that SprayR made, which is here:
I:Program FilesSteamAppsdrpeppercanhalf-life 2 deathmatchhl2mpmaterialsVGUIlogos

2. Then I replace its code for the one you have in this tutorial.

"LightmappedGeneric"
{
"$basetexture" "VGUIlogosdrpepperbcn32_000_ani"
"Proxies"
{
"AnimatedTexture"
{
"animatedtexturevar" "$basetexture"
"animatedtextureframenumvar" "$frame"
"animatedtextureframerate" 10
}
}
}

Could you please tell me what am I missing?

Thanks a lot Raeven0 : )

Javier DL
[1 extra comment]
All original content ©2006 EditLife.net. All Rights reserved. All files property of their rightful owners.
Get Firefox! Get Thunderbird! Get Notepad++!