Left 4 Dead 2

Left 4 Dead 2

125 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)
< >
74 Comments
El Tuailait Jun 13 @ 5:31pm 
@Ellie Thanks man!!! Look! It is better now!!
http://steamcommunity.com/sharedfiles/filedetails/?id=946356201
Ellie  [author] Jun 13 @ 4:46am 
@El Tuailait : Did you properly set up the phongmask and the envmapmask ? You need multiple different layers for your gun to look "natural". A bumpmap layer (for procedural heights light) ; a envmap layer (for reflection) - this one is usually contained in the alpha channel of the bumpmap texture ; a phongmask layer (for what parts are shiny or not).
I'd suggest you to reverse engineer this mod to see what to put where and how in the VMT ;)
El Tuailait Jun 12 @ 8:44pm 
Hello? I'm working on my first mod which is a re-skin of the combat rifle so it looks pretty much like this [www.recoilweb.com] , however, the first time, it got like the entire texture became into a shin reflective metal finish, instead of the only shiny upper receiver, and the rest with a dull simple finish... how can I fix it?
Ellie  [author] Nov 27, 2016 @ 6:35am 
@niсk : I think it's a server side script that replaces that. Rendercolor is stronger than VMT parameters I guess. You can maybe try to set $alpha 1 in the VMT but I still think that rendercolor is atop.
An idea would be to attach a particle to the jockey and make it visible above everything. This however is ultra cheaty and it's a non-written rule that us modder follow to not release such cheats :P
123 Nov 27, 2016 @ 6:22am 
@Ellie: some servers make infected nearly invisible. For example, perkmod has "ghost" perk for jockey. You can't see a jockey until it catches you, because jockey is 90% transparent.
How perkmod does this thing? It changes "alpha" keyvalue of entity, so it becomes transparent. One can do the came thing using console commands: «ent_fire !picker addoutput "rendermode 2"» and then «ent_fire !picker addoutput "rendercolor 255 255 255 25"», where 25 means 90% transparency.
Maybe it is possible to make infected always visible by editing vmt files? For example, maybe some type of texture doesn't support alpha parameter, so texture will be always 100% visible. Or maybe some .vmt parameter can override alpha value, which is set in-game.
Ellie  [author] Nov 27, 2016 @ 5:57am 
@niсk : I don't understand what you mean. You mean, is it possible to make the $alpha parameter unable to change anything ? As far as I know, it's not possible because such things are engine based. For example, the engine prevents the use of $ignorez on 3D Models (this parameter makes the thing visible above everything), for cheat reasons.
123 Nov 27, 2016 @ 5:20am 
can i remove the possibility of changing alpha value of texture? For example, we try to set "rendercolor 255 255 255 0" on jockey. Jockey shold ignore it and stay visible. Is it possible?
Djehuty May 13, 2016 @ 6:35am 
Oh and I just uploaded it to the workshop, if you want to check it out.
Djehuty May 13, 2016 @ 6:33am 
Damn, well I will try it online right now and see. If it doesn't work I will try to explore the detail method, or just leave it without glow.
Ellie  [author] May 13, 2016 @ 6:30am 
@Djehuty : It might not try online though with this method and cause consistency errors. If you test in local (typing the map in console) it won't cause any problems.
$detail method stays the only thing I've heard that work online