VTEX (Valve Texture): Difference between revisions
(Described the .vtex format) |
(its never easy is it) |
||
(28 intermediate revisions by 10 users not shown) | |||
Line 1: | Line 1: | ||
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. | {{Tabs|VTF (Valve Texture Format)|source=1|custom1=VTEX (Valve Texture)|custom1alt=Source 2|main=source}} | ||
{{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, 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 = | ||
Line 8: | Line 12: | ||
== Template file == | == Template file == | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="js"> | ||
<!-- dmx encoding keyvalues2_noids 1 format vtex 1 --> | <!-- dmx encoding keyvalues2_noids 1 format vtex 1 --> | ||
"CDmeVtex" | "CDmeVtex" | ||
Line 59: | Line 63: | ||
== File data format == | == File data format == | ||
{{ | {{note | The lists may be incomplete.}} | ||
The .vtex file is structures as a CDmeVtex list with arrays for CDmeInputTexture input textures and CDmeTextureOutputChannel output channel sets. | The .vtex file is structures as a CDmeVtex list with arrays for CDmeInputTexture input textures and CDmeTextureOutputChannel output channel sets. | ||
Line 78: | Line 83: | ||
| m_outputTypeString | | m_outputTypeString | ||
| string | | string | ||
| Type of texture to generate | | Type of texture to generate. | ||
|- | |- | ||
| m_outputFormat | | m_outputFormat | ||
Line 86: | Line 91: | ||
| m_outputClearColor | | m_outputClearColor | ||
| vector4 | | vector4 | ||
| Initial color before input textures are applied to the output. | |||
|- | |- | ||
| m_nOutputMinDimension | | m_nOutputMinDimension | ||
Line 157: | Line 162: | ||
| m_typeString | | m_typeString | ||
| string | | string | ||
| Type of input texture | | Type of input texture. | ||
|- | |- | ||
| m_imageProcessorArray | | m_imageProcessorArray | ||
Line 165: | Line 170: | ||
| m_bPassThroughToCompiledVtex | | m_bPassThroughToCompiledVtex | ||
| bool | | bool | ||
| Pass through the input image directly to the texture file? | |||
|- | |- | ||
| m_n3DSliceCount | | m_n3DSliceCount | ||
Line 206: | Line 211: | ||
| Array of input textures by their m_name keys. | | Array of input textures by their m_name keys. | ||
|} | |} | ||
=== CDmeImageProcessor keys === | === CDmeImageProcessor keys === | ||
Line 225: | Line 231: | ||
| Algorithm specific argument. | | Algorithm specific argument. | ||
|} | |} | ||
=== Texture types === | |||
{| class="standard-table" | |||
! style="width: 200px;" | 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 data formats === | ||
{| class="standard-table" | {| class="standard-table" | ||
! style=" | ! style="" | Format | ||
! Description | ! Description | ||
|- | |- | ||
| DXT1 | | DXT1 | ||
| | | Standard RGB block compression (also known as BC1) | ||
|- | |- | ||
| DXT5 | | DXT5 | ||
| | | 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 | |||
|- | |||
| IA88 | |||
| Uncompressed greyscale with alpha | |||
|- | |||
| RGBA8888 | |||
| | | | ||
|- | |- | ||
| | | BGRA8888 | ||
| | | | ||
|- | |- | ||
Line 271: | Line 327: | ||
|- | |- | ||
| RGBA32323232F | | RGBA32323232F | ||
| | | | ||
|- | |- | ||
Line 289: | Line 333: | ||
|- | |- | ||
| RG11_EAC | | RG11_EAC | ||
| | | | ||
|} | |} | ||
Line 315: | Line 353: | ||
| FillToPowerOfTwo | | FillToPowerOfTwo | ||
| Fill the texture to the nearest power of two size. | | Fill the texture to the nearest power of two size. | ||
|- | |||
| FillToMultipleOfFour | |||
| Fill the texture to the nearest multiple of two size. | |||
|- | |- | ||
| EncodeRGBM | | EncodeRGBM | ||
| Encode a HDR texture to RGBM: RGB with a multiplier in the alpha channel. | | 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 === | === Mipmap processor algorithms === | ||
Line 327: | Line 381: | ||
|- | |- | ||
| None | | None | ||
| | | Output without mipmaps. | ||
|- | |- | ||
| Box | | Box | ||
| Standard box filtered mipmaps | | Standard box filtered mipmaps. | ||
|- | |||
| Nice | |||
| Use Source 1 [[NICE_filtering|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 | | AlphaWeighted | ||
Line 336: | Line 402: | ||
|- | |- | ||
| Normals | | Normals | ||
| {{todo| | | {{todo|Regular tangent space normal maps?}} | ||
|- | |||
| AnisoNormal | |||
| {{todo}} | |||
|- | |||
| AnisoNormalRoughness | |||
| {{todo}} | |||
|- | |||
| AnisoRoughness_RG | |||
| {{todo}} | |||
|- | |- | ||
| HemiOctAnisoRoughness | | HemiOctAnisoRoughness | ||
Line 343: | Line 418: | ||
| HemiOctIsoRoughness_RG_B | | HemiOctIsoRoughness_RG_B | ||
| Used with hemi-octahedron normal maps and regular isotropic roughness maps packed into the RB and G channels respectively. | | Used with hemi-octahedron normal maps and regular isotropic roughness maps packed into the RB and G channels respectively. | ||
|- | |||
| HemiOctAnisoRoughness_RG_BA | |||
| {{todo}} | |||
|- | |- | ||
| GGXCubeMapBlur | | GGXCubeMapBlur | ||
Line 352: | Line 430: | ||
| RGBM | | RGBM | ||
| Generate mips for RGBM encoded textures. | | 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 = | = Compiled file format = | ||
{{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 = | |||
[[SteamVR/Environments/Fog_Tutorial|SteamVR Home env_gradient_fog tutorial]] | |||
[[Category:Source 2]] | [[Category:Source 2]] | ||
[[Category:Material System]] | [[Category:Material System]] | ||
[[Category:File formats]] | [[Category:File formats]] |
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.