Porting GoldSrc content to Source


For help, see the VDC Editing Help and Wikipedia cleanup process. Also, remember to check for any notes left by the tagger at this article's talk page.
Porting your current Goldsource .mdl to the Source engine is a short process. For this process, I'm going to assume that you have all the original source content for the model. I'm referring to the original 3d package file, textures and .qc file at the bare minimum. If you have the .smd files, this could save you some time but not in every case, and if you have the original 3d source, then you can always re-export new .smd's. If you do not have the source content, don't loose hope. See the end of this document for instructions on how to decompile your .mdl file then start from the beginning.
Overview
For the most part, porting your models is brainless "robotmonkey" work. It's a process with straightforward steps that someone needs to push buttons to make happen. First we'll make sure your VPROJECT is set properly, and then convert your old textures to Source materials. Next tweak your .qc file to some new Source syntax, and then compile the new content into your new Source .mdl.
Step 1. VPROJECT
The first thing to take care of is your VPROJECT environment variable. This variable is referenced by a handful of Source tools, 3 of which you will use to port your models. Studiomdl and Vtex both use VPROJECT to know where to place your compiled models and materials respectively. Half-Live Model Viewer (HLMV) uses VPROJECT to find the materials your model uses. If you have already set your VPROJECT, skip to step 2.
To set your VPROJECT(Current Game), you can use Source SDK launcher or VConfig.exe.
Step 2. Convert old textures to new materials
In Goldsource, .bmp textures were built right into the .mdl. However in Source, we now author our source files (diffuse, specular, bumpmaps, etc) as .tga files then use the tool Vtex to convert the .tga into a .vtf, which is referenced by the .mdl but not compiled into it. In addition to .vtf's, there are .vmt files. These files are just text files that define the attributes of your material. The primary things in the .vmt are the pointers to the different versions of the texture, namely the diffuse, specular, and bump. However there are also other arguments that can be set. For more information, see the Material System documentation in the SDK.
Before we compile any .tga's, I should point out that you should create a 'materialsrc' and 'materials' directory inside your mod directory. For example C:\MyMod\materialsrc
and C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials
. The 'materialsrc' directory is where you should keep all of your original source content (your .tga's). The materials directory is where Vtex will output all your .vmt's and .vtf's to. Of note is that if you create a subdirectory in the 'materialsrc' directory and also have that directory mirrored in your 'materials' directory, when you compile a .tga from that directory with Vtex it will automatically put the .vmt and/or .vtf into that directory. So for example if you make both C:\MyMod\materialsrc\player
and C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials\player
, when you run Vtex on a file inside the materialsrc\player directory, the .vmt/.vtf will be exported into the materials\player directory. If you are not using the –mkdir Vtex argument, and the directories are not mirrored, you will get an error when using Vtex so make sure you have equivalent directories if you run into a problem.
I'd also like to preface with a few tool tips in reference to Vtex that I use to make my life a little easier. The first is a shortcut to Vtex that will create a .vmt for you, the second is a quick way to re-compile a .tga assuming you already have a .vmt for the material.
Tip #1 Shortcut for Creating NEW materials
- Create a shortcut to vtex.exe on your desktop. Vtex.exe is located in your SourceSDK\bin directory.
- Right-Click the shortcut and select the 'properties' option.
- In the "Target" box, add "-mkdir -shader vertexlitgeneric" after vtex.exe with a space between them.
- Click OK.
You should use this shortcut whenever you need to convert a texture to a material that you have never converted before. The argument "-mkdir" will automatically create the materialsrc directory you're compiling from in the materials directory if you have not already done so. The argument -shader VertexLitGeneric
will tell Vtex to automatically make you a new .vmt for your .vtf that points to the .vtf as the diffuse texture.

Tip #2 TGA to VTF right-click shortcut
- Open a Windows Explorer window (Windows key + E).
- Go to Tools > Folder options.
- Select the "File Types" tab and scroll down until you see the TGA extension.
- Click TGA so that it is highlighted.
- Click the "Advanced" button at the bottom of the panel.
- You should now see the "Edit File Type" panel.
- Click the "New..." button.
- In the "Action:" box type "TGA to VTF".
- Now click the "Browse..." button and locate your vtex.exe file. (It will be in "bin" directory wherever you have installed SourceSDK. For example <codeC:\Program Files\Valve\Steam\SteamApps\username\sourcesdk\bin)
- The "Application used to perform action:" box should now read something like "C:\Program Files\Valve\Steam\SteamApps\username\sourcesdk\bin\vtex.exe "%1"".
- Click in the little box next to "Use DDE".
- In the "Application" box type "vtex".
- In the "Topic" box type "System".
- Hit OK on all the panels to accept the changes.
You can now right-click on any .tga file that you have an existing .vmt for and select the "TGA to VTF" option and Vtex will recompile your texture. This is useful for when you make changes to a texture you have previously compiled.
Now to convert your textures, we can use our new tools to save us some typing in a DOS window.
- Save all your .bmp's as .tga's with your favorite image editing application into their appropriate materialsrc directory.
- Drag your .tga onto the new Vtex desktop shortcut you've created.
- Do this for all the textures for your model.

Step 3. Tweak the .qc file
For the most part old .qc files will work with the new Studiomdl, however there have been a few syntax changes that you will need to implement in order for the model to build correctly.
- $modelname now works in conjunction with your VPROJECT and automatically assumes a directory output location of your VPROJECT + a 'models' directory. For example
C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models
. So if your were to set your $modelname to "player\myplayer.mdl", Studiomdl will compile the model and write it toC:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\models\player\myplayer.mdl
. Of note is that Studiomdl will not make directories for you, nor does it have a –mkdir argument so you will have to make sure the directory that you're writing to already exits before you start the compile. - Replace $cdtexture with $cdmaterials. $cdmaterials also uses your VPROJECT and assumes the output directory to be your VPROJECT + a 'materials' directory. So for example
C:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials
. As a rule of thumb we break our material tree up based on what the material is being applied to. In this case a model. So keeping the same example as in the $modelname step above, you could set $cdmaterials to "models\player" and the model will look for its materials in the directoryC:\Program Files\Valve\Steam\SteamApps\SourceMods\MyMod\materials\models\player
.
Step 4. Collision Model (aka Physbox)
A "Collision Model" (aka "Collision Hull," "Physics Hull," or "Physbox") is the simplified mesh that defines how the model will interact with the world when it is being physically simulated. This document will not cover the details of creating a physbox, but I would like to quickly discuss if you need to create one by hand or have Studiomdl create one for you.
Studiomdl will create a physics hull for you if you do not specify one, however it will do a quick and dirty job of it. It will not "vacuum seal" the model. It will connect all the furthest points of the model together directly.
To demonstrate this, imagine looking down on your model and that it is shaped like a +...
You've deemed that it must have a correct physbox because it is going to be seen frequently reacting with the world and/or player, thus needs to bounce and spin correctly. So you want your physbox to resemble something like this, the red lines...
However if you were to let Studiomdl create the physbox for you, it would create a mesh that connected all the most extended parts directly. Like this...
In some cases, that's ok. If the object is insignificant, or is rarely used in some dark corner, etc. However if this example object were a revolving door, then this physbox would be unacceptable. For more information, see the "Physics" section of the modeling documentation.
Step 5. Run Studiomdl to compile the model.
The actual process of compiling hasn't changed outside of Studiomdl using your VPROJECT. The following steps can make the job a little easier though by associating all .qc files with Studiomdl so that whenever you double-click them, they will automatically be compiled. If this isn't something you would like, then skip it and run Studiomdl by any method you prefer. See the Modeling documentation for more information on Studiomdl.
To associate .qc files with Studiomdl for double-click compiling:
- Open a Windows Explorer. (Windows Key + E)
- At the top of the window, click "Tools", then "Folder Options...".
- Click the "File Types" tab then scroll down to QC. If you do not have a QC extension in your list, you can add it by hitting the "New" button below the list, and enter "QC" in the box. Hit "OK" to enter the extension into the list.
- Click the QC extension. It should become highlighted.
- In the "Details for 'QC' extension" area of the "Folder Options" panel, click the "Change..." button to the right of the text "Opens with:".
- Click the "Browse..." button at the bottom right of the "Open With" panel.
- Browse to the file "studiomdl.exe" in the SDK tools. Click the "Open" button.
- Make sure that "studiomdl.exe" is highlighted in the "Open With" panel. Click the "OK" button.
- Close the "Folder Options" panel with the "Close button.
You should now be able to compile your model as a Source model by simply double-clicking the models .qc file.
Step 6. Check your new source .mdl with Half-Life Model Viewer
To make sure everything is working correctly, you can run the new Half-Life Model Viewer to view your new model. HLMV can be found in the "Bin" directory with the rest of the tools. Go to File>Load Model option at the top of HLMV and browse to the location of your model then hit the "Open" button.
Some problems you might run into:
- If your model has a black and pink texture, it's because the materials are not in the location the .qc has pointed the model to look for them in.
- With the "Render" tab at the bottom of HLMV selected, at the top right corner of the panel click the checkbox next to "Physics Model." If your physics model does not look as you have expected it to, see the Modeling documentation to help diagnose your problem.
That should do it. If you're still having problems, try going through the Modeling documentation to see if there are any issues you might need to take care of.
P.S. I've Lost My Original Source...
If you've lost your original source, you can use SMD importer for your 3D package(e.g. Valve Addon for Softimage|XSI) and import your .smd directly for editing. One way to get a hold of your textures for converting to materials is to use the Goldsource version of HLMV and extracting the textures from the Texture tab. If all of these options fail you, maybe starting from scratch isn't such a bad idea after all.