Loading Source Engine vtf's with Go
September 07, 2018
A more recent project of mine has been writing a BSP level visualiser in Golang. Naturally this means plenty of parsers for proprietary formats required, the first after the bsp itself being the ability to add textures to bsp face data. Valve created their own (pair of) format(s) for materials and textures; .vmt (Valve Material Format) & .vtf (Valve Texture Format). I’ll cover vmt another day, as its basically a plaintext key-value store that loosely resembles JSON (it may be a more common format that I haven’t encountered before).
So, vtf. VTF is quite a useful,simple format, as it doesn’t actually store any texture data in a proprietary format. Instead, it’s more of a container for many different storage or compression formats, along with space for metadata associated with the stored format, and what it represents.
Anyway, I found there was no go library for parsing vtf textures (quite understandably, its not exactly a common requirement!). So I built one. The featureset is more or less the same as vtflib for reading vtfs, although there is, and likely wont be support for writing vtfs.
See the readme for more information about support: https://github.com/galaco/vtf