VTEX (Valve Texture Tool): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Warning: falling back to auto detection of vconfig (Windows vista))
(Moved away and linked to most of the article.)
Line 1: Line 1:
= Overview =
== Overview ==


'''Vtex''', or Valve Texture Tool, is the standard application used to create [[VTF]] texture files from [[TGA]] bitmap files for use in the Source engine. It is located in the <code>/Steam/SteamApps/''username''/sourcesdk/bin/</code> folder. Vtex can be used with "drag-and-drop" in Windows to easily create .vtf files, as described in [[Creating Materials]]. Vtex can also be used as a command-line tool.
'''Vtex''', or Valve Texture Tool, is the standard application used to convert [[TGA|targa (.tga)]] image files into [[VTF|Valve Texture Files (.vtf)]] for use in the Source engine.


=Using Vtex on the command-line=
It is located in the <code>/Steam/SteamApps/''username''/sourcesdk/bin/</code> folder.


The Vtex application can also be executed via the a command prompt to use advanced features. You can provide additional parameters to create a basic .vmt when the texture is compiled, as well as other options.
Vtex can be used in two ways: Through the "drag-and-drop" method in Windows (described below), or through the [[Vtex CLI use|command line interface]].


The syntax for <code>vtex.exe</code> is as follows:


vtex [-quiet] [-nopause] [-mkdir] [-shader ShaderName] [-vmtparam Param Value] texture1.tga texture2.tga ...
== The drag-and-drop method ==


== Basic Vtex usage ==
The drag-and-drop method is an easy way to use Vtex.
{{todo|More detail - the process is apparently currently described in [[Creating Materials]], but should be moved here.}}


The Windows environment variable "<code>%sourcesdk%</code>" can be utilized to locate <code>vtex.exe</code> easily in a command-line statement. This variable contains the location of the Source SDK installation directory.


For example, to compile a Half-Life 2 material called "<code>sample_material.tga</code>" in the directory "<code>sourcesdk_content/hl2/materialsrc/metal</code>", you would open a command prompt, change to the directory to "<code>sourcesdk_content/hl2/materialsrc/metal</code>" and type this at the command-line:


"%sourcesdk%\bin\vtex" sample_material.tga
==See also==
 
The compiled .vtf file would be compiled to this folder (assuming you had set '''Half-Life 2''' as your current game directory):
 
SteamApps\''username''\half-life 2\hl2\materials\metal
 
{{note|It is very important that you set the '''Current Game''' in either the '''SDK Launcher''' or '''VConfig''' to the correct game directory ''before'' you open a command prompt to compile textures. Changing the '''Current Game''' will not affect any command prompt windows that are already open. This is due to how Windows uses environment variables.}}
 
== Vtex commands ==
 
=== -mkdir ===
 
You can add the <code>-mkdir</code> command to vtex, and it will add the destination directory if it does not exist. For example, if you had a .tga at <code>/sourcesdk_content/hl2/materialsrc/sample/sample_material.tga</code> you would type this at the command-line:
 
"%sourcesdk%\bin\vtex" -mkdir sample_material.tga
 
This would create a new directory called "<code>sample</code>" in your<code> Half-Life 2/hl2/materials</code> directory, if it didn't already exist, and then place the compiled .VTF file in that new location. If the directory already exists, the <code>-mkdir</code> parameter is ignored.
 
=== -shader ===
 
You can use the <code>-shader <''shadername''></code> command to have Vtex create a .VMT for the new material with the [[shader]] specified. For example, to create a basic <code>LightmappedGeneric</code> material, use the <code>-shader</code> command like this:
 
"%sourcesdk%\bin\vtex" -shader LightmappedGeneric sample_material.tga
 
This would compile the material sample_material.vtf in <code>half-life 2/hl2/materials/metal</code> as well as create a new material file <code>sample_material.vmt</code> in the same location, using the <code>LightmappedGeneric</code> shader, like this:
 
<pre>
"LightmappedGeneric"
{
"$baseTexture" "sample/lightmappedgeneric"
}
</pre>
 
=== -vmtparam ===
 
You can use the <code>-vmtparam <''parameter''> <''value''></code> command to additional material parameters to the created .vmt file. If a .vmt already exists in the same location, any new parameters will not be added. For example, to make a material translucent, you would type the following:
 
"%sourcesdk%\bin\vtex" -shader LightmappedGeneric -vmtparam $translucent 1 sample_material.tga
 
Which would create the following <code>sample_material.vmt</code><nowiki>:</nowiki>
 
<pre>
"LightmappedGeneric"
{
"$baseTexture" "sample/lightmappedgeneric"
"$translucent" 1
}
</pre>
 
You can add multiple <code>-vmtparam</code> statements in the same Vtex command, like this:
 
"%sourcesdk%\bin\vtex" -shader LightmappedGeneric -vmtparam "$bumpmap" "sdk/bumpspecular_normal" -vmtparam "$envmap" "env_cubemap" sample_material.tga
 
This would create the following <code>sample_material.vmt</code> specifying parameters for a bumpmapped specular material:
 
<pre>
"LightmappedGeneric"
{
"$baseTexture" "sample/sample_material"
"$bumpmap" "sdk/bumpspecular_normal"
"$envmap" "env_cubemap"
}
</pre>
 
=== -quiet ===
 
When added, this commands will cause Vtex to do its work without producing any output to the console and will not pause when finished.
 
=== -nopause ===
 
Removes the "<code>Hit a key to continue</code>" message that appears when Vtex has finished working.
 
== Wildcards ==
 
Command-line ''wildcards'' can also be used with Vtex. This command-line would compile all .tga files in the current directory:
 
"%sourcesdk%\bin\vtex" *.tga
 
This command-line would compile all .tga files in the current directory with names than begin with "sample":
 
"%sourcesdk%\bin\vtex" sample*.tga
 
In this case, the files "<code>sample_metal</code>" and "<code>sample3</code>" would be compiled, but not "<code>samp_metal</code>" or "<code>sampl_2</code>".
 
== Chaining ==
 
Vtex can compile multiple materials from the same command-line. Simply add the name of each .tga after the first, like this:
 
"%sourcesdk%\bin\vtex" sample_material1.tga sample_material2.tga sample_material3.tga
 
If a .vmt is generated on the command-line using the <code>-shader</code> command, a unique .vmt will be created for each .tga in the chain, all with the same parameters specified by the <code>-shader</code> and <code>-vmtparam</code> commands. If you need more individual control of the shader parameters of each .tga, use a batch (.bat) file to run vtex multiple times instead.
 
= Troubleshooting =
 
==Local Steam Service is not running==
 
Vtex will give the following error:
 
SteamStartup() failed: SteamStartup(0xf,0x0012F0E4) failed with error 108: The local Steam Service is not running
 
Steam must run while Vtex is run. Start Steam to fix this.
 
 
==Problem figuring out outputdir==
 
Vtex will give the following error:
 
Problem figuring out outputdir for <path>
 
As a first step, check that the texture to convert is really in the <code>\sourcesdk_content\hl2\materialsrc</code> folder.
 
If the texture is in the correct folder, the error might instead be caused by a complication with the environment variables.
Primarily, this should be able to be eliminated by using [[VConfig]] and ensuring the selected mod has been run at least once. However, there are cases where this doesn’t solve the problem.
One solution is to remove the instance of the VProject Environment variable. In Windows XP this can be accomplished by the following:
 
#Right-click on ''My computer'' and click on ''Properties''.
#Select the ''Advanced'' tab.
#Click on ''Environment Variables'' near the bottom of the window.
#In the ''System variables'' section scroll down and highlight the line ''VProject''.
#Click the ''Delete'' button.
#Click ''OK'' twice to exit.
 
However, this solution will create the ''Unable to find gameinfo.txt'' error instead. {{todo|Delete this non-functioning solution alternative?}}
 
 
==Unable to find gameinfo.txt==
 
Vtex will give the following error and instructions:
 
Unable to find gameinfo.txt. Solutions:
1. Read http://www.valve-erc.com/srcsdk/faq.html#NoGameDir
2. Run vconfig to specify which game you're working on.
3. Add -game <path> on the command line where <path> is the directory that gameinfo.txt is in.
 
This error will occur after ''VProject'' has been removed using the steps above.
 
Open Source SDK and change the ''Current Game''.
 
{{note|The link at step 1 won't provide a solution. (The page is really old.)}}
 
 
==TGA is Bogus==
 
Vtex will give the following error:
 
TGA <path> is bogus!
 
The texture image you are trying to convert is not recognized as a valid targa (.tga) file. Make sure that it is, and that it is either 24 bit/pixel or 32 bit/pixel. (16 bit/pixel is not recognized.)
 
 
==Warning: falling back to auto detection of vconfig (Windows vista)==
Make a shortcut for vtex.exe and add ''-game [path to game directory]''
:'''Example:''' -game c:/steam/steamapps/sourcemods/Awakening
 
If there are spaces in any of the folders in youre path use "
:'''Example:''' ''-game "c:/program files/steam/steamapps/sourcemods/insurgency"''
 
 
=See also=


* [[Vtex CLI use]]
* [[Vtex troubleshooting]]
* [[Creating Materials]]
* [[Creating Materials]]
* [[Shader Types and Parameters]]
* [[Shader Types and Parameters]]

Revision as of 07:35, 28 August 2007

Overview

Vtex, or Valve Texture Tool, is the standard application used to convert targa (.tga) image files into Valve Texture Files (.vtf) for use in the Source engine.

It is located in the /Steam/SteamApps/username/sourcesdk/bin/ folder.

Vtex can be used in two ways: Through the "drag-and-drop" method in Windows (described below), or through the command line interface.


The drag-and-drop method

The drag-and-drop method is an easy way to use Vtex.

Todo: More detail - the process is apparently currently described in Creating Materials, but should be moved here.


See also