Left 4 Dead 2

Left 4 Dead 2

138 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.
 
Rate  
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)
< >
83 Comments
Ryuji-amude Sep 25 @ 10:45am 
@Ellie: ok, man. The game reads only “max” string.
Ellie  [author] Sep 25 @ 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.
Ryuji-amude Sep 25 @ 10:05am 
@Ellie: Thanks bro. I did such as you said but then the animation is not played
//--------------------------------------------------------
"Proxies"
{
"AnimatedTexture"
{
"animatedtexturevar" "$basetexture"
"animatedtextureframenumvar" "$frame"
"animatedtextureframerate" "16"
}
"LinearRamp"
{
rate "16"
resultVar "$frame"
}

"Clamp"
{
min "0"
max "119"
srcVar1 "$frame"
resultVar "$frame"
}

}

}
//--------------------------------------------------------------------
Ellie  [author] Sep 25 @ 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 @ 9:24am 
@Pantaloon
//-----------------------------------------------------------------------------------
"Proxies"
{
LinearRamp
{
rate "1"
resultVar "$frame"
}

Clamp
{
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.
Ryuji-amude Sep 25 @ 7:31am 
@Ellie: do you know a method how to set the beginning and end of the animated texture so that it does not repeat?
Titaniumless Jul 24 @ 7:51pm 
@Ellie Yes this is pretty much what I want it to be. The gun looks pretty good now, thanks for the help!
Ellie  [author] Jul 24 @ 8:57am 
@Titaniumless : I'm not sure what you mean but certainly, it depends on the parameters you use.
Maybe try this :
$envmaptint "[0.003 0.003 0.003]"
as well as this :
"$phong" "1"
"$phongboost" ".1"
"$phongexponent" .3
"$phongtint" "[1 1 1]"

Titaniumless Jul 24 @ 6:21am 
Hello, I'm currently adding some final touches on my skin for a weapon now, I tested a few times and the one thing that bothers me is the reflection on it. Is it possible for the skin to not lose its skin because of reflection? For example: Deagle is in full red and whenever I went to a light source it instantly fade into chrome.
Crosshair (El Tuailait) Jun 13 @ 5:31pm 
@Ellie Thanks man!!! Look! It is better now!!
http://steamcommunity.com/sharedfiles/filedetails/?id=946356201