From Valve Developer Community
Revision as of 09:41, 2 December 2017 by Terri00 (talk | contribs) (Rewrote the page with all missing information covered, and added extra clarification. Removed the dead links)
Jump to: navigation, search

VTX is the extension for Source's proprietary mesh strip format. It stores hardware optimized material, skinning and triangle strip/fan information for each LOD of each mesh in the MDL.

It is currently found in .sw.vtx (Software), .dx80.vtx (DirectX 8.0) .dx90.vtx (DirectX 9.0) and .xbox.vtx (XBox) flavors. Left 4 Dead and Left 4 Dead 2 originally used just .VTX files, as of the Sacrifice update for these two games they now use the .dx90.vtx for the Mac OSX and re-used the .VTX only for Portal 2.

File Structure


// this structure is in <mod folder>/src/public/optimize.h
struct FileHeader_t
	// file version as defined by OPTIMIZED_MODEL_FILE_VERSION (currently 7)
	int version;

	// hardware params that affect how the model is to be optimized.
	int vertCacheSize;
	unsigned short maxBonesPerStrip;
	unsigned short maxBonesPerTri;
	int maxBonesPerVert;

	// must match checkSum in the .mdl
	int checkSum;

	int numLODs; // Also specified in ModelHeader_t's and should match

	// Offset to materialReplacementList Array. one of these for each LOD, 8 in total
	int materialReplacementListOffset;

        //Defines the size and location of the body part array
	int numBodyParts;
	int bodyPartOffset;

This is the header structure for the current VERSION7 .vtx file

Body array

The body array is a list of BodyPartHeader_t objects.

Size is specified by: numBodyParts.

Location is specified by bodyPartOffset. This is relative to the header, which is alwasy 0x0 and can therefore the offset can allways be treated as a static address.


struct BodyPartHeader_t
	//Model array
	int numModels;
	int modelOffset;

Model array

The model array is a list of ModelHeader_t objects.

Size is specified by: numModels.

Location is specified by bodyPartOffset. This is a relative offset, from the start of the BodyPartHeader_t object.


// This maps one to one with models in the mdl file.
struct ModelHeader_t
	//LOD mesh array
	int numLODs;   //This is also specified in FileHeader_t
	int lodOffset;

LOD Mesh Array

The LOD mesh array is a list of ModelLODHeader_t objects.

Size is specified by: numLODS

Location is specified by lodOffset. This is again a relative offset, from the start of the Modelheader_t object.


struct ModelLODHeader_t
    //Mesh array
	int numMeshes;
	int meshOffset;

	float switchPoint;

Mesh array

The mesh array is a list of MeshHeader_t objects.

Size is specified by: numMeshes.

Location is specified by meshOffset. Relative offset from the start of the ModelLODHeader_t object.

Switch Point

The point at which the engine should switch to this LOD mesh is defined by switchPoint.


struct MeshHeader_t
	int numStripGroups;
	int stripGroupHeaderOffset;

	unsigned char flags;

Strip Group Array

The strip group array is a list of StripHeader_t objects.

Size is specified by: numStripGroups

Location is specified by stripGroupHeaderOffset. Relative from MeshHeader_t object.


The unsigned char flags value can be read from this table:

Value Meaning


// A strip is a piece of a stripgroup which is divided by bones 
struct StripHeader_t
	//Indices array
	int numIndices;
	int indexOffset;

	//Vertices array
	int numVerts;    
	int vertOffset;

	short numBones;

	unsigned char flags;

	int numBoneStateChanges;
	int boneStateChangeOffset;

Indices array

The indices array is a list of unsigned short indices.

Size is specified by: numIndices.

Location is specified by indexOffset. Relative from StripHeader_t object.

Vertices array

The vertex array is a list of Vertex_t objects.

Size is specified by: numVerts.

Location is specified by vertOffset. Relative from StripHeader_t object.


struct Vertex_t
	// these index into the mesh's vert[origMeshVertID]'s bones
	unsigned char boneWeightIndex[3];
	unsigned char numBones;

	unsigned short origMeshVertID;

	// for sw skinned verts, these are indices into the global list of bones
	// for hw skinned verts, these are hardware bone indices
	char boneID[3];

origMeshVertID defines the index of this vertex that is to be read from the linked .VVD file's vertex array

See also