The Source SDK tools give access to hundreds of different models, sounds, and materials. Half-Life 2 is based on a post-war, apocalyptic environment, and most of the materials include some wear, grunge, and destruction. If your mod does not follow this theme, you'll probably want to add some of your own content in the maps.
In this chapter, we will be learning the following topics:
Let's jump in!
Source materials are made up of two files:
You can have multiple VMT files that reference the same VTF file. So, you can have multiple materials that use the same image differently.
The .bin
folder contains the program you need to create your own materials. All you need is an image editor capable of creating targa (.tga
) files and a proper folder structure.
First, let's set up our folders. For vtex.exe
, the texture-creating program, to function properly, you need to create two folders: one to hold the texture source files and another to hold the compiled materials. The first folder we need to create in your mod folder will hold all the TGA files. In this example, the mytextures
folder will contain all of our textures. Create the following folders in your Steam folder as follows:
steamappscommon<your mod>materialsrcmytextures
.
Since I'm working with Half-Life 2: Episode Two, my folder location is steamappscommonHalf-Life 2ep2materialsrcmytextures
. It might be a good idea to create a shortcut to this folder in some place that is easily accessible, because this folder is located deep within the Steam folder.
Vtex needs to know where to put the converted texture files. Create another mytextures
folder in the materials
folder in the ep2
folder. Again, since I am using Half-Life 2: Episode Two, I have created the following folder:
steamappscommonHalf-Life 2ep2materialsmytextures
This folder will contain the VMT and VTF files that Source will actually display in Hammer and in-game.
The program used to create the textures is called vtex.exe
, and it's located in the .bin
folder. Again, following my Half-Life 2: Episode Two example, vtex.exe
will be available at SteamsteamappscommonHalf-Life 2in
. In order to make our lives a bit easier, create a shortcut to vtex.exe
in the materialsrcmytextures
folder.
Phew! that was exhausting. Now that we have set up our folders, we can get to the fun part—creating materials! All texture files that are created with Vtex need to be targa files and should have dimensions in factors of 2. Height and width values of 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, and so on, are all acceptable, but the default texture size is 512 x 512 so, that should be a great place to start. Once your targa file is created and saved in the proper folder (materialsrcmytextures
), drag the targa file onto the vtex.exe
shortcut you previously created to create a VTF.
I have included a sample targa file called texture01
for you to play around with, as shown in the following screenshot:
A command prompt window will appear showing you the input path, output path, and status of the file conversion as follows:
If everything is set up properly, you will see a newly created VTF file in the mytextures
folder of your game directory.
Unfortunately, our VTF file is useless by itself. For the engine to recognize that file as a material, we need to create a VMT file that defines properties such as the render mode and material type. VTF files are just text files that are saved in the .vmt
format. You can use any simple text editor, such as Notepad, to create them. Open Notepad and type the following code:
"LightmappedGeneric" { "$basetexture" "mytextures/texture01" "$surfaceprop" "wood" }
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
Let me explain how this all works.
Lightmappedgeneric
: This defines the texture as a normal light mapped texture. It can receive light information in game; most material files will begin with this.$basetexture
: This defines the main VTF to display. The mytextures/texture01
folder is the location of the VTF relative to the main materials folder.$surfaceprop
: This tells the engine the type of surface material. When you damage this texture in-game, it will create sounds and damage decals based on the surface properties. In my example, this material is wood, but there are dozens of other choices. A full list of valid surface properties can be found on Valve's wiki at https://developer.valvesoftware.com/wiki/Material_surface_properties.Save the file as texture01.vmt
to complete the material creation. When you browse for your texture in Hammer, you will be searching for the VMT file and not the VTF file.
When you run the map in-game, you'll notice that the decals and sounds that are produced when the surface is damaged match those of the surface properties. In this example, the material is wood.
18.226.177.86