Fr/Valve Texture Format: Difference between revisions

From Valve Developer Community
< Fr
Jump to navigation Jump to search
No edit summary
No edit summary
Line 173: Line 173:
|}
|}


== File format ==
The VTF image format is described as follows.
=== VTF layout ===
VTF Header
VTF Low Resolution Image Data
For Each Mipmap (Smallest to Largest)
  For Each Frame (First to Last)
    For Each Face (First to Last)
      For Each Z Slice (Min to Max; Varies with Mipmap)
        VTF High Resolution Image Data
=== VTF enumerations ===
enum
{
IMAGE_FORMAT_NONE = -1,
IMAGE_FORMAT_RGBA8888 = 0,
IMAGE_FORMAT_ABGR8888,
IMAGE_FORMAT_RGB888,
IMAGE_FORMAT_BGR888,
IMAGE_FORMAT_RGB565,
IMAGE_FORMAT_I8,
IMAGE_FORMAT_IA88,
IMAGE_FORMAT_P8,
IMAGE_FORMAT_A8,
IMAGE_FORMAT_RGB888_BLUESCREEN,
IMAGE_FORMAT_BGR888_BLUESCREEN,
IMAGE_FORMAT_ARGB8888,
IMAGE_FORMAT_BGRA8888,
IMAGE_FORMAT_DXT1,
IMAGE_FORMAT_DXT3,
IMAGE_FORMAT_DXT5,
IMAGE_FORMAT_BGRX8888,
IMAGE_FORMAT_BGR565,
IMAGE_FORMAT_BGRX5551,
IMAGE_FORMAT_BGRA4444,
IMAGE_FORMAT_DXT1_ONEBITALPHA,
IMAGE_FORMAT_BGRA5551,
IMAGE_FORMAT_UV88,
IMAGE_FORMAT_UVWQ8888,
IMAGE_FORMAT_RGBA16161616F,
IMAGE_FORMAT_RGBA16161616,
IMAGE_FORMAT_UVLX8888
};
enum
{
TEXTUREFLAGS_POINTSAMPLE = 0x00000001,
TEXTUREFLAGS_TRILINEAR = 0x00000002,
TEXTUREFLAGS_CLAMPS = 0x00000004,
TEXTUREFLAGS_CLAMPT = 0x00000008,
TEXTUREFLAGS_ANISOTROPIC = 0x00000010,
TEXTUREFLAGS_HINT_DXT5 = 0x00000020,
TEXTUREFLAGS_NOCOMPRESS = 0x00000040,
TEXTUREFLAGS_NORMAL = 0x00000080,
TEXTUREFLAGS_NOMIP = 0x00000100,
TEXTUREFLAGS_NOLOD = 0x00000200,
TEXTUREFLAGS_MINMIP = 0x00000400,
TEXTUREFLAGS_PROCEDURAL = 0x00000800,
TEXTUREFLAGS_ONEBITALPHA = 0x00001000,
TEXTUREFLAGS_EIGHTBITALPHA = 0x00002000,
TEXTUREFLAGS_ENVMAP = 0x00004000,
TEXTUREFLAGS_RENDERTARGET = 0x00008000,
TEXTUREFLAGS_DEPTHRENDERTARGET = 0x00010000,
TEXTUREFLAGS_NODEBUGOVERRIDE = 0x00020000,
TEXTUREFLAGS_SINGLECOPY = 0x00040000,
TEXTUREFLAGS_ONEOVERMIPLEVELINALPHA = 0x00080000,
TEXTUREFLAGS_PREMULTCOLORBYONEOVERMIPLEVEL = 0x00100000,
TEXTUREFLAGS_NORMALTODUDV = 0x00200000,
TEXTUREFLAGS_ALPHATESTMIPGENERATION = 0x00400000,
TEXTUREFLAGS_NODEPTHBUFFER = 0x00800000,
TEXTUREFLAGS_NICEFILTERED = 0x01000000,
TEXTUREFLAGS_CLAMPU = 0x02000000
};
=== VTF header ===
typedef struct tagVTFHEADER
{
char signature[4]; // File signature ("VTF\0").
unsigned int version[2]; // version[0].version[1] (currently 7.2).
unsigned int headerSize; // Size of the header struct (16 byte aligned; currently 80 bytes).
unsigned short width; // Width of the largest mipmap in pixels. Must be a power of 2.
unsigned short height; // Height of the largest mipmap in pixels. Must be a power of 2.
unsigned int flags; // VTF flags.
unsigned short frames; // Number of frames, if animated (1 for no animation).
unsigned short firstFrame; // First frame in animation (0 based).
unsigned char padding0[4]; // reflectivity padding (16 byte alignment).
float reflectivity[3]; // reflectivity vector.
unsigned char padding1[4]; // reflectivity padding (8 byte packing).
float bumpmapScale; // Bumpmap scale.
unsigned int highResImageFormat; // High resolution image format.
unsigned char mipmapCount; // Number of mipmaps.
unsigned int lowResImageFormat; // Low resolution image format (always DXT1).
unsigned char lowResImageWidth; // Low resolution image width.
unsigned char lowResImageHeight; // Low resolution image height.
unsigned short depth; // Depth of the largest mipmap in pixels.
// Must be a power of 2. Can be 0 or 1 for a 2D texture (v7.2 only).
} VTFHEADER;
=== VTF lo-res image data ===
Tightly packed low resolution image data in the format described in the header. The low resolution image data is always stored in the DXT1 compressed image format. Its dimensions are that of the largest mipmap with a width or height that does not exceed 16 pixels. i.e. for a 256x256 pixel VTF: 16x16, for a 256x64 pixel VTF: 16x4, for a 1x32 pixel VTF: 1x16, for a 4x4 pixel VTF: 4x4.
=== VTF hi-res image data ===
Tightly packed interleaved high resolution image data in the format described in the header. Common image formats include DXT1, DXT5, BGR888, BGRA8888 and UV88. All dimensions must be a [http://en.wikipedia.org/wiki/Power_of_two power of two].


=== Version history ===
=== Version history ===
Line 314: Line 210:
;[[VTF Explorer]]:VTF and VMT viewer\explorer GUI. Easy and extensible VMT creation. Can browse [[GCF]] files.
;[[VTF Explorer]]:VTF and VMT viewer\explorer GUI. Easy and extensible VMT creation. Can browse [[GCF]] files.
;[[studiocompiler]]: includes VTF and VMT compile & decompile GUI.
;[[studiocompiler]]: includes VTF and VMT compile & decompile GUI.
[[Category:Glossary]]
[[Category:Material_System]]

Revision as of 09:55, 1 November 2008

Le VTF est un [format] propriétaire de Vavle utiliser par le Moteur Source. Il sont assigner à une surface et controler par un VMT. Bien souvent on utiliser plusieurs VTF pour une surface, par exemple pour un sol rugueux on utilise la texture de base plus une texture de Bump, soit deux VTF.

Les fichier VTF peuvent être converties à partir de TGA, un bon format pour travailler. Il est recommander d'utiliser VTFEdit pour la conversion, ce logiciel possède une interface contrairement à Vtex, et peut créer les VMT facilement. Il vous faudra ensuite choisir une compressions.

Comme dans tous moteur de jeux il est important de mettre pour vos texture une résolutions en multiple de 2. Par exemple 512*512 ou 1024*512 sont correct.

1
2
4
8
16
32
64
128
256
512
1024
2048
4096

Capacité du format

Ce format peut stocker vos textures, mais aussi un environement map, des textures volumetrique ; et chacun peut avoir plusieurs frames. Frame? C'est une suite d'image dans le même VTF, par exemple pour réaliser une texture animé, l'eau est un belle exemple.


  • Une map d'environement est une texture en 6 face deplier pour pouvoir former un cubemap, ou elle peut être une simple face deformer pour s'ajuster sur une sphere. (mais cela est deconseiller).
  • Pour chaque image, le VTF contient votre texture de base, plus la même en differentes resolutions plus basse : le MIPMAP. Le moteur ajuste ainsi selon la distance quelle texture il prendra.
  • Le VTF peut aussi inclure des données comme :
    • Une clé pour indiquer le départ d'une animations
    • L'echelle du bumpmap
    • Les vecteur de reflexion
    • Une petite image pour la visualiser dans hammer

Compressions d'image

Vous pouvez choisir un format de compression avec pertes (DXT) ou non compresser, mais les fichier images seront volumineux.

Compression supportée

Format Red Bits Green Bits Blue Bits Alpha Bits Total Bits Compressed Supported Comment
A8 0 0 0 8 8 False True
ABGR8888 8 8 8 8 32 False True
ARGB8888 8 8 8 8 32 False True
BGR565 5 6 5 0 16 False True
BGR888 8 8 8 0 24 False True
BGR888_BLUESCREEN 8 8 8 0 24 False True
BGRA4444 4 4 4 4 16 False True
BGRA5551 5 5 5 1 16 False True
BGRA8888 8 8 8 8 32 False True
BGRX5551 5 5 5 0 16 False True
BGRX8888 8 8 8 0 32 False True
DXT1 N/A N/A N/A 0 4 True True
DXT1_ONEBITALPHA N/A N/A N/A 1 4 True True
DXT3 N/A N/A N/A 4 8 True True Uninterpolated Alpha
DXT5 N/A N/A N/A 4 8 True True Interpolated Alpha
I8 N/A N/A N/A N/A 8 False True Luminance (Grayscale)
IA88 N/A N/A N/A 8 16 False True Luminance (Grayscale)
P8 N/A N/A N/A N/A 8 False False Paletted
RGB565 5 6 5 0 16 False True
RGB888 8 8 8 0 24 False True
RGB888_BLUESCREEN 8 8 8 0 24 False True
RGBA16161616 16 16 16 16 64 False True HDR Format
RGBA16161616F 16 16 16 16 64 False True Floating Point HDR Format
RGBA8888 8 8 8 8 32 False True
UV88 N/A N/A N/A N/A 16 False True
UVLX8888 N/A N/A N/A N/A 32 False True
UVWQ8888 N/A N/A N/A N/A 32 False True
Comparison of how DXTn compression affects different types of images

Choix de la compression

Mais heureusement seul quelque-un vont nous servir :

  • BGR888: Utiliser celui-ci pour une texture sans canal alpha et avec des dégradé très fins.(bump ou halo pour les lumières).
  • BGRA8888: Utiliser celui-ci pour une texture sans canal alpha et avec des dégradé très fins.(bump ou halo pour les lumières).
  • DXT1: Pour une utilisation courante sans canal alpha.
  • DXT3: Pour une utilisation courante avec canal alpha et avec dégrader net.
  • DXT5: Pour une utilisation courante avec canal alpha et avec dégrader lisse.
  • I8: Pour une txture noir et blanc sans canal alpha et avec des dégradé très fins (halo pour les lumières).
  • IA88: Pour une txture noir et blanc avec canal alpha et avec des dégradé très fins (fumé ou halo).
  • RGBA16161616F: Pour HDR.
  • UV88: Pour DuDv.

Image flags

A VTF file can contain the following flags:

Flag Value Comment
Point Sampling 0x0001 Low quality texture filtering.
Trilinear Sampling 0x0002 Medium quality texture filtering.
Clamp S 0x0004 Clamp S coordinates.
Clamp T 0x0008 Clamp T coordinates.
Anisotropic Sampling 0x0010 High quality texture filtering.
Hint DXT5 0x0020 Used in skyboxes. Makes sure edges are seamless.
No Compress 0x0040 No DXT compression used.
NORMAL 0x0080 Texture is a normal map.
No Mipmaps 0x0100 Render largest mipmap only.
No LOD 0x0200 Use largest mipmap set, even on old hardware.
Min Mipmap 0x0400
Procedural 0x0800 Texture is an procedural texture (code can modify it).
One Bit Alpha 0x1000 One bit alpha channel used.
Eight Bit Alpha 0x2000 Eight bit alpha channel used.
Environment Map 0x4000 Texture is an environment map.
Render Target 0x8000 Texture is a render target.
Depth Render Target 0x10000 Texture is a depth render target.
No Debug Override 0x20000
Single Copy 0x40000
One Over Mipmap Level In Alpha 0x80000 Fill the alpha channel with 1/Mipmap Level. (Internal to VTEX?)
Premultiply Color By One Over Mipmap Level 0x100000 (Internal to VTEX?)
Normal To DuDv 0x200000 Texture is a DuDv map. (Internal to VTEX?)
Alpha Test Mipmap Generation 0x400000 (Internal to VTEX?)
No Depth Buffer 0x800000
Nice Filtered 0x1000000 Use NICE filtering to generate mipmaps. (Internal to VTEX?)
Clamp U 0x2000000 Clamp U coordinates (for volumetric textures).


Version history

v7.4

  • Released October 10th, 2007 as part of The Orange Box.
  • Bitwise equivalent to v7.3.
  • Addresses issues related to how gamma-correction is performed on textures for TV-output on XBOX 360 combined with hunting down OS Paged Pool Memory.

v7.3

  • Added an extensible resource orientated structure.
  • Added CRC, Texture LOD Control and Sheet resources, along with backwards compatible Image and Low Resolution Image resources.
  • Added several vendor specific depth-stencil formats (for internal engine use), along with normal map formats and linear uncompressed formats.
  • Released September 18th, 2007 as part of the Team Fortress 2 beta.

v7.2

  • Added volumetric texture support.
  • Released September 23rd, 2005 as a Steam engine update.

v7.1

  • Added spheremap support to environment maps. (This was intended for DirectX 6 support which was later cut.)

v7.0

  • Initial release. (Internal release only, however, some v7.0 textures made it to the published title.)

Implementation

An example Steam independent implementation of the VTF image file format can be found in the LGPL C/C++ library VTFLib.

Utilities

3DSMax VTF plugin
3D Studio Max 6/7/8 VTF Plug-in.
IrfanView
General purpose image viewer with optional VTF support (see PlugIns section).
Paint.NET Plug-in
Paint.NET VTF Plug-in.
Photoshop Plug-in
Photoshop 6 (and up) VTF Plug-in.
Shell Extension
Windows XP/2000 VTF shell extension.
VTFTool
Windows based VTEX and VTF2TGA replacement.
VTFCmd
VTF and VMT command line editing tool (VTEX clone).
VTFEdit
VTF and VMT viewer and editing GUI.
VTF Explorer
VTF and VMT viewer\explorer GUI. Easy and extensible VMT creation. Can browse GCF files.
studiocompiler
includes VTF and VMT compile & decompile GUI.