VMT: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(otherlang2)
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(50 intermediate revisions by 26 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar}}
| de = Material:de
 
| fr = Material:fr
{{todo|Move engine-agnostic stuff to [[material]].}}
| jp = Material:jp
A '''VMT''' ("Valve Material") file defines the [[material]] used by a two-dimensional surface. It contains all of the information needed for {{src|4}} to simulate the surface visually, aurally, and physically.<br>If a material is missing, it will produce the infamous Source pink and black checkered pattern. A white wireframe is not a missing material, but instead a missing [[shader]].
}}
 
__TOC__


A '''material''' is a <code>.vmt</code> text file that defines a two-dimensional surface. It contains all of the information needed for Source to simulate the surface visually, aurally, and physically. VMT stands for "Valve Material Type".


The contents of a material will fall into some or all of these categories:
The contents of a material will fall into some or all of these categories:


# [[Texture]] names
# [[Texture]] names
# [[Material surface properties|Physical surface types]]
# [[$surfaceprop|Physical surface]] [[Material surface properties|types]]
# [[Shader]]-specific parameters
# [[:Category:Shaders|Shader]] [[:Category:List of Shader Parameters|parameters]]
# [[Material Map Compile Flags|Special compile properties]]
# [[Material optimization|Fallbacks]]
# [[Material optimization|Fallbacks]]
# [[Material Proxy|Proxies]]
# [[Material Proxy|Proxies]]


== A simple example ==
== A simple example ==
{{CodeBlock|<nowiki>LightmappedGeneric
{
$basetexture "coast/shingle_01"
$surfaceprop gravel
}</nowiki>}}
''This is a very basic [[Wikipedia:Shingle beach|shingle beach]] material.''
#The <code>[[LightmappedGeneric]]</code> shader is used, which means that the material is for use on surfaces with [[lightmap]]s (i.e. [[brush]]es).
#''The opening curly brace ({{Code|<nowiki>{</nowiki>}}) opens a set of parameters''
#The <code>[[$basetexture]]</code> parameter is given with <code>coast\shingle_01</code>, which is the location of a texture. This is what will be drawn on the screen.
#<code>[[$surfaceprop]]</code> gives the material the physical properties of gravel.
#''The closing curly brace ({{Code|<nowiki>}</nowiki>}}) character closes a set of parameters''
It's important to remember that this material can only be used on brushes. If it needed to be used on [[model]]s, for instance, another version would need to be created using the {{code|[[VertexLitGeneric]]}} shader.


LightmappedGeneric
Most of the time switching materials from one shader to another is as simple as changing their first line, since a great number of parameters are shared between them. Some params only work with certain shaders, like [[Phong]] effects, which are only available with {{code|[[VertexLitGeneric]]}}, but unfortunately you won't encounter any critical errors if a param isn't understood by the shader. It just won't have any effect.
{
$basetexture coast\shingle_01
$surfaceprop gravel
}


This is a very basic [[Wikipedia:Shingle beach|shingle beach]] material.
{{tip|If you ever need to use a space, tab, or curly brace character in a parameter value, you must wrap the whole value with "quote marks". You'll often see absolutely everything wrapped like this - save yourself some typing, as that's unnecessary.}}
{{bug|hidetested=1|Sometimes{{when}}, the first parameter defined in the VMT will fail to load. If this happens, a dummy parameter such as {{code|$bug}} can be used.}}


#The <code>[[LightmappedGeneric]]</code> shader is used, which means that the material is for use on surfaces with [[lightmap]]s - i.e. [[brush]]es.
== Finding materials ==
#''The { character opens a set of parameters''
#The <code>[[$basetexture]]</code> parameter is given with <code>coast\shingle_01</code> (a texture). This is what will be drawn on the screen.
#<code>[[$surfaceprop]]</code> gives the material the physical properties of gravel.
#''The } character closes a set of parameters''


It's important to remember that this material can only be used on brushes. If it needed to be used on [[model]]s, for instance, another version would need to be created using the <code>[[VertexLitGeneric]]</code> shader.
=== SteamPipe ===


Most of the time switching materials from one shader to another is as simple as changing their first line, since a great number of parameters are shared between them. But some params only work with certain shaders - for instance, [[Phong]] effects are only available with <code>VertexLitGeneric</code>. The good news is that you won't encounter any critical errors if a param isn't understood by the shader.
When Valve updated all {{src|4}} games to [[SteamPipe]], all materials were moved from [[GCF]] into [[VPK]] files. Third-party games (running on {{src04|1}} - {{src09|1}}) that previously used [[GCF]] files are also having it's materials moved to depot [[VPK]] files. VPK Files work with {{gcfscape|4}} and {{vpkedit|4}}.


{{tip|If you ever need to use a space or tab character in a parameter value, you must wrap the whole value with "quote marks". You'll often see absolutely everything wrapped like this - save yourself some typing, as that's unnecessary.}}
More info on SteamPipe [https://support.steampowered.com/kb_article.php?ref=7388-QPFN-2491 here]


== Finding materials ==
=== Non-SteamPipe Games ===


Materials are stored in the <code>materials\</code> folder of your game or mod. The best way to browse them is from [[Hammer]]'s texture selection screen.
In non [[SteamPipe]] {{src|4}} games, Materials are stored in the {{Path|materials\}} folder of your game or mod. The best way to browse them is from {{hammer|4}}'s texture selection screen.


If you want to edit or view the code of Valve's material files you will first need to extract them from their [[GCF]] package with [[GCFScape]]. They tend to be stored in GCFs with 'materials' in their name.
If you want to edit or view the code of Valve's material files you will first need to extract them from their [[GCF]] package with {{gcfscape|4}}. They tend to be stored in GCFs with 'materials' in their name.


== See also ==
== See also ==


*[[Creating a Material]]
* [[Creating a Material]]
*[[Notepadpp VDF languages|Notepad++ syntax highlighting for materials]]
* [[Notepad++ VDF languages|Notepad++ syntax highlighting for materials]]
* [[$basetexture]]
* [[Valve Texture Format]]
* [[$envmapmask]] (specular mask)
* [[Shader]]
* [[$envmap]] (environment map)
* [[:Category:List of Shader Parameters|List of Shader Parameters]]
* [[$phong]] (diffuse reflection)
* [[Source VMT Editor]]
* [[$selfillum]]
* [https://github.com/Xyphos/VMTGen VMTGen]
* [http://www.therazzerapp.de/tutorials/vmt_erstellen.html German Tutorial by TheRaZZeRApp]  


[[Category:Material System]]
[[Category:Material System]]
[[Category:Glossary]]
[[Category:Source]]
[[Category:File formats]]

Latest revision as of 07:07, 20 May 2025

English (en)Deutsch (de)Español (es)Français (fr)한국어 (ko)Русский (ru)Translate (Translate)
Todo: Move engine-agnostic stuff to material.

A VMT ("Valve Material") file defines the material used by a two-dimensional surface. It contains all of the information needed for Source Source to simulate the surface visually, aurally, and physically.
If a material is missing, it will produce the infamous Source pink and black checkered pattern. A white wireframe is not a missing material, but instead a missing shader.


The contents of a material will fall into some or all of these categories:

  1. Texture names
  2. Physical surface types
  3. Shader parameters
  4. Special compile properties
  5. Fallbacks
  6. Proxies

A simple example

LightmappedGeneric { $basetexture "coast/shingle_01" $surfaceprop gravel }

This is a very basic shingle beach material.

  1. The LightmappedGeneric shader is used, which means that the material is for use on surfaces with lightmaps (i.e. brushes).
  2. The opening curly brace ({) opens a set of parameters
  3. The $basetexture parameter is given with coast\shingle_01, which is the location of a texture. This is what will be drawn on the screen.
  4. $surfaceprop gives the material the physical properties of gravel.
  5. The closing curly brace (}) character closes a set of parameters

It's important to remember that this material can only be used on brushes. If it needed to be used on models, for instance, another version would need to be created using the VertexLitGeneric shader.

Most of the time switching materials from one shader to another is as simple as changing their first line, since a great number of parameters are shared between them. Some params only work with certain shaders, like Phong effects, which are only available with VertexLitGeneric, but unfortunately you won't encounter any critical errors if a param isn't understood by the shader. It just won't have any effect.

Tip.pngTip:If you ever need to use a space, tab, or curly brace character in a parameter value, you must wrap the whole value with "quote marks". You'll often see absolutely everything wrapped like this - save yourself some typing, as that's unnecessary.
Icon-Bug.pngBug:Sometimes[When?], the first parameter defined in the VMT will fail to load. If this happens, a dummy parameter such as $bug can be used.

Finding materials

SteamPipe

When Valve updated all Source Source games to SteamPipe, all materials were moved from GCF into VPK files. Third-party games (running on Source 2004 - Source 2009) that previously used GCF files are also having it's materials moved to depot VPK files. VPK Files work with GCFScape GCFScape and VPKEdit VPKEdit.

More info on SteamPipe here

Non-SteamPipe Games

In non SteamPipe Source Source games, Materials are stored in the 🖿materials\ folder of your game or mod. The best way to browse them is from Hammer Hammer's texture selection screen.

If you want to edit or view the code of Valve's material files you will first need to extract them from their GCF package with GCFScape GCFScape. They tend to be stored in GCFs with 'materials' in their name.

See also