Skip to content
tranek edited this page Mar 10, 2015 · 10 revisions

vtex_c File Structure

Headers

Main File

  • 4 bytes: size of entire file
  • 4 bytes: header version
  • 4 bytes: ?
  • 4 bytes: number of blocks

Block Headers

  • 4 bytes: Block name (RERL, REDI, NTRO, and/or DATA). RERL seems to be optional.
  • 4 bytes: offset from this location where this block starts
  • 4 bytes: length of block

Block Types

  • RERL: Lists external and deferred resources by ID. Not typically used in vtex_c files.
  • REDI: Resource Edit Info Block. Seems to be stuff related to how the file was compiled.
  • NTRO: Resource Introspection Manifest. This block holds the keys for the DATA block's values.
  • DATA: The data values.
  • After DATA: Raw binary data. Image data in the case of vtex_c.

Block: DATA

  • 2 bytes: texture width
  • 2 bytes: texture height
  • 2 bytes: texture depth
  • 1 byte: texture format
  • 1 byte: mip count
  • 6 bytes: ???
  • 8 bytes: texture flags
  • 4 bytes: texture reflectivity
  • 15 bytes: ???
  • x bytes: fallback texture bits

Raw Binary Data

  • Starts immediately after the DATA block.
  • Organized consecutively by mip level, largest number (smallest in size) to smallest number (largest in size).
  • Mip level 0 (largest mip image size) is listed last with its last byte being the last byte in the vtex_c file. This is the mip level that is extracted to the .tga file.
  • Each mip level can have multiple images depending on the texture depth and if it is a cubemap or not.
  • Each image is stored as DXT1 or DXT5 (so far) raw binary data with no DDS/DXT headers.
  • Normal maps are stored in DXT5-nm format with the Red channel in the Alpha channel, the Blue channel removed, and the Green channel unchanged. The Blue channel will need to be recomputed at run-time in the pixel shader. Good info about DXT5-nm: http://tech-artists.org/wiki/Normal_map_compression