Tutorial: Adding effects to Source textures Last edited 1 year ago2022-10-10 22:37:18 UTC


This tutorial assumes that you have a basic knowledge of the VMT file (can create a simple texture). If not, I will briefly give an example below. This also assumes that you can create a VTF. I will mention some programs for creating VTF's and will also explain how to compile with them. I will first explain the differences between a basic and Decal texture. I will then explain what the bump map effect is and how to apply it to your texture, and then continue onto Env Mapping, Detail Textures, and Phong Shading model textures. I will then explain how to make specialized textures for displacement geometry. After that I will include an example map that will showcase the different texture effects. I will then finish the tutorial by discussing three tools for making VTF's and VMT's; Nem's Tools, GIMP, and Paint.NET.

What VTF/VMT files are

Right about now you may be wondering what VTF's and VMT's are. If you aren't, skip this paragraph. A VMT or (Valve Material Type) is a text document that is used to 'program' your texture. It will take all the parts of your texture and put them together using the values you supply. They range from extremely simple to very complex. (If you want to see a complicated VMT file look at a water VMT)

A basic VMT looks like this:
// Comment: This is a comment and does nothing. Everything after '//' is ignored
// A comment can be used to disable parts of a VMT without deleting all the text

LightmappedGeneric //The shader type (Usually is LightmappedGeneric)
    $basetexture "MyFile/MyTextureName" // Location of VTF relative to the 'materials' folder
A VTF or (Valve Texture Format) is a picture format that is derived from TGA files. (TGA is another type of image file) So before you convert your image files to VTF you must save them as TGA files. Unlike normal pictures files, though, VTF's must have a specific size. Your VTF file does not need to be a square, but the length and width both must be a power of two (ie. 1, 2, 4, 8, 16, 32 ... 4096) they cannot exceed 4096. (SIDES MUST BE A POWER OF 2, DOES NOT NEED TO BE SQUARE)

VMT surface properties

A real simple way to make any texture more interesting is the $surfaceprop modifier. This will cause the texture to behave as if it is made out of a certain material. This changes what sound the player's footsteps make, what sound collisions with the texture make, the mass of the texture, may add sound effects like echo, what sound bullets hitting the texture make, and what debris (if any) are emitted when the surface is shot.

To change the surface properties of a material simply include $surfaceprop in the VMT. Like this:
    $basetexture "YourFolder/YourTextureName" // VTF that will become the texture
    $surfaceprop "brick" // Will make the texture act like it's made out of brick
The default surface properties can be found here. If you are working on a mod any non-default properties can be found in the surfaceproperties_manifest.txt file located in the scripts folder.
Example of holes in a 'metal' texture vs. holes in a 'tile' texture.Example of holes in a 'metal' texture vs. holes in a 'tile' texture.

Basic and decal textures

Basic textures are just pictures that are used to 'paint' geometry in game, like models or walls. Decal textures could be thought of as the second layer of 'paint' on your map geometry. They are basically textures that are projected ONTO your other textures. The Valve Developer Community describes decals in this way "[They] can be used to add detail, break repetition, and create effects you cannot with standard textured surfaces alone". Some possible decals are blood, paint splatter, graffiti, road lines, and manholes. There is one type of decal texture, but two different ways to include decal textures in your map. One is the Decal Tool and the other is the Overlay Tool. I will not discuss these in this tutorial but more information can be found at the Valve Developer Community.

In order to make a decal you must first have alpha in your VTF file. To do this you would basically surround the portion of the texture you want displayed with black alpha values. Different programs have different ways of editing alpha values. In Paint.NET you would just select the parts of the texture you don't want and 'delete' them.

To make a simple decal for use in mapping you will only need these three commands:
Make up of a decal textureMake up of a decal texture
The VMT of a basic decal texture will look something like this: (Modified sample from The Valve Developer Community)
    $basetexture "decals/YourDecal" // VTF that will become the texture
    $decal 1                       // Makes the texture a decal
    $decalscale 0.1                // Sets the scale of the decal ( '1' means  1 pixel = 1 inch. In this case 10px = 1in)
    $translucent 1                 // Causes the alpha channel to be used as transparency
There are other commands, but those are only used for creating decals that fade after time. These are used for blood on models or bullet holes that appear when you shoot something. I will not discuss these here as they are not useful for mapping.

Another type of decal can be used to mimic dents or pock marks. Instead of 'painting' over your texture this will lighten and darken the texture. This type of decal also requires a specially edited VTF. Your VTF will need to be a grayscale image. Every pixel over mid-range gray (RGB 128,128,128) will make the underlying texture lighter while every pixel under mid-range gray will darken the underlying texture. The alpha channel is used to control which parts of the decal will affect the underlying texture. If the alpha channel is left unedited "bordering" can occur around the edges of the decal, creating a well defined square. The VMT for this type of decal is the same as above except the DecalModulate shader is used instead of the LightmappedGeneric shader, and the $translucent and $decal values are not used.
Another Type Of DecalAnother Type Of Decal
An example:
DecalModulate //This shader is used instead of the 'LightmappedGeneric'
    $basetexture "decalsYourDecal" // VTF that will become the texture
    $decalscale 0.1 // Sets the scale of the decal ( '1' means  1 pixel = 1 inch. In this case 10px = 1in)

Bump mapping

Bump Mapping or Normal Mapping is a texture effect used to cause 2-D surfaces to appear to be 3-D. It does this by allowing the Source engine to generate specialized shadows and highlights that simulate a surface that isn't flat such as a brick wall or a sandy beach. Bump maps can also be applied to models to add more detail like a woven basket, or a knotted wood desk.
Bump Map on a modelBump Map on a model
Bump mapping is not done in an entirely new VMT like the decal texture; it is included in the VMT of the affected texture. A bump map requires a specially formatted VTF file that is difficult to create without specialized tools. The red, green, and blue channels of the Bump Map image effect how the image looks. I won't go into this, but the information can be found here.

First you will have to create the bump map from your texture. It is possible to create one manually, but it is extremely difficult. However, there are several free tools for creating normal maps. For Photoshop or Paint Shop pro (the tool works for both) go here. For GIMP go here. For Paint.NET go here. Or you can use other programs to generate the Bump Maps such as Nem's Tools, XSI, Blender, NVIDIA Melody, Cinema 4d, xNormal.

The tools above will take a VTF file and generate a bump map for the texture. Normally bump maps are saved with the name "BaseTextureName_normal". So, if I had a texture named "brickWall01" I would create a bump map named "BrickWall01_normal" this is just to avoid confusion.

When using the tools you may have to change a few settings to get the effect you want. Just remember two things: The bump map will be reverse what your texture will look like (the indented parts will appear raised on your texture), and too high of a raised section will cause part of your texture to not receive any light making it constantly black.
An example bump map generated from image on leftAn example bump map generated from image on left
Above Texture in a GameAbove Texture in a Game
Now that you have created the VTF the hardest part is over. Including a bump map in a texture file is as simple as adding $bumpmap "texture path" to the VMT file:
    $basetexture "YourFolder/YourTextureName" // VTF that will become the texture
    $bumpmap "YourFolder/YourBumpMapName" // VTF that will become bump map
There are other commands but they are generally not used and are more advanced. The simplest one is $bumpscale <float> (accepts a decimal or non-decimal number that will change the size of the bump map texture). Look here for more info.

Environment mapping

This is probably one of the more advanced texture effects. This will make a texture or model appear to be reflective or just help tint the model/texture to better match the room. This also doesn't require a new VMT, just a VTF and several variables.

Unlike bump maps, the VTF files used for Environment Mapping (env mapping) are simple to create. Just create a grayscale image and increase or decrease the brightness until the desired effect is achieved. Darker areas are more reflective and lighter areas are less reflective. However, if you are using a bump map you will need to take your end result and put it into the alpha channel of the bump map VTF using an image editing program. I suggest the free image editor GIMP or the non-free Paint Shop Pro.

After you have your VTF the more difficult part begins. There are several variables you need to use. And $envmap (this will almost always be set to env_cubemap, any other values are too advanced for this tutorial) Example:
    $basetexture     "YourFolder/YourTextureName" // VTF that will become the texture
    $envmap env_cubemap  // Leave this way
    $envmapcontrast 0  // changes the contrast
    $envmapsaturation 1 // This will cause the reflection to be full color
    $envmapmask "YourFolder/YourTextureName_env"
    // Use "$normalmapalphaenvmapmask 1" instead of above if using a bump map
    $envmaptint "[1,1,1]" // Normal tint
When your first include these textures in your map, they will not be env mapped. You will have to place env_cubemap entities in your map when you create it in Hammer. Then, after your map has been compiled, you will need to type the command buildcubemaps into the developer console. After this the screen will go black and you will see a bunch of pictures flash across your screen as your cube maps are rendered. After this the map will automatically restart, and your textures will be env mapped. (Note: you will need to do this before you give out your map or else everyone you give your map to will have to run the buildcubemaps command. It's better to run it once and give out your cubemapped version of the map.)

This is the VMT for the tile floor shown below:
    "$basetexture" "CustomText/GC Textures/Tile/Tile_Medium01"
    "$surfaceprop" "tile"
    "$bumpmap" "CustomText/GC Textures/Tile/Tile_Medium01_normal"
    "$envmap" "env_cubemap"
    "$envmaptint" "[ .56 .56 .56 ]"
    "$envmapcontrast" 1
    "$envmapsaturation" 1
    "$normalmapalphaenvmapmask" 1 // Because I have a bump map
<- Before 'buildcubemaps' (No Env_Map) & After 'buildcubemaps' (With Env_Map) -><- Before 'buildcubemaps' (No Env_Map) & After 'buildcubemaps' (With Env_Map) ->
<- Before 'buildcubemaps' (No Env_Map) & After 'buildcubemaps' (With Env_Map) -><- Before 'buildcubemaps' (No Env_Map) & After 'buildcubemaps' (With Env_Map) ->

Detail textures

Detail textures simply add detail to textures. The detail texture is a grayscale image that is used to darken a texture when the player looks at it from a short distance. This causes the texture to appear to have fine details.
Example of Detail Texture from Half-Life 2 Episode 2Example of Detail Texture from Half-Life 2 Episode 2
To create a detail texture make a grayscale .vtf file that is somewhat repeatable. It does not need to repeat perfectly because they player will only see it if they are very close to your texture, and they will usually not see more than one tile at a time. Any small seams will be mostly hidden by your main texture.

To add the detail texture to your main texture, open the .vmt and add this line to it:
$detail FileNameTextureName
This is the location of the detail vtf inside the 'materials' folder. The $detail command has six modifying commands I will only discuss the three simpler ones. $detailblendmode is either the number 1 or 0 with 0 being the default. All the Valve developer community says about this is to set it to 1 to darken the texture more. However, when I was experimenting with it, looked like a value of 1 would apply the detail image to the normal map of the texture (Make it bumpy) while 0 would apply the detail image to the visual texture (make it darker). I don't have any examples with this set to 1 because the extra bumpiness make all my textures look worse. Experiment with it on your own.

Here are some of Valve's default detail textures:

For brickwork & concrete

$detail detail/noise_detail_01
$detailscale 7.74
$detailblendfactor 0.8
$detailblendmode 0

For scratched metal

$detail detail/metal_detail_01
$detailscale 4.283
$detailblendfactor .65
$detailblendmode 0

For rock

$detail detail/rock_detail_01
$detailscale 11
$detailblendfactor 1
$detailblendmode 0

For plaster

$detail detail/plaster_detail_01
$detailscale 6.783
$detailblendfactor .8
$detailblendmode 0

Textures for Displacements

See also: Tutorial: DisplacementsTutorial: Creating blend textures for Displacements

Displacement textures (also known as blends) are some of the simplest textures to make if you have learned how to use all of the effects above. These textures are simply two textures in one VMT. When placed onto a displacement you can fade from one texture to the other. This is useful for creating effects such as dirt paths on grassy displacements.

To create a blend texture just use all the VMT commands discussed above twice and the "WorldVertexTransition" shader instead of the "LightmappedGeneric" shader. However, the second time you will need to put a 2 after the command. (NOTE: The only commands you cannot do this with are the Detail Texture commands. You can only have 1 detail texture.) So "$basetexutre" would be used first then "$basetexture2". Generally all the commands for the first texture are grouped at the top of the VMT while all the commands for the second texture are grouped at the bottom. This is just to avoid confusion and is not necessary.

Below is an example of a simple blend texture:
    "$basetexture" "CustomText/GC Textures/Grass/Grass04"
    "$bumpmap" "CustomText/GC Textures/Grass/Grass04_normal"
    "$surfaceprop" "Grass"

    "$basetexture2" "CustomText/GC Textures/Sand/Sand03"
    "$bumpmap2" "CustomText/GC Textures/Sand/Sand03_normal"
    "$surfaceprop2" "Dirt"

    "%tooltexture" "CustomText/GC Textures/ToolTexture/Blend72_tooltexture"
Above texture in a game.Above texture in a game.
You may have noticed the "%tooltexture" command in the VMT example above. This is the only command that needs discussed. This command can be used with any VMT, but is rarely ever needed. This command changes the thumbnail displayed in the hammer editor when you are browsing for textures. This is normally not useful with most normal textures, however with blend textures it is very useful. One use for this command is when you have multiple blend textures that all use the same base texture. In hammer all these textures will have the same bumpmap; even though one might be a grass-snow blend while another is a grass-dirt blend. Using this command to change the thumbnail for each of these textures will make them easier to find.

This command is used in this way: "%tooltexture" "ThumbnailPath"

This texture is a VTF file normally around 64 - 128 pixels square, and it usually fades from the first base texture to the second. Below is an example of what the tooltexture VTF would look like for the above VMT:
A sample tooltextureA sample tooltexture
And that's all there is to creating blends. This concludes the section of this tutorial on making textures for mapping. The next texture effect is for only models. If you're not interested in modeling, you can skip this next section and go to the Example Map or the Useful Programs section.

Phong shading

Phong shading is one of the more complicated texture effects to explain, and can only be used on models. Phong shading basically makes something shiny, and there are quite a few settings in the vmt. Below are some pictures of Alyx that demonstrate phong shading in action.
The effect of phong shading.The effect of phong shading.
The second picture is phong shading; there are just a bunch of effects that go with it. All of these effects together are called the specular shading.The second picture is phong shading; there are just a bunch of effects that go with it. All of these effects together are called the specular shading.
A larger picture of Alyx. Notice the phong shading on her nose and lips.A larger picture of Alyx. Notice the phong shading on her nose and lips.
Some other examples of phongSome other examples of phong
Some other examples of phongSome other examples of phong
The commands you will use to add phong shading to your model are: $phong, $phongexponenttexture, $phongexponent, $phongboost, and $phongfresnelranges. (NOTE: You will need to use all of these commands. There are default values for these commands, however, according to the Valve Developer Community, these default values are sometimes not used if they aren't specifically set.)
The exponent texture for the Alex modelThe exponent texture for the Alex model
Alyx model with a fresnel of [0.05 0.5 1Alyx model with a fresnel of [0.05 0.5 1
this number means that the fresnel affect will appear most wherever the model is curved so that it is almost parallel with the viewer's sight. Notice how the effect appears near the outline of the model.]

Again, you'll just have to experiment with the values for your model. I would suggest copying some of Valve's values for starting points. Then if the values look nice on your models you can just stop there.

Below is an example of Alyx's .vmt from HL2 Episode 1:
vertexlitgeneric // Notice this is not 'LightmappedGeneric' - model textures are vertex lit
    "$basetexture" "models/Alyx/alyx_faceandhair"
    "$bumpmap" "models/alyx/alyx_head_normal"
    "$halflambert" 1
    "$nodecal" "1"
    "$model" "1" //This is necessary because the texture is for a model
    "$phong" "1"
    "$phongexponenttexture" "models/Alyx/alyx_head_exponent"
    "$phongboost"    "6"
    "$phongfresnelranges"    "[0.05 0.5 1]"
One thing that you hopefully noticed was that at the beginning of this .vmt there was the word "vertexlitgeneric" instead of "LightmappedGeneric" that is because almost all model textures use the "vertexlitgeneric" shader. So remember to put the "vertexlitgeneric" at the top of all model textures along with the $model 1 command.

Also one other thing that you cannot see from the VMT file is the PhongMask. This is another grayscale texture stored in the alpha channel of the BumpMap. (This means that you must have a bump map texture. If it isn't used just make it flat.) The PhongMask, like the envmask, controls how much of the phong effect actually appears on your model. Darker values mean lighter phong, and whiter values mean brighter phong. (Note completely black values will cause the phong to disappear completely.)
The PhongMask used on the Alyx model.The PhongMask used on the Alyx model.
At this point in time some of you may be thinking. "Wait, the bumpmap only has 1 alpha channel. How am I supposed to put the envmask AND the phongmask in the same alpha channel?" The answer is... You can't. However, you do have two options.
  1. Use the phongmask as both a phongmask and envmask, or
  2. Invert (Turn white to black and black to white) your envmask and put it into your base texture's alpha channel and then use the $basealphaenvmapmask 1 command.
After you have finished this you should have a working phong shaded model. For more information on phong shading go here.
A phong shaded model. The fresnel values were copied from the smg1 in HL2.A phong shaded model. The fresnel values were copied from the smg1 in HL2.

Useful Programs

During my time texturing I have come across three very useful free programs. The programs are:


Paint.NET is a free image editing program somewhat like photo shop. It is very simple to use. I will not explain how to use it. I just want to point out that it has a Normal Map Generator plugin (Though I suggest using a program like XNormal) and can save files in the .VTF format with another plugin. (NOTE: There is a bug with this plug-in that causes it to not work on most 64-bit systems.)
Paint.NET (NOTE: The workspace wasn't this cramped when I took the screen shot. I just compressed it to make the image file smaller.)Paint.NET (NOTE: The workspace wasn't this cramped when I took the screen shot. I just compressed it to make the image file smaller.)


This is another free image editor. However, unlike Paint.NET, I do not think that it is as easy to use, but it does give you a lot more control over your image. This program is useful for pasting things into the alpha channel of textures. I will explain how to do this.

First open two textures. The base texture and the one that will be placed into its alpha channel.
Open the Two textures.Open the Two textures.
Next right-click on the "Layer's" area to the right, and choose "Add Layer Mask" from the drop-down list.
Select "Add Layer Mask"Select "Add Layer Mask"
A dialogue box will pop up. I think it is easiest to choose the "Transfer Image Alpha Channel". This way the mask channel will start out white. (Unless there is something in the alpha channel already. You would also use this command to edit an image that is in the alpha channel already.)
Select "Transger Image Alpha Channel".Select "Transger Image Alpha Channel".
You should now see two images in the layer window. One is the image, and the other should be white (If there was nothing in the alpha channel to begin with.) Right click in the layer tab again and select "Show Layer Mask". This will make it easier to edit.
Select "Show Layer Mask". (NOTE: The arrows are for emphasis and will not be seen in the program.)Select "Show Layer Mask". (NOTE: The arrows are for emphasis and will not be seen in the program.)
After this you will need to copy the image you want to paste into the alpha channel of the other.
Copy the image you want to paste into the alpha channel of the other.Copy the image you want to paste into the alpha channel of the other.
You will then need to hit paste twice in order to get the image into the layer mask. (I don't know why) After this you will be left with a floating selection layer on top of your original layer. Delete this. (NOTE: If your layer mask hasn't changed you may need to try hitting the paste button a few more times.)
Hit 'paste' twice and delete the floating selection layer.Hit 'paste' twice and delete the floating selection layer.
(If you are making an envmap and pasting it into the base texture's alpha channel now would be the time to invert your image. Select the 'color' menu and choose the 'invert' option.)

After this you will want to deselect "Show Layer Mask".
Deselect "Show Layer Mask"Deselect "Show Layer Mask"
Then right-click over in the layer tab again and choose "Merge Visible Layers". Any of the three choices in the dialogue box that pops up should work. Hit OK, and the layer mask icon should disappear.
Select "Merge Visible Layers" and hit OK.Select "Merge Visible Layers" and hit OK.
Once you have done this you are finished. Save the image as a TGA and convert it to a VTF with another prgram. (NOTE: You may have noticed that the starting image in this example looks exactly like the ending image. This is because I had already pasted something into the alpha channel before I started this tutorial.)
You are finished! Save the image as a TGA.You are finished! Save the image as a TGA.

Nem's Tools

Nem's Tools are a bunch of useful programs for editing VMT, VTF, GCF, and other Valve-related files. The VMT (Called VTFEdit) editor is especially useful. You can use it to view VTF files, create VMT files using a wizard, edit VMT files, and batch convert folders of TGA files to VTF files and vice-versa. More information can be found at the Nem's Tools website.
A screen shot of a VMT file in the editor and the Batch Converter.A screen shot of a VMT file in the editor and the Batch Converter.
That concludes this tutorial. Now get out there and give your textures that extra 'something' to make them shine!


Commented 15 years ago2009-01-28 18:08:41 UTC Comment #100897
Serios and large work, my respect ^_^.
Commented 15 years ago2009-07-03 14:57:30 UTC Comment #100898
Indeed, great stuff.
Commented 12 years ago2012-06-05 21:18:51 UTC Comment #100899
Actually it's not a bump map, it's a normal map :/

You must log in to post a comment. You can login or register a new account.