Creating a Material: Difference between revisions
TomEdwards (talk | contribs) m (power of two) |
TomEdwards (talk | contribs) |
||
Line 42: | Line 42: | ||
== Configuring the texture == | == Configuring the texture == | ||
See [[Valve Texture Format#Image_flags]]. These options can all be found in the checkbox list on the left-hand side of the VTFEdit window. | |||
==Creating the material file== | ==Creating the material file== |
Revision as of 04:29, 31 May 2008
This tutorial is a step-by-step guide to creating a brand new material, including the creation of the material's texture.
Creating a texture
Any image file can be used as a texture, so long as both of its dimensions are a power of two: 2, 4, 8, 16, 256, 1024, and so on. Valve's world textures are generally 512x512, but you are at liberty to use whatever resolution you see fit. Higher resolutions lower performance but make an image sharper when viewed up close. If you go too high quality may actually degrade because of the amount of resizing required.
Different types of object have textures of different resolutions: check Valve's choices in source materials.gcf
with GCFScape if you are ever confused.

Converting a texture
A material's texture(s) must be Valve Texture Format files. The tool Valve provide for converting them to this format is VTEX, but its command-line design makes it a nightmare to try and use, even when you do know what you're doing.
Instead, you should use the third-party tool VTFEdit. It provides a graphical interface, allows you to change a VTF file's properties without re-compiling, accepts a far wider array of input files, and is generally better in every regard. The author of VTFEdit has also created VTF plug-ins that let you save to the format directly from Photoshop and Paint.NET, but this tutorial will not cover them as not everyone uses those tools.
To import your texture with VTFEdit, use File > Import
or press Ctrl+I. Select your image and you will be presented with the import options screen:
General settings
These settings are the most important. There are three:
- Normal format
- The sub-format the texture should be stored in if it is opaque.
- Alpha format
- The sub-format the texture should be stored in if it has transparency.
- Texture type
- How this texture will be used; normally as an Animated Texture, even if it doesn't actually have animation.
If you're making a plain and simple world texture you won't need to change any of these. If you're making a texture with fine gradient detail however, you'll need to choose more suitable formats.
Mipmap settings
These settings define how the texture is scaled when viewed from far away, or when the game is running with medium or low texture detail. The only time you will realistically need to worry about it is when creating interface textures, for which you should disable the check box. This ensures that your menu images are always sharp and readable, even if the very lowest texture detail setting is being used.
Normal map settings
These settings allow you to auto-generate a normal map from your input image. You'll want to do this properly, with an image editor, for the material you ship, but the automated option is there regardless if you want quick results.
Configuring the texture
See Valve Texture Format#Image_flags. These options can all be found in the checkbox list on the left-hand side of the VTFEdit window.
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.
