Left 4 Dead 2

Left 4 Dead 2

142 ratings
[L4D2 Modding] : VMT Edit for Modders
By Ellie
This guide aims to provide tutorials and explainations to L4D2 and other games Modders about what's possible to do with Valve Material files (VMT), with concrete examples and code. It will regullary be updated but is still being written.
Hello fellow modder =), since I like the modding community, I took some time to put this Guide together. Here, I am planning to prodive you some information about modding the VMT files. If you don't know that this is, I think this guide isn't for you :D.

I won't explain here what VTFEdit is and how to complie an addon etc., I assume that you already know all of this and are here to learn some new things. Ready ? Just select what you'd want to do in the list on your right =).

In this guide, the software I'll sometimes use to present things is Adobe Photoshop CS5. Everything can also be done in GIMP or PAINT.NET, but I think that Adobe Photoshop is easier to use for most things :)

If you have a question, don't hesitate to ask it in the comments, I'll answer as soon as I can ;)
[Easy] : Animated textures
Description :
If you want to transform a texture in what would look like an animated GIF, you're at the right place. This technique is used in many mods and there's basically 2 main uses :
  • Creating the illusion of movement (f.e. in an "Animated TV" mod)
  • Adding a variety of different textures to a same object, giving the illusion of a bigger variety of the same object. (f.e. in a "Different Brands Soda Machine" Mod)

How to :
  • STEP 1 : Create the textures for every single frame (= if you want an animated mod, create enough textures to make the animation fluid ; = if you want a "variety" mod, create the textures you want, for example 5 different soda machine textures).
    The textures MUST have the same size and MUST be in the same folder to be selected and MUST be in the alphabetical order you want them to appear (that means, if you name your textures 1.tga, 2.tga, 3.tga etc., the animation will strat from 1.tga and so on in alphabetical / alphanumerical order)
  • STEP 2 : Open VTFEdit and go to "Import" as usual
  • STEP 3 : Press and do not release the "CTRL" key of your keyboard, with the CTRL key still pressed, click on your different textures ; this allows you to select multiple images
  • STEP 4 : Release the CTRL key when you're done, and click on Open (as usual)
  • STEP 5 : If is has worked, you should be able to increment the "Frame" value and visualize the other frames. Your texture is now "multiple" frame, save it.

  • STEP 6 : Now open the corresponding VMT file and paste this at the end, BEFORE the final } :
    "Proxies" { "MaterialModifyAnimated" { "animatedtexturevar" "$basetexture" "animatedtextureframenumvar" "$frame" "animatedtextureframerate" "###" } }
  • STEP 7 : You're almost done, the only thing that you still need to do is to replace the ### by a number to make your texture change at the right speed. The only thing you have to do is to divide 1 by the number of seconds between each texture and replace the ### by this number
    - Example 1 : If you want that the image changes every 50 seconds ==> 1/50 = 0.02, so you must write "animatedtextureframerate" "0.02"
    - Example 2 : If you want that the image changes every 0.1 second ==> 1/0.1 = 10, so you must write "animatedtextureframerate" "10"

[Easy] : Glowing Textures
Description : Do I really need a description ? This sections will explain how you can make certain elements of a texture glow, it can be used in a lot of different situations and (yeah ofc.) to give the survivors an advantage on the infecteds ;)

How to [1] : All-Glowing Texture : (If you want all the object to glow and not only parts)
  • STEP 1 : Open the VMT file
  • STEP 2 : Change the first line, that spells "VertexLitGeneric" by this :
Yeah... that's that simple... and it works with almost anything (unlike the next method).

How to [2] : Partial Glowing texture : (If you want some parts to glow)
Basically, what you need to do is to create a new greyscale texture of your initial texture that you want to make glow, and paint in black the parts you don't want to make glow, and in white the ones that you want to make glow (Black = No Glow, White = Max Glow).
Beware : White makes the texture glow a LOT, most of the time you'll only need dark or very dark grey. Here's an example below :

The "Glow-Mask" texture : the parts in dark grey will make the same parts of the original texture glow.

The "original" texture that will have this mask applied to, you can see the arrows indicate the Display and the Soda Selection, you can see recognise them in the previous picture.

This can even be done in MS Paint, just import the original texture, cover with dark grey squares or circles what you want to glow and then color the rest in black.
  • STEP 1 : Create the "above explained texture mask (greyscale)"
  • STEP 2 : Import and save the texture mask with VTFEdit in the same folder as the other .vtf texture, give it a new name (any name will do, I've put vending_hdn_machine01_mask.vtf in the example below)

  • STEP 3 : Open the VMT and add these 2 lines :
    $selfillum 1 $selfillummask "########"
  • STEP 4 : Replace the ####### by your greyscale texture mask path, in my case, the $basefexture was Models/props_office/vending_hdn_machine01 and the $selfillummask was Models/props_office/vending_hdn_machine01_mask.

Full VMT Material Example :
VertexLitGeneric { $basetexture "Models/props_office/vending_hdn_machine01" $surfaceprop default $selfillum 1 $selfillummask "Models/props_office/vending_hdn_machine01_mask" $selfillumtint "1 1 1" }
[Easy] : Infinite Scrolling Textures
DESCRIPTION : Allows you to make a texture scroll in any direction. This method will give bad results on textures that contains multiple little "parts" of the model. It can be used to make conveyors belt or sometimes revoving objects.

  • STEP 1 : Add this in the VMT :
    "Proxies" { "TextureScroll" { "textureScrollVar" "$basetexturetransform" "textureScrollRate" 1 "textureScrollAngle" 180 } }
  • STEP 2 : You can modify the angle and the scroll rate, I think it's self-explainatory. The "rate" is in "complete scroll per second", a value of 1 means that the texture will do a full scroll in 1 second.
[Easy] : Team Depending Textures
DESCRIPTION : Allows you to create a texture that is different depending if you're playing as an Infected or a Surviror in Versus Mod.

  • STEP 1 : Refer yourself to "[Easy] : Animated Textures" if you don't know how to make a multiple frame VTF.
  • STEP 2 : Prepare the texture for the infected and the texture for the survivors, place them in the same folder and make sure the texture for the suvrirors is first in alphabetical order (so it will become frame 0 in your VTF), then import andsave them with VTFEdit (at that point, you should have the texture for the survivors in frame 0 and the one for the infected in frame 1)
  • STEP 3 : Add this in the VMT above the final }
    Proxies { PlayerTeam { "team" 3 "resultVar" $frame } }
EXAMPLE : (with trash_00.vtf / vmt)
< >
specify Feb 3 @ 5:17pm 
Thanks, very helpful
Ellie  [author] Feb 1 @ 12:36pm 
@DarkMech: Thechnically yes, but it requires some "heavy" coding that I never actually test :P
DarkMech Feb 1 @ 12:17pm 
I don't want remove frames to my animation X(, I could divide in two parts. Can the animation be played one after another in the same place? QuQ
Ellie  [author] Jan 31 @ 1:33pm 
@DarkMech: No but there's a limit of 62Mb (approx.) per VTF
DarkMech Jan 31 @ 1:25pm 
I have an animation of 199 frames that I can not played, I reduced it to 88 frames by cutting part of the animation and now is playing but incomplete. Is there a limit of frames per animation or something like that?
ludicrous Sep 25, 2017 @ 10:45am 
@Ellie: ok, man. The game reads only “max” string.
Ellie  [author] Sep 25, 2017 @ 10:10am 
@Pantaloon : Remove the AnimatedTexture block, you don't need it.
If the animation is not played because you see the last frame, it means that it had already finished when you saw it.
ludicrous Sep 25, 2017 @ 10:05am 
@Ellie: Thanks bro. I did such as you said but then the animation is not played :alyx:
"animatedtexturevar" "$basetexture"
"animatedtextureframenumvar" "$frame"
"animatedtextureframerate" "16"
rate "16"
resultVar "$frame"

min "0"
max "119"
srcVar1 "$frame"
resultVar "$frame"


Ellie  [author] Sep 25, 2017 @ 9:29am 
@Pantaloon : If you want to delay the start of the animation, you can add
initialValue "-60"
between rate and resultVar. -60 means it will wait 60sec before starting.
Starting the animation when you first look at it is more complex and impossible for most things.
Ellie  [author] Sep 25, 2017 @ 9:24am 
rate "1"
resultVar "$frame"

min "0"
max "10"
srcVar1 "$frame"
resultVar "$frame"

Replace "rate" by the speed you want (1 = 1 frame per second) and "max" by the maximum frame of your VTF.