Creating a Material

From Valve Developer Community
Revision as of 16:09, 18 July 2005 by Mungo (talk | contribs) (Additional options)

Jump to: navigation, search

This tutorial is a step-by-step process you can go through to create a basic material.

Making the textures

1. Choose your material dimensions, and work on your texture at twice that. Dimensions must be in powers of two but do not have to be square. For textures that appear on large surfaces a good scale is 512 pixels for 10 feet (3.0 meters) in the game. For models which have more detail, try to match the resolution of models you’ve seen in HL2. If your resolution is too high, it will actually look worse because of mipmapping. When it’s done, scale it down to the appropriate dimensions and save it as an uncompressed TGA file in this folder:

C:\Program Files\Valve\Steam\SteamApps\Username\sourcesdk_content\gameshortname\materialsrc

2. Convert the TGA to VTF by dragging it onto vtex.exe. The VTF will be in this folder:

C:\Program Files\Valve\Steam\SteamApps\Username\gamename\gameshortname\materials

3. Move your textures to a directory within their current folder (materials). As an example, let's say are creating a texture called brickwall.vtf for Half-Life 2 and want to categorize it under walls. It would go here:

C:\Program Files\Valve\Steam\SteamApps\Username\half-life 2\hl2\materials\walls\brickwall.vtf

Creating the material file

A .VMT file is necessary for the material to appear in the game and in the Hammer editor. Use Notepad to create the VMT, and save it in the same directory as your .VTF. To prevent Notepad from adding .txt to your file name, choose All Files in the dropdown box for file type.

This is the content of the .VMT:

"''shader type''"
    "$basetexture" "''texture name''"
    "$surfaceprop" "''surface type''"

Replace shader type with one of the following:

This is the most common and is used for surfaces you want to be lit normally.
This is used for surfaces that are always fully lit like a computer screen or lit lightbulb.
This is used for models.

After "$basetexture", replace texture name with the name of your texture (.VTF) along with its path from the materials folder, in quotes. Do not include the .VTF extension.

After "$surfaceprop", replace surface type with the the surface type of the material, in quotes. (This affects the sound of impacts and look of bullet holes.) Choose one of these surfaces: metal, paper, wood, concrete, glass, brick, tile. For more choices, see Material properties.

Here’s what the .VMT for the example brick wall texture would look like:

    "$basetexture" "walls/brickwall"
    "$surfaceprop" "brick"

Some common additional options

"$model" 1
This line is necessary for model skins. Also note that the TGA should also be included in the same directory with the VTF and VMT for the modeler to skin with. Try to keep the skin for each model entirely in one texture—using multiple textures on a model is a resource hog. Remember that the shader type for models is always "VertexLitGeneric".
"$decal" 1
This is necessary for decals.
"$selfillum" 1
Adding this line will cause the texture to self-illuminate according to the alpha channel of your base texture. An example would be a Combine soldier’s helmet which is lit normally except for the eyes, which glow even in the dark.
"$nocull" 1
Add this line if you want your texture to be visible from both sides. This is only applicable for flat objects like glass or wire fences.
"$alpha" 0.5
Adding this line will make the texture translucent. The number can be anything between zero and one.
"$color" "[1 1 1]"
This will scale the color of the red, green, and blue components of your texture. You might use it if you wanted to use the same texture for multiple materials, such as various colors of the same looking glass.

Note: All entries added to a .VMT should be in quotes, except for numbers that appear alone.

See also

Creating Materials

Shader Types and Parameters

Creating Normal Maps

Creating Reflective Materials

Creating Parallax Maps