VTEX (Valve Texture): Difference between revisions
SirYodaJedi (talk | contribs) m (There's a tool for it now, but mipmaps don't work properly.) |
(its never easy is it) |
||
(22 intermediate revisions by 9 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{Tabs|VTF (Valve Texture Format)|source=1|custom1=VTEX (Valve Texture)|custom1alt=Source 2|main=source}} | ||
VTEX is the proprietary texture format use by the [[Source 2]] engine. The VTEX format includes a .vtex source file that describes how to compile the texture, and the actual compiled .vtex_c texture file. | {{for|the Source 1 command-line program|[[VTEX (Valve Texture Tool)]]}} | ||
VTEX is the proprietary texture format use by the [[Source 2]] engine, succeeding the {{src|1}}'s [[VTF]] texture format. The VTEX format includes a .vtex source file that describes how to compile the texture, and the actual compiled .vtex_c texture file. | |||
For most uses the .vtex_c file is compiled automatically by the tools, and no .vtex source file is generated. In some cases, such as when creating sprites for particle effects or textures for [[env_cubemap_fog]] and [[env_gradient_fog]], no automated tool exists and the .vtex file has to be created manually. | For most uses the .vtex_c file is compiled automatically by the tools, and no .vtex source file is generated. In some cases, such as when creating sprites for particle effects or textures for [[env_cubemap_fog]] and [[env_gradient_fog]], no automated tool exists and the .vtex file has to be created manually. | ||
{{ | {{bug|hidetested=1|While certain shaders support non-power-of-two textures, your mileage may vary, sometimes certain resolutions which show up in -tools mode will show as errors without -tools. | ||
A resolution such as w400-h200 seems to work, but something weird like w375-h472 will not, always make sure to test without -tools, or just stick to power-of-two textures.}} | |||
= Source file format = | = Source file format = | ||
The .vtex file is a [[DMX]] file usually created in the keyvalues2_noids text format. It describes how to compile a texture from a set of image inputs. Placing a .vtex file in the content directory of the current add-on will cause the tools to compile it when referenced. | The .vtex file is a [[DMX]] file usually created in the keyvalues2_noids text format. It describes how to compile a texture from a set of image inputs. Placing a .vtex file in the content directory of the current add-on will cause the tools to compile it when referenced. | ||
Line 88: | Line 91: | ||
| m_outputClearColor | | m_outputClearColor | ||
| vector4 | | vector4 | ||
| Initial color before input textures are applied to the output. | |||
|- | |- | ||
| m_nOutputMinDimension | | m_nOutputMinDimension | ||
Line 130: | Line 133: | ||
| {{todo}} | | {{todo}} | ||
|} | |} | ||
=== CDmeInputTexture keys === | === CDmeInputTexture keys === | ||
Line 168: | Line 170: | ||
| m_bPassThroughToCompiledVtex | | m_bPassThroughToCompiledVtex | ||
| bool | | bool | ||
| Pass through the input image directly to the texture file? | |||
|- | |- | ||
| m_n3DSliceCount | | m_n3DSliceCount | ||
Line 182: | Line 184: | ||
| {{todo}} | | {{todo}} | ||
|} | |} | ||
=== CDmeTextureOutputChannel keys === | === CDmeTextureOutputChannel keys === | ||
Line 269: | Line 270: | ||
|- | |- | ||
| DXT1 | | DXT1 | ||
| Standard RGB block compression (also known as BC1) | | Standard RGB block compression (also known as BC1) | ||
|- | |- | ||
| DXT5 | | DXT5 | ||
| Standard RGBA block compression (also known as BC3) | | Standard RGBA block compression (also known as BC3) | ||
|- | |||
| ATI1N | |||
| Single-channel (greyscale) block compression (also known as BC4) | |||
|- | |||
| ATI2N | |||
| Two-channel block compression (also known as BC5) | |||
|- | |||
| BC6H | |||
| HDR block compression | |||
|- | |||
| BC7 | |||
| High quality RGB or RGBA block compression {{dota2|not}} | |||
|- | |- | ||
| I8 | | I8 | ||
| Uncompressed greyscale | | Uncompressed greyscale | ||
|- | |||
| IA88 | |||
| Uncompressed greyscale with alpha | |||
|- | |- | ||
| RGBA8888 | | RGBA8888 | ||
| | |||
|- | |||
| BGRA8888 | |||
| | | | ||
|- | |- | ||
Line 309: | Line 328: | ||
| RGBA32323232F | | RGBA32323232F | ||
| | | | ||
|- | |- | ||
| R11_EAC | | R11_EAC | ||
Line 326: | Line 333: | ||
|- | |- | ||
| RG11_EAC | | RG11_EAC | ||
| | | | ||
|} | |} | ||
Line 459: | Line 460: | ||
{{todo}} | {{todo}} | ||
The compiled .vtex_c format can be extracted with the third party tool | The compiled .vtex_c format can be extracted with the third party tool {{vrf|4}}. | ||
= See also = | = See also = |
Latest revision as of 16:27, 21 June 2025
VTEX is the proprietary texture format use by the Source 2 engine, succeeding the Source's VTF texture format. The VTEX format includes a .vtex source file that describes how to compile the texture, and the actual compiled .vtex_c texture file.
For most uses the .vtex_c file is compiled automatically by the tools, and no .vtex source file is generated. In some cases, such as when creating sprites for particle effects or textures for env_cubemap_fog and env_gradient_fog, no automated tool exists and the .vtex file has to be created manually.

Source file format
The .vtex file is a DMX file usually created in the keyvalues2_noids text format. It describes how to compile a texture from a set of image inputs. Placing a .vtex file in the content directory of the current add-on will cause the tools to compile it when referenced.
Template file
<!-- dmx encoding keyvalues2_noids 1 format vtex 1 -->
"CDmeVtex"
{
"m_inputTextureArray" "element_array"
[
"CDmeInputTexture"
{
"m_name" "string" "InputTexture0"
"m_fileName" "string" "materials/my_textures/my_texture.png"
"m_colorSpace" "string" "srgb"
"m_typeString" "string" "2D"
"m_imageProcessorArray" "element_array"
[
"CDmeImageProcessor"
{
"m_algorithm" "string" "None"
"m_stringArg" "string" ""
"m_vFloat4Arg" "vector4" "0 0 0 0"
}
]
}
]
"m_outputTypeString" "string" "2D"
"m_outputFormat" "string" "DXT1"
"m_outputClearColor" "vector4" "0 0 0 0"
"m_nOutputMinDimension" "int" "0"
"m_nOutputMaxDimension" "int" "0"
"m_textureOutputChannelArray" "element_array"
[
"CDmeTextureOutputChannel"
{
"m_inputTextureArray" "string_array" [ "InputTexture0" ]
"m_srcChannels" "string" "rgba"
"m_dstChannels" "string" "rgba"
"m_mipAlgorithm" "CDmeImageProcessor"
{
"m_algorithm" "string" "Box"
"m_stringArg" "string" ""
"m_vFloat4Arg" "vector4" "0 0 0 0"
}
"m_outputColorSpace" "string" "srgb"
}
]
"m_vClamp" "vector3" "0 0 0"
"m_bNoLod" "bool" "0"
}
File data format

The .vtex file is structures as a CDmeVtex list with arrays for CDmeInputTexture input textures and CDmeTextureOutputChannel output channel sets.
CDmeVtex root keys
Attribute | Type | Description |
---|---|---|
m_inputTextureArray | element_array | Array of CDmeInputTexture entries describing each input image. |
m_textureOutputChannelArray | element_array | Array of CDmeTextureOutputChannel entries describing sets of output channels. |
m_outputTypeString | string | Type of texture to generate. |
m_outputFormat | string | Image data format to generate. |
m_outputClearColor | vector4 | Initial color before input textures are applied to the output. |
m_nOutputMinDimension | int | The minimum size of a side of the output texture in pixels . |
m_nOutputMaxDimension | int | The maximum size of a side of the output texture in pixels. |
m_nOutputDimensionReduce | int | [Todo] |
m_vClamp | vector3 | Whether to clamp the S, T and U coordinates respectively. |
m_bNoLod | bool | Disables Level of Detail. |
m_bHiddenAssetFlag | bool | Marks the output file as a hidden asset. |
m_bCreateLinearColorSpaceApiTexture | bool | [Todo] |
m_nDisplayRectWidth | int | [Todo] |
m_nDisplayRectHeight | int | [Todo] |
m_nMotionVectorsMaxDistanceInPixels | int | [Todo] |
CDmeInputTexture keys
Attribute | Type | Description |
---|---|---|
m_name | string | Name to refer to this input by. |
m_fileName | string | Filename for the input image. |
m_colorSpace | string | Image color space: linear or srgb |
m_fileExt | string | [Todo] |
m_nMinBitsPerChannel | int | [Todo] |
m_typeString | string | Type of input texture. |
m_imageProcessorArray | element_array | Array of image processor algorithms to apply to the input. |
m_bPassThroughToCompiledVtex | bool | Pass through the input image directly to the texture file? |
m_n3DSliceCount | int | [Todo] |
m_n3DSliceWidth | int | [Todo] |
m_n3DSliceHeight | int | [Todo] |
CDmeTextureOutputChannel keys
Attribute | Type | Description |
---|---|---|
m_srcChannels | string | Specifies the used channels of the input texture and their order: r, g, b and a |
m_dstChannels | string | Specifies what channels of the output textures map to the specified input channels: r, g, b and a |
m_mipAlgorithm | CDmeImageProcessor | Image processor algorithm to use for mipmap generation. |
m_outputColorSpace | string | Output color space: linear or srgb |
m_inputTextureArray | string_array | Array of input textures by their m_name keys. |
CDmeImageProcessor keys
Attribute | Type | Description |
---|---|---|
m_algorithm | string | What algorithm to use for this image processor. |
m_stringArg | string | Algorithm specific argument. |
m_vFloat4Arg | vector4 | Algorithm specific argument. |
Texture types
Format | Description |
---|---|
1D | One dimensional texture. |
2D | Two dimensional texture. |
3D | Three dimensional volumetric texture. |
1DARRAY | Array of one dimensional textures. |
2DARRAY | Array of two dimensional textures. |
3DARRAY | Array of three dimensional volumetric textures. |
CUBE | Single cubemap texture with a cross layout. |
CUBEARRAY | Array of cubemap sides. |
Image data formats
Image processor algorithms
These algorithms can be added to an input m_imageProcessorArray.
Algorithm | Description |
---|---|
None | Do nothing. |
Inverse | Invert the image channels. |
NormalizeNormals | Normalize the vectors of a normal map to have a length of 1. |
FillToPowerOfTwo | Fill the texture to the nearest power of two size. |
FillToMultipleOfFour | Fill the texture to the nearest multiple of two size. |
EncodeRGBM | Encode a HDR texture to RGBM: RGB with a multiplier in the alpha channel. |
Mod2XCenter | [Todo] |
HeightToNormal | Generate a normal map from a height map. |
DilateColorInTransparentPixels | [Todo] |
ConvertToYCoCg | Convert the channels to the YCoCg color model. |
Mipmap processor algorithms
One of these algorithms can be selected as the mip processing algorithm for the output.
Algorithm | Description |
---|---|
None | Output without mipmaps. |
Box | Standard box filtered mipmaps. |
Nice | Use Source 1 NICE filtered mipmaps. |
BoxInverse | Standard box filtered mipmaps with inverted colors. |
MultiplyNoMip | Multiply two input textures together. |
MultiplyBox | Multiply two input textures together, with box filtering mipmaps. |
AlphaWeighted | Todo: Used for transparency masks and color in the same texture.
|
Normals | Todo: Regular tangent space normal maps?
|
AnisoNormal | [Todo] |
AnisoNormalRoughness | [Todo] |
AnisoRoughness_RG | [Todo] |
HemiOctAnisoRoughness | Used with hemi-octahedron normal maps and anisotropic roughness maps packed into the RB and GA channels respectively. |
HemiOctIsoRoughness_RG_B | Used with hemi-octahedron normal maps and regular isotropic roughness maps packed into the RB and G channels respectively. |
HemiOctAnisoRoughness_RG_BA | [Todo] |
GGXCubeMapBlur | Blur cubemap mips to use for variable roughness reflections with the GGX BRDF. |
GGXCubeMapBlur_RGBM | Blur cubemap mips to use for variable roughness reflections with the GGX BRDF. For RGBM encoded textures. |
RGBM | Generate mips for RGBM encoded textures. |
Mip2DGradient | [Todo] |
PreserveCoverage | [Todo] |
MipDepth | [Todo] |
MipHeight | [Todo] |
MipWidth | [Todo] |
AutoLevels | [Todo] |
WrapGaussian | [Todo] |
HeightCombine | [Todo] |
Compiled file format
[Todo]
The compiled .vtex_c format can be extracted with the third party tool Source 2 Viewer.