VTEX (Valve Texture): Difference between revisions
(Described the .vtex format) |
(Added more image processor algorithms and image types) |
||
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. | 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. | 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. | ||
Line 59: | Line 59: | ||
== 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 79: | ||
| m_outputTypeString | | m_outputTypeString | ||
| string | | string | ||
| Type of texture to generate | | Type of texture to generate. | ||
|- | |- | ||
| m_outputFormat | | m_outputFormat | ||
Line 128: | Line 129: | ||
| {{todo}} | | {{todo}} | ||
|} | |} | ||
=== CDmeInputTexture keys === | === CDmeInputTexture keys === | ||
Line 157: | Line 159: | ||
| m_typeString | | m_typeString | ||
| string | | string | ||
| Type of input texture | | Type of input texture. | ||
|- | |- | ||
| m_imageProcessorArray | | m_imageProcessorArray | ||
Line 179: | Line 181: | ||
| {{todo}} | | {{todo}} | ||
|} | |} | ||
=== CDmeTextureOutputChannel keys === | === CDmeTextureOutputChannel keys === | ||
Line 206: | Line 209: | ||
| 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 229: | ||
| 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 === | ||
Line 232: | Line 268: | ||
|- | |- | ||
| DXT1 | | DXT1 | ||
| | | Standard RGB block compression. | ||
|- | |- | ||
| DXT5 | | DXT5 | ||
| | | Standard RGBA block compression. | ||
|- | |- | ||
| I8 | | I8 | ||
Line 274: | Line 310: | ||
|- | |- | ||
| BC6H | | BC6H | ||
| | | HDR block compression. | ||
|- | |- | ||
| BC7 | | BC7 | ||
| | | High quality RGB and RGBA block compression. | ||
|- | |- | ||
| ATI2N | | ATI2N | ||
| | | Two channel block compression. | ||
|- | |- | ||
| IA88 | | IA88 | ||
Line 292: | Line 328: | ||
|- | |- | ||
| ATI1N | | ATI1N | ||
| | | Single channel block compression. | ||
|- | |- | ||
| BGRA8888 | | BGRA8888 | ||
| | | | ||
|} | |} | ||
=== Image processor algorithms === | === Image processor algorithms === | ||
Line 315: | Line 352: | ||
| 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 380: | ||
|- | |- | ||
| 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 401: | ||
|- | |- | ||
| Normals | | Normals | ||
| {{todo| | | {{todo|Regular tangent space normal maps?}} | ||
|- | |||
| AnisoNormal | |||
| {{todo}} | |||
|- | |||
| AnisoNormalRoughness | |||
| {{todo}} | |||
|- | |||
| AnisoRoughness_RG | |||
| {{todo}} | |||
|- | |- | ||
| HemiOctAnisoRoughness | | HemiOctAnisoRoughness | ||
Line 343: | Line 417: | ||
| 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 429: | ||
| 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 = | ||
Line 371: | Line 460: | ||
The compiled .vtex_c format can be extracted with the third party tool [[Valve Resource Viewer]]. | The compiled .vtex_c format can be extracted with the third party tool [[Valve Resource Viewer]]. | ||
= 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]] |
Revision as of 13:04, 6 June 2022
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 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 | 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. |
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. |
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
Format | Description |
---|---|
DXT1 | Standard RGB block compression. |
DXT5 | Standard RGBA block compression. |
I8 | |
RGBA8888 | |
R16 | |
RG1616 | |
RGBA16161616 | |
R16F | |
RG1616F | |
RGBA16161616F | |
R32F | |
RG3232F | |
RGB323232F | |
RGBA32323232F | |
BC6H | HDR block compression. |
BC7 | High quality RGB and RGBA block compression. |
ATI2N | Two channel block compression. |
IA88 | |
R11_EAC | |
RG11_EAC | |
ATI1N | Single channel block compression. |
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. |
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 Valve Resource Viewer.