Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:VTF (Valve Texture Format)

From ReverseEngineering.wiki
Format
Developer Valve
Versions 7.0-7.5; SDK 2013 writes 7.4
Magic 56 54 46 00 ("VTF\0") at offset 0
Extensions .vtf
Endianness little (Xbox 360 files big endian)
On this wiki Facts · Code · Notes · Topics

Texture container of the Source engine (.vtf): signature VTF\0, version 7.x (7.0-7.5), a header with size, dimensions, flags, frames, reflectivity, image format, optional low-res thumbnail, resource directory from 7.3, then mip levels stored smallest first.

Header

From public/vtf/vtf.h (SDK 2013; #pragma pack(1) but the comments warn of padding): char fileTypeString[4] ("VTF"), int version[2] (major 7, minor; VTF_MAJOR_VERSION 7, VTF_MINOR_VERSION 4), int headerSize; then (7.1) u16 width, u16 height, u32 flags, u16 numFrames, u16 startFrame, 4 bytes pad, float reflectivity[3], 4 bytes pad, float bumpScale, ImageFormat imageFormat (int32), u8 numMipLevels, ImageFormat lowResImageFormat (int32), u8 lowResImageWidth, u8 lowResImageHeight; 7.2 adds u16 depth; 7.3 adds 3 pad bytes, u32 numResources and 8 pad bytes (console/posix builds), followed by ResourceEntryInfo { u32 type (3 chars + flag byte); u32 data-or-offset } sorted by type, at most 32 entries.

Xbox 360 files use version 0x0360.8 (VTF_X360_MAJOR_VERSION 0x0360, minor 8).

Data order

Before 7.3 the layout is header, optional low-res thumbnail (usually DXT1, 16x16), then the image data. Mip levels are stored from the smallest to the largest, and for each mip every frame, then every face (6 for cubemaps, 7 in old versions with a sphere map), then every depth slice. Resource ids: 0x01 legacy low-res image, 0x30 legacy image data, 0x10 sheet (flag 0x02 in the top byte = entry has no data chunk).

Flags (TEXTUREFLAGS_*)

The TEXTUREFLAGS_* bits of the header flags field: 0x1 pointsample, 0x2 trilinear, 0x4 clamps, 0x8 clampt, 0x10 anisotropic, 0x20 hint_dxt5, 0x40 srgb, 0x80 normal, 0x100 nomip, 0x200 nolod, 0x400 all_mips, 0x800 procedural, 0x1000 onebitalpha, 0x2000 eightbitalpha, 0x4000 envmap, 0x8000 rendertarget, 0x10000 depthrendertarget, 0x20000 nodebugoverride, 0x40000 singlecopy, 0x80000 staging_memory, 0x100000 immediate_cleanup, 0x200000 ignore_picmip, 0x800000 nodepthbuffer, 0x2000000 clampu, 0x4000000 vertextexture, 0x8000000 ssbump, 0x20000000 border, 0x40000000 streamable_coarse, 0x80000000 streamable_fine. Version 7.3 and earlier mask the flags with ~0xD1780400.

Image formats

See Fact:VTF (Valve Texture Format)/enum/ImageFormat (names and numbers).

Code & repositories

  • https://github.com/ValveSoftware/source-sdk-2013 @ be57e3d01ac7d7aa6a2cacbfef187c0b46616db0 · license: LicenseRef-Source-SDK (declared by the contributor; GitHub's detector did not recognize LICENSE)
    Source SDK 2013: public/bspfile.h (BSP lumps), public/vtf/vtf.h and public/bitmap/imageformat.h (VTF), public/studio.h and public/optimize.h (MDL, VVD, VTX). Proprietary Source SDK license, not an open-source license.
    Tested on: source read, not run: source read, not built: headers at commit be57e3d · checked 2026-10-18; last activity 2026-10-10

Pitfalls

  • Pixel format names are written in memory order of the engine's channel naming, so BGRA8888 is bytes B,G,R,A. Players commonly meet DXT1, DXT5, BGRA8888 and RGBA16161616F (HDR).
  • public/vtf/vtf.h lines 133-148 (SDK 2013) lists 7 cubemap faces (right, left, back, front, up, down, plus a fallback spheremap) and notes the +y/-y naming of back/front is odd. Unverified: that files of version 7.5 store only 6 faces comes from community documentation, not the SDK header.

Evidence & references

ValveSoftware/source-sdk-2013 src/public/vtf/vtf.h and src/public/bitmap/imageformat.h at commit be57e3d.