TGA

From Valve Developer Community
Jump to: navigation, search
Deutsch

Truevision Graphics Adapter (TGA), commonly referred to as "targa" (Truevision Advanced Raster Graphics Adapter), is a non-proprietary image format from Truevision that is favoured by Valve. The file extension for targas is .tga. It is the base format for Valve Texture Files (.vtf), and used to store images used by the Steam client.

The format stores the basic RGB (red, green, blue) channels with 8 bit precision (0-255) each, for a total of 24 bits/pixel, with an optional additional 8 bit alpha channel, for a total of 32 bits/pixel. The extra channel contains information that the VMT shaders can use for effects such as transparency or specularity.

Most Textures in Source start life as TGAs which are edited and adjusted with any suitable image editor. The TGA is then compiled into the Valve Texture Format (VTF) using Vtex.exe (or a third-party tool such as VTFEdit) to participate in the Material System.


Targa for Vtex

Valid format

For a targa image to be recognized as valid by Vtex, it must meet the following criteria:

  • It must be 24 or 32 bits/pixel in depth. (16 bits/pixel is not recognized.)
  • Its dimensions (height and width) must have a pixel size equal to a power of 2. (i.e. 2^4=16, 2^5=32, 2^6=64, 2^7=128, 2^8=256, 2^9=512, etc.)
  • Its dimensions can not be bigger than 2048 pixels.
  • The height and width doesn't need to be the same - 64x128, 256x512 works fine - but square images are preferred by the Source engine, so use them whenever possible, even when it doesn't seem like the best way to go.
  • RLE compression is optional, but should be avoided due to occasional conversion troubles.

Scale

The default texture scale in Hammer is 0.25. This means that 1 texture pixel = 0.25 map units in Hammer and in game, or a 512x512 texture covers 128x128 map units (equivalent to 8x8 feet or 2.4x2.4 meters).

Relative Dimensions for (Default) Texture Scale 0.25
Texture Hammer FileSize
pixels map units kB (32bit)
4 x 4 1 x 1 0.06
8 x 8 2 x 2 0.25
16 x 16 4 x 4 1
32 x 32 8 x 8 4
64 x 64 16 x 16 16
128 x 128 32 x 32 64
256 x 256 64 x 64 256
512 x 512 128 x 128 1024 (1MB) This is the most common size for archictextures : brickwork, concrete, etc.
1024 x 1024 256 x 256 4096 (4MB)
2048 x 2048 512 x 512 16384 (16MB) This is the largest size that vtex can cope with and is only used for large non-tiling brushes like 2D skyboxes.
  • Texture (pixels) : Square format is preferred but rectangles are acceptable. Each dimension must be a power of two upto 2048.
  • Hammer (map units) : using the default Texture Scale of 0.25. This can be overridden locally per surface in Hammer or per material by using the $basetexturetransform scale factor in the VMT. For example A 512x512 texture with a scale of 0.5 will cover only 64x64 map units, and when viewed up close should appear highly detailed.
  • Filesize (kB) : is given for 32bit uncompressed rasta image. To do: VTF uses it's own compression system ...
Note:3D Skybox scale is 1/16th of map scale, so textures for 3D skybox surfaces should be designed accordingly.

Save location

Remember that Vtex is only able to locate targa images located inside the /materialsrc/ folder of the current game, so you may want to save it there directly to spare you the trouble of having to move it there later.

External links