Texture

From GMod Wiki

Revision as of 22:10, 23 November 2010 by Di-0xide (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

A texture is an image file-set that is tiled on a 3d or 2d object, or used in surface drawing. For Source, textures are made up of a .VTF file, which is the raw image data, and a .VMT file, which supplies information about the texture. Textures are referred to by the name of their VMT/VTF filenames (i.e. a file with the name "sometexture.vtf" is usually referred to as "sometexture" in the Source engine).

There are many VTF/VMT editors/converters/creators out there, the most popular and most complete being "VTFLib"[1].

VTF Files

VTF files contain the raw image data of a texture. Most texture files are converted to VTF format from the popular TIF(F) format; this allows for high quality images along with 1 or 8 bit alpha channels (if needed).

VTF files must be accompanied by a VMT file in order to work with the Source engine.

VMT Files

VMT files are required for VTF files to display properly. Without a VMT file, the VTF file will show the black/purple 'error' texture.


VMT files are, contrary to popular belief, simply text files describing a VTF file. Since both go hand in hand (you can't use one without the other), VMT files are generally created along-side VTF files in many of the popular texture creation programs on the internet.

VMT files contain an in-depth description about how a texture should be drawn, processed, shaded, lit, etc.

Surface Drawing

Since "surface" drawing (drawing 2D images on the screen) cannot use lighting or other 3D coloring aspects, VMT files must describe a VTF file as "UnLit". If you need a file to be drawn on the screen and have no lighting properties, simply edit the VMT file to match the following format.

"UnlitGeneric"
{
	"$basetexture" "vtf_filename"
	"$translucent" 1
	"$vertexalpha" 1
	"$vertexcolor" 1
}

You would then use surface.GetTextureID to get the texture ID from the filename and path.

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox