VTEX (Valve Texture)
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 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, 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: 2D, 3D, CUBE, CUBEARRAY |
m_outputFormat | string | Image data format to generate. |
m_outputClearColor | vector4 | Todo: 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: 2D, 3D, CUBE, CUBEARRAY |
m_imageProcessorArray | element_array | Array of image processor algorithms to apply to the input. |
m_bPassThroughToCompiledVtex | bool | Todo: 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. |
Image data formats
Format | Description |
---|---|
DXT1 | |
DXT5 | |
I8 | |
RGBA8888 | |
R16 | |
RG1616 | |
RGBA16161616 | |
R16F | |
RG1616F | |
RGBA16161616F | |
R32F | |
RG3232F | |
RGB323232F | |
RGBA32323232F | |
BC6H | |
BC7 | |
ATI2N | |
IA88 | |
R11_EAC | |
RG11_EAC | |
ATI1N | |
BGRA8888 |
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. |
EncodeRGBM | Encode a HDR texture to RGBM: RGB with a multiplier in the alpha channel. |
Mipmap processor algorithms
One of these algorithms can be selected as the mip processing algorithm for the output.
Algorithm | Description |
---|---|
None | Do nothing. |
Box | Standard box filtered mipmaps |
AlphaWeighted | Todo: Used for transparency masks and color in the same texture.
|
Normals | Todo: Normal maps?
|
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. |
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. |
Unknown processor algorithms
Algorithm | Description |
---|---|
Brightness | |
GenerateSheetData |
Compiled file format
[Todo]
The compiled .vtex_c format can be extracted with the third party tool Valve Resource Viewer.