Creating a Material: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Added a few notes)
Line 18: Line 18:
This is the content of the VMT:
This is the content of the VMT:


<pre><nowiki>"''shader type''"
<pre>"<shader type>"
{
{
     "$basetexture" "''texture name''"
     "$basetexture" "<texture name>"
     "$surfaceprop" "''surface type''"
     "$surfaceprop" "<surface type>"
}</nowiki></pre>
}</pre>


Replace ''shader type'' with one of the following:
Replace <code>&lt;shader type&gt;</code> with one of the following:


;LightmappedGeneric
;LightmappedGeneric
Line 35: Line 35:
:This is used for models.
: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 "$basetexture", replace <code>&lt;texture name&gt;</code> 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]].
After "$surfaceprop", replace <code>&lt;surface type&gt;</code> 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:
Here's what the VMT for the example brick wall texture would look like:


<pre><nowiki>"LightmappedGeneric"
<pre><nowiki>"LightmappedGeneric"

Revision as of 16:12, 4 April 2007

Merge-arrows.png
It has been suggested that this article or section be merged into Material. (Discuss)

This tutorial is a step-by-step process you can go through to create a basic material. For a quicker explanation, see Material. Refer to the See also section for additional features to add to the material, such as normal maps and reflections.

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. Ensure you have your mod selected in the Source SDK menu
  3. 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
    Vtex.exe will be in your C:\Program Files\Valve\Steam\SteamApps\Username\sourcesdk\bin folder.
  4. 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:

LightmappedGeneric
This is the most common and is used for surfaces you want to be lit normally.
UnlitGeneric
This is used for surfaces that are always fully lit like a computer screen or lit lightbulb.
VertexLitGeneric
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:

"LightmappedGeneric"
{
    "$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.pngNote:All entries added to a VMT should be in quotes, except for numbers that appear alone.

See also