Making a material

This tutorial covers making a texture by dragging and dropping a TGA image onto VTEX. This method is extremely tedious, and as such, many have taken the liberty of creating GUI alternatives to the command prompt VTEX, such as VTEXGUI, vmtCREATE, and even a Photoshop plugin.

Who or what is a vtex and what does he/she/it have to do with textures?

VTEX is the only program Valve gave us for making textures for HL2 (or the mods thereof). VTEX will convert a standard TGA image to a VTF (Valve Texture Format) file, which can then be used in HL2 or its mods.

Paint can't save files as TGAs. If you have an image that you'd like to use as a texture, you'll need an image editor such as Photoshop or Paint Shop Pro, or an image converter such as Advanced Batch Converter.

Also, the image you use must have powers of two for dimensions. That means its width and height can be 2, 4, 8, 16, 32, etc., but not 80, 48, 160, etc.

So, if you have your powers-of-two TGA, we'll begin!

How do I convert my TGA to a VTF?

Ensure that Steam is open before continuing.

First, you'll need to set the SDK tools to the appropriate game... Navigate to your Steam folder, then SteamApps/account/sourcesdk/bin. For instance, I would be in C:\Steam\SteamApps\Raeven0\sourcesdk\bin. Run the program vconfig.exe; just choose the game you're working on in the drop-down menu and click Okay. [NOTICE: vconfig is somehow screwed up right now (surprise?), and the problem isn't going away. See this thread.]

After that, open a new Explorer window (you'll need two) and navigate to the game's directory. For HL2 it'd be steam/steamapps/account/half-life 2/hl2; for CS:S it'd be steam/steamapps/account/counter-strike source/cstrike; for HL2DM it's steam/steamapps/account/half-life 2 deathmatch/hl2mp.

Once there, create a materialsrc folder if it does not already exist. Also, create a materials folder if it does not already exist.

Still with me? We're almost done!

Take your TGA and place it in the materialsrc folder. Now, make a TXT file with the same name as the TGA--for instance, if your TGA is named yellow.tga, then you'll make an empty file named yellow.txt. The TXT file is used in special cases to modify the texture in special ways.

Open the materialsrc folder if it's not already open, and click and drag the TGA from that folder onto the VTEX program in the OTHER Explorer window. (You wondered why we left it open? It's so that you can drag the TGA onto VTEX. It's the fastest way to get VTEX to convert the TGA.) If all went well, a VTEX prompt should appear with the directory of the TGA, the directory in which the VTF will be placed, and a "Hit any key to continue" confirmation. If you hit any key, the VTEX program will place a VTF in the materials

But...

Now you have to make another file so that you can actually use the texture.

(First, you'll notice that all of Valve's textures are separated into folders. Water and grass and dirt are in nature/, decals are in decals/... You can make another folder for your texture, if you like. Just make a new folder in materials and put the VTF in it. You cannot use a VTF if it's not in a folder.)

Make a new empty text file in some subdirectory of materials (in the same folder as the VTF is always good, for organization). Change its extension from TXT to VMT. This file will be the one actually referenced by Hammer and the game, so you can technically name it whatever you want. Keeping with my examples, I'll call mine yellow--that is, yellow.vmt.

Wait. What is a VMT?

Well, think of it this way. The way HL2's texture system works is that you have a lot of pictures (the VTFs), and you can do anything you want to those pictures by making a VMT (information file) for them. With a single VTF image, you can have a VMT to make the texture scroll in-game, and another VMT to make the texture reflect like water... Essentially, VTFs are pictures, and VMTs combine the pictures with special properties to give you a material.

At this point, you have your picture (yellow.vtf) and you need to make a VMT for it. The VMT will take the picture and tell the game what to do with it.

Open the VMT with Notepad or some other plaintext editor and write the following into it:

folder you made. That's your texture!
"LightmappedGeneric"
{
"$BaseTexture" "path to VTF"
}

For the path to VTF, you have to write the path a special way. If the path to the VTF were materials\somefolder\yellow.vtf, you'd write somefolder/yellow; if the path were materials\somefolder\blue.vtf, you would write somefolder/blue. Note that quotation marks are present around every string; for my yellow.vtf, that line would read "$BaseTexture" "somefolder/yellow".

If your VTF and VMT were both made properly, you should now have a texture that'll show up in Hammer, ready to be used... congratulations!

This new texture--both the VTF and the VMT--will have to be distributed with your map, though. Valve recently released a BSPZIP tool, which can be used to embed your texture into your BSP file such that the files themselves don't need to be sent, because they're already inside the BSP.

0 comentarios: