🔞 Not Safe For Work content is ahead, please, NO minors! 🔞


Material Overrides


Tips and tricks for using material overrides. What they are, what they can and can't do, and some usage tips.

Use the overview below to jump to the section that most interests you.

Overview

  1. What Are Material Overrides?
  2. Adding and Using Material Overrides
  3. General Types
  4. Limitations
  5. Usage

What Are Material Overrides?

Material Overrides are, as the name suggests, overrides for materials. More specifically, they are parameters patched into a specific* instance of a material of an animation set.
Some overrides will apply to all copies of a material, especially if the material didn't originally specify them. To fix this, you'll need to add that override to any other copies of the material with the default value specified.


Adding and Using Material Overrides

Right click the animation set of the model you wish to edit the materials on, and click Add Override Materials.

Wow that was easy. But doesn't do much for us on its own.


Right click the model again, and click Show in Element Viewer > Model. In the Element Viewer towards the bottom, you'll see a materials category. Expanding that should show a list of all* materials that this model uses.
The list will only be populated up until it runs into the first missing material, if the model has one.

Expanding that will show the material's properties. By default, every material will have a name and mtlname property. These are the display name in the materials list and the path to the material relative to the materials folder, respectively. Several TF2 parameters will also be automatically added, if present in the material. Those are:

To add your own properties to your material override, right click the material and click Add Attribute > [Type]. In the popup menu, you'll be giving it a name and pressing OK.

Of course, adding things doesn't do us a whole lot of good unless we add the right stuff. What type and name you're giving depends on what you're trying to do. We'll go over the types in the next section.


General Types

If you're familiar with programming, a lot of these types will be familiar. Understanding what's what will help when you're trying to figure out what it is you're trying to accomplish with your override.

NameDefault ValueDescription
elementAn SFM element, such as the material you're editing.
int0An integer, otherwise known as a whole number, such as 0, 1, or -1023.
float0A floating-point decimal, otherwise known as a real number, such as 0.0, 1.0, or -10.2299995422*.
boolfalseA boolean, shown in SFM as a checkbox. Can be either true or false.
stringA string of characters, otherwise known as text, such as "Hello world!"
binaryBinary data, written in hexidecimal.
time0.0000A timestamp, stored as a real number with four decimal places.
color#000000A color, comes with a color picker.
vector20 0A two-part vector, stored as two floats.
vector30 0 0A three-part vector, stored as three floats.
vector40 0 0 0A four-part vector, stored as four floats.
qangle0 0 0A rotation of pitch, yaw, roll, stored as a vector3.
quarternion0 0 0 1A quarternion rotation, stored as a vector4.
matrix1 0 0 0
0 1 0 0
0 0 0 0
0 0 0 0
A 4x4 matrix of floats.
[type]_arrayA 1D array of [element].

All well and good, but what types are used where? Well, there's a lot of answers to that. For completion's sake, here's a guide with a list (be warned, it's very long and technical). Searching on the VDC can also greatly help. Any time I mention a material override, the type will be listed in parenthesis after the name.

Some types are interchangable. For example, anything that takes a color could also take a float or vector3. If defined as a float, the resulting color will be grayscale. If defined as a vector3, the color could go beyond the usual range and thus appear to glow. This is how weapon crit glows are achieved. Note that floats and vectors for colors use 0-1 for the usual range, rather than the 0-255 of the color type, i.e. white as a vector is 1 1 1 rather than 255 255 255.


One more thing to note. Any override defined as a float can be animated.

  1. Right click the material and click Create AnimationSet for Element. A popup will appear with each float parameter listed, along with a min and max that you can set for the slider range.
  2. Alter any ranges as necessary and press OK. The override will appear in your Animation Set Editor*.
    Overrides don't show up if your Animation Set Editor has Show Scene Heirarchy enabled.

This can be annoying to deal with, especially if you use Scene Heirarchy (which you typically should be). Luckily, you can add the override to the model's Animation Set.

  1. First, disable Scene Heirarchy if it is enabled (Right click in the Animation Set Editor or click on the Animation Set Editor's Tools button and uncheck Show Scene Heirarchy) so you can see the override in the Animation Set Editor.
  2. Right click the material override in the Animation Set Editor and click Show In Element Viewer > AnimationSet.
  3. In the Element Viewer, expand the rootControlGroup and then its children.
  4. Select all and Ctrl+C to copy it, or right click all and click Copy.
  5. With that copied, right click the model in the Animation Set Editor and click Show In Element Viewer > AnimationSet.
  6. In the Element Viewer, expand the rootControlGroup, right click children, and click Paste Special > Paste as Reference. You should now see an all category if you expand the model in the Animation Set Editor.
  7. You can rename this by expanding children and all in the Element Viewer, and typing in a new value for the name. I usually go with materials but anything works as long as you can tell what's there.

You can then re-enable Scene Heirarchy and enjoy your overrides being stored with the model they're overriding.


Limitations

Before we get into what they can do, it's important to understand what they can't do. In case you're trying to edit something and it seems like it's not working, it might be a case of the base material you're trying to edit just not supporting what you're trying to do.

The first big example of this is shaders. A material override cannot change a material's shader. If your material is UnlitGeneric, that's what it's staying, you can't override it into being, say, VertexLitGeneric.

Overrides also can't change a value that's being altered by a proxy. For example, TF2 player models have a BurnLevel proxy to control their burning effect. An override added for $detailblendfactor (float) won't have an effect on one of these materials.

Next, while there's some overrides that can more or less always be used such as $color (color), there's many that can't be added only through overrides. For example, $bumpmap (string) only has an effect if the material in question already had a $bumpmap defined.


In these cases, you'll need to track down the material in question and add a "default" option to it if you wish to be able to use these overrides. Please keep in mind that Source is finicky at times and sometimes things just don't work together for reasons. (a prime example, just look at all those notes) That said:

Adding the override is a great way to start out on finding the material in question. its mtlname will tell you where the file is, relative to the materials folder. Unfortunately, it won't tell you which materials folder its in. A good place to start there is to look at the model in the Select .MDL File dialog box from creating a new Animation Set for a model. Before the model's name is a category labeled Mod, which lists the folder name the model came from. This is most likely where the material will be.

With that information in hand, right click SFM in your Steam library and click Manage > Browse local files. From there, the filepath to the material you want to edit will most likely be:

[folder Steam opened]/game/[Mod]/materials/[mtlname].vmt

If that's not it, you'll have to try other folders where Mod is. Here's some folders you could try:

Once found, open it up. Notepad works, but my personal recommendation is Notepad++ with the VDF Language Plugins installed. You should see something like this:

"Shader"
  {
    "$parameter" "value"
    "$parameter" "value"
    "$parameter" "value"
    
    ...
    
    "Proxies"
    {
      "proxy_name"
      {
        "proxyVar1" "$value"
        "proxyVar2"   value
        "resultVar" "$value"
      }
      ...
    }
  }

You'll be inserting the parameter of your choice on a new line, somewhere inside the curly brackets. Watch out if the material has proxies defined! You don't want to put it in or past those. Note that quote marks aren't necessary unless the value in question has spaces in it.

For most float values, the default would be 0. For colors, it'll be "[1 1 1]". Strings will work a little differently. Here's some examples:

Once added, save the material (or save a copy of it in the Usermod Mod space, to prevent updates from reverting your changes) and restart SFM*.
*Note: Instead of restarting, you could try mat_reloadmaterials in the SFM console, but this doesn't always work depending on the changes made, and also has a chance to crash SFM, so it's usually better to just restart it yourself. Definitely save before trying it!

If everything was done right, the material shouldn't look any different than it normally does, but should change when an override is added.


Usage

So up until now we've been very abstract with all this. That's in part because this is just such a wide-ranging topic. There's so many things you could do with material overrides, and even a fair few different ways you could go about doing the same thing with different ones. But, it could be hard to tell without something more concrete, so let's get a specific example going.

We'll be using the spill props from here for this.

We want a cum puddle, because of course we do. Spawn one of the props_invasion/2fort/chem_spill_[X].mdl models in and get it set up for material overrides.

So, what do we need for this to become... cum? Well, unless we're doing fun art, we probably need the color changed. This model doesn't support TF2 coloring, so that'll be a two-step process. First, we need to get the texture white. Add a string override, and name it $basetexture. Mind the $, it's required!

With our default value of  , you should see the model has become covered in missing texture*. Let's replace that with lights/white. It should now be white. But, maybe a little too white. Lets add some color to it to bring it down a bit. I usually go for a light cream color to cum, so let's add a $color2 (color) to this. With the default value of black, the model should now look... gray?
Don't leave a texture blank or with a wrong path, even if you want the missing texture. This will cause error spam in your console that will eventually crash SFM. missing texture can be added properly with debug/debugempty.

So, yeah, this model glows. More accurately, it has self illumination. We'll deal with that in a second. For now, the color. I usually go for a color around RGB 173 173 153, but obviously you can adjust to taste.

So this glowing thing is a real thorn in the side, eh? To get rid of that, we'll black out its self illumination mask. That'll be $selfillummask (string), and we want a value of tools/toolsblack. A fully black self-illum mask means "don't glow at all." So everything is... almost right. Something looks just a little off? It's still ever so slightly blue. That'll be its phong, it's been tinted blue. So one more override to add to fix that. $phongtint (vector3). We can leave this at its default, because phong tint is done as a ratio between the red/green/blue values, so 0 0 0 is the same as 1 1 1.


So we've got one material override. Wasn't too bad to set up, but that's a lot to do if we want more than one model. What if we want it on other spill models? Do we have to manually add it to each one? The answer may surprise you (the answer is no).

First things first, if we copy this animation set and paste, all the copies will have copies of the override. The overrides themselves can also be copy/pasted over in the element viewer, both in the current model, and in any others.
Keep in mind, the mtlname has to match one of the materials on the model in question. All the other spill models use this same material, so they'll all work out of the box.

If you paste on an override element, it'll replace it. If you do it on the materials attribute, it'll put in alongside any existing overrides.

You can also right click and Paste Special > Paste as Reference the copied override. This keeps the two copies linked, so changes to one will change the other as well.
Keep in mind that includes the mtlname, so reference copies can only be used on the same material.

Finally, you can save/load material overrides. Right click the override you wish to save out and press Export element.... This will open a file browser to your sessions folder. I recommend creating a subfolder in this for your overrides, with a name such as material_overrides, and saving the copy there.
Note: SFM will open to the last used folder any time you import/export material overrides, so this new folder would be selected automatically in the future.

Loading a saved material override acts similiarly to right click pasting/pasting as reference, just select Import element... instead. Here's a useful one I made to help with TF2 paint colors. Just drop that into the folder you hopefully just made (or your sessions folder if you like getting dmx files confused) and import it on the materials attribute when you wanna try it out.
You can right click on color values to copy and paste them! Paste special... will also let you mix the current color with the copied color.