Left 4 Dead 2

Left 4 Dead 2

287 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.
   
Award
Favorite
Favorited
Unfavorite
Introduction
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 :
    UnlitGeneric
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.

HOW TO :
  • 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.
EXAMPLES :
http://steamcommunity.com/sharedfiles/filedetails/?id=439231882
https://steamcommunity.com/sharedfiles/filedetails/?id=448300441
[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.

HOW TO :
  • 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)
124 Comments
mekochengyt Jul 8, 2024 @ 2:05am 
does is possible to animate weapon textures?, i try animate but it doesnt work
Supermito Mar 26, 2024 @ 7:28pm 
can you make selfillum glows less bright? how
Yoimiya Jul 22, 2021 @ 5:01pm 
@Ellie : I have basically done what I want. I want to appreciate you.
I found a page on the Valve Developer Community where I learned about some parameters of the RES files. Here is the link : https://developer.valvesoftware.com/wiki/Understanding_VGUI2_Resource_Files . Hope to help people who see this.
Ellie  [author] Jul 22, 2021 @ 10:15am 
@粼光星天 : Sorry, but not as far as I know. I myself did very little things with HUD so I cannot help you much.
Yoimiya Jul 20, 2021 @ 1:13pm 
Hello ellie, I want to create my own hud. But I dont know how the res files work. Are there some tutorial about it?
十年公交男 Feb 27, 2021 @ 6:40am 
OMG,I finally got the tutorial I wanted.THANK YOU,Ellie!
Ellie  [author] Feb 19, 2021 @ 5:58am 
@♡ Azuki ♡: You're welcome! If you want each door to have a random pic, you can also follow this Guide: https://steamcommunity.com/sharedfiles/filedetails/?id=2389582650 ;) (depending on what door you modify)
cp17 Feb 19, 2021 @ 12:27am 
TY TY TY BROO I'VE MADE AN ANIMATED DOOR WITH 10 HENTAI GIRL PICS THX
I'M SO HAPPY AHHAHAHAHAHAH
cp17 Feb 18, 2021 @ 7:48pm 
Oh, I re-readed it 100~ times and now I understand it. Tnx I'll give u an award when I get my points.
Ellie  [author] Feb 18, 2021 @ 1:24pm 
♡ Azuki ♡ : Read [Easy] : Animated textures