Material Flags: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(All of the material flags which change properties.)
 
No edit summary
Line 1: Line 1:
Several special shader parameters exist, starting with a <code>%</code> sign instead of <code>$</code>. These are read by the compile tools to alter the properties of the face or the brush they are attached to. Most are intended to produce the special <code>tools/</code> textures, but may also be used for other materials. All are boolean properties. These cannot be affected by [[Material_Proxies|Proxies]].
Material <code>$flags</code> and <code>$flags2</code> parameters control how the material is rendered. <code>$flag</code> can be changed in real-time to allow changes in rendering, but <code>$flags2</code> is read-only and assists the engine or other code in using the material correctly.
 
See also [[Tool_textures|Tool Textures]] for more detail about the propeties of individual materials.


The flags can also be set via the .vmt
Example:
Example:
 
#Sets the MATERIAL_VAR_VERTEXCOLOR and MATERIAL_VAR_VERTEXALPHA flag
  LightmappedGeneric
  UnlitGeneric
  {
  {
  $basetexture developer/custom_clip
  $basetexture brick/brickwall003a
  '''%compileclip 1'''
  $vertexcolor 1
$vertexalpha 1
  }
  }
   
   
== Exclusive Flags ==
== $flags ==
Only one of these flags may be set on any given material.
$flags can contain the following flags:
 
==== %CompileClip (<code>toolsclip</code>) ====
[[image:Toolsclip.gif|32px]] Makes the brush block only players and NPCs. This is equivalent to a combination of '''PlayerClip''' and '''NPCClip'''.
 
=== %CompileNoChop ===
Prevents 'subdividing patches' on the surface. This presumably affects how the face is converted to triangles.


=== %CompileNPCClip (<code>toolsnpcclip</code>) ===
{| class=standard-table
[[image:Toolsnpcclip.gif|32px]] Makes the brush block only NPCs. This implies '''NoLight''' and '''NoDraw'''.
| '''Flag''' || '''Value''' || '''Comment'''
|-
| MATERIAL_VAR_DEBUG || 0x0001 ||
|-
| MATERIAL_VAR_NO_DEBUG_OVERRIDE || 0x0002 ||
|-
| MATERIAL_VAR_NO_DRAW || 0x0004 ||
|-
| MATERIAL_VAR_USE_IN_FILLRATE_MODE || 0x0008 ||
|-
| MATERIAL_VAR_VERTEXCOLOR || 0x0010 || [[$vertexalpha]]
|-
| MATERIAL_VAR_VERTEXALPHA || 0x0020 || [[$vertexalpha]]
|-
| MATERIAL_VAR_SELFILLUM || 0x0040 ||
|-
| MATERIAL_VAR_ADDITIVE || 0x0080 ||
|-
| MATERIAL_VAR_ALPHATEST || 0x0100 ||
|-
| MATERIAL_VAR_MULTIPASS || 0x0200 ||
|-
| MATERIAL_VAR_ZNEARER || 0x0400 ||
|-
| MATERIAL_VAR_MODEL || 0x0800 ||
|-
| MATERIAL_VAR_FLAT || 0x1000 ||
|-
| MATERIAL_VAR_NOCULL || 0x2000 ||
|-
| MATERIAL_VAR_NOFOG || 0x4000 ||
|-
| MATERIAL_VAR_IGNOREZ || 0x8000 ||
|-
| MATERIAL_VAR_DECAL || 0x10000 ||
|-
| MATERIAL_VAR_ENVMAPSPHERE || 0x20000 ||
|-
| MATERIAL_VAR_NOALPHAMOD || 0x40000 ||
|-
| MATERIAL_VAR_ENVMAPCAMERASPACE || 0x80000 ||
|-
| MATERIAL_VAR_BASEALPHAENVMAPMASK || 0x100000 ||
|-
| MATERIAL_VAR_TRANSLUCENT || 0x200000 ||
|-
| MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK || 0x400000 ||
|-
| MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING || 0x800000 ||
|-
| MATERIAL_VAR_OPAQUETEXTURE || 0x1000000 ||
|-
| MATERIAL_VAR_ENVMAPMODE || 0x2000000 ||
|-
| MATERIAL_VAR_SUPPRESS_DECALS || 0x4000000 ||
|-
| MATERIAL_VAR_HALFLAMBERT || 0x8000000 ||
|-
| MATERIAL_VAR_WIREFRAME || 0x10000000 ||
|-
| MATERIAL_VAR_ALLOWALPHATOCOVERAGE || 0x20000000 ||
|-
| MATERIAL_VAR_IGNORE_ALPHA_MODULATION || 0x40000000 ||
|}


=== %CompileOrigin (<code>toolsorigin</code>) ===
== $flags2 ==
[[image:Toolsorigin.gif|32px]] Sets the origin of a brush entity. This is deprecated for Source maps, in GoldSource origin brushes were used to set the rotation origin of rotating entities.
$flags2 can contain the following flags:


=== %CompileTrigger (<code>toolstrigger</code>) ===
{| class=standard-table
[[image:Toolstrigger.gif|32px]] Makes the brush suitable for [[Trigger|Triggers]].
| '''Flag''' || '''Value''' || '''Comment'''
 
|-
=== %CompileSkip(toolsskip) ===
| MATERIAL_VAR2_LIGHTING_UNLIT || 0x0000 ||
[[image:Toolsskip.gif|32px]] Removes the face during compilation, making the brush into sets of planes.
|-
 
| MATERIAL_VAR2_LIGHTING_VERTEX_LIT || 0x0001 ||
=== %CompileSky (toolsskybox) ===
|-
[[image:Toolsskybox.gif|32px]] Makes the face render the (2D/3D) [[Skybox]], and emit [[light_environment]] light.
| MATERIAL_VAR2_LIGHTING_LIGHTMAP0 || 0x0002 ||
 
|-
=== %Compile2DSky (toolsskybox2d) ===
| MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP || 0x0004 ||
[[image:Toolsskybox2d.gif|32px]] Makes the face render the 2D [[Skybox]] only, in addition to emitting [[light_environment]] light.
|-
 
| MATERIAL_VAR2_LIGHTING_MASK 0x0001 + 0x0002 + 0x0004
=== %PlayerClip (<code>tools/toolsplayerclip</code>) ===
|-
[[image:Toolsplayerclip.gif|32px]] Makes the brush only block players.
| MATERIAL_VAR2_DIFFUSE_BUMPMAPPED_MODEL || 0x0008 ||
 
|-
=== %CompileNoLight (<code>nolight</code>) ===
| MATERIAL_VAR2_USES_ENV_CUBEMAP || 0x0010 ||
Disables generating lightmaps for a brush face. Useful for materials that don't need lighting info or are always invisible. This is disabled on water materials. [[Valve]] introduced this parameter with [[Alien Swarm]], using it for the black areas you see in the levels.
|-
 
| MATERIAL_VAR2_NEEDS_TANGENT_SPACES || 0x0020 ||
== Additive Flags ==
|-
Multiple of these flags may be applied to any given material.
| MATERIAL_VAR2_NEEDS_SOFTWARE_LIGHTING || 0x0040 ||
|-
| MATERIAL_VAR2_BLEND_WITH_LIGHTMAP_ALPHA || 0x0080 ||
|-
| MATERIAL_VAR2_NEEDS_BAKED_LIGHTING_SNAPSHOTS || 0x0100 ||
|-
| MATERIAL_VAR2_USE_FLASHLIGHT || 0x0200 ||
|-
| MATERIAL_VAR2_USE_FIXED_FUNCTION_BAKED_LIGHTING || 0x0400 ||
|-
| MATERIAL_VAR2_NEEDS_FIXED_FUNCTION_FLASHLIGHT || 0x0800 ||
|-
| MATERIAL_VAR2_USE_EDITOR || 0x1000 ||
|-
| MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE || 0x2000 ||
|-
| MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE || 0x4000 ||
|-
| MATERIAL_VAR2_IS_SPRITECARD || 0x8000 ||
|-
| MATERIAL_VAR2_USES_VERTEXID || 0x10000 ||
|-
| MATERIAL_VAR2_SUPPORTS_HW_SKINNING || 0x20000 ||
|-
| MATERIAL_VAR2_SUPPORTS_FLASHLIGHT || 0x40000 ||
|}
   
   
=== %CompileBlockLOS (<code>toolsblocklos</code>) ===
[[image:Toolsblocklos.gif|32px]] Makes the brush block NPC line of sight only.
=== %CompileDetail ===
=Forces the brush to no longer cut visleafs, similar to [[func_detail]].
=== %CompileHint(<code>toolshint</code>)===
[[image:Toolshint.gif|32px]] Makes the face hint-cut visleafs. This implies '''NoLight''' and '''NoDraw'''.
=== %CompileInvisible (<code>toolsinvisible</code>) ===
[[image:Toolsinvisible.gif|32px]] Makes a surface behave like NoDraw, but still allow bullets to pass through it. This implies '''NoLight''' also.
=== %CompileLadder ===
[[image:Toolsladder.gif|32px]] Makes the brush usable as a [[func_ladder]].
=== %CompileNoDraw (<code>toolsnodraw</code>) ===
[[image:Toolsnodraw.gif|32px]] Makes a brush behave like <code>tools/toolsnodraw</code>.
=== %CompileNonSolid ===
Makes the brush not solid to anything.
=== %CompileNoShadows ===
Prevents shadows from being cast onto the texture.
=== %CompilePassBullets===
Makes the brush act as a "grating" type, allowing bullets through but blocking other objects. Useful for foliage or metal grates.
=== %CompileWater, CompileSlime ===
Marks the brush as a [[Water_(shader)|water]]-type material. Makes it non-solid, allows swimming inside, etc. The slime variant switches to green splash particles. If <code>%CompileKeepLight</code> is also set, the brush will retain its lighting data.
=== %NoPortal {{Portal2Series}} ===
In Portal and Portal 2, makes the texture non-portalable, unless [[Gel_(Portal_2)|Conversion Gel]] is used.
=== %NoPaint {{Portal2}} ===
In Portal 2, makes the material unable to be painted by [[Gel_(Portal_2)|Gel]].


[[Category:Material System]]
[[Category:Material System]]
[[Category:List of Shader Parameters]]
[[Category:List of Shader Parameters]]

Revision as of 10:53, 14 May 2018

Material $flags and $flags2 parameters control how the material is rendered. $flag can be changed in real-time to allow changes in rendering, but $flags2 is read-only and assists the engine or other code in using the material correctly.

The flags can also be set via the .vmt Example:

#Sets the MATERIAL_VAR_VERTEXCOLOR and MATERIAL_VAR_VERTEXALPHA flag
UnlitGeneric
{
$basetexture brick/brickwall003a
$vertexcolor 1
$vertexalpha 1
}

$flags

$flags can contain the following flags:

Flag Value Comment
MATERIAL_VAR_DEBUG 0x0001
MATERIAL_VAR_NO_DEBUG_OVERRIDE 0x0002
MATERIAL_VAR_NO_DRAW 0x0004
MATERIAL_VAR_USE_IN_FILLRATE_MODE 0x0008
MATERIAL_VAR_VERTEXCOLOR 0x0010 $vertexalpha
MATERIAL_VAR_VERTEXALPHA 0x0020 $vertexalpha
MATERIAL_VAR_SELFILLUM 0x0040
MATERIAL_VAR_ADDITIVE 0x0080
MATERIAL_VAR_ALPHATEST 0x0100
MATERIAL_VAR_MULTIPASS 0x0200
MATERIAL_VAR_ZNEARER 0x0400
MATERIAL_VAR_MODEL 0x0800
MATERIAL_VAR_FLAT 0x1000
MATERIAL_VAR_NOCULL 0x2000
MATERIAL_VAR_NOFOG 0x4000
MATERIAL_VAR_IGNOREZ 0x8000
MATERIAL_VAR_DECAL 0x10000
MATERIAL_VAR_ENVMAPSPHERE 0x20000
MATERIAL_VAR_NOALPHAMOD 0x40000
MATERIAL_VAR_ENVMAPCAMERASPACE 0x80000
MATERIAL_VAR_BASEALPHAENVMAPMASK 0x100000
MATERIAL_VAR_TRANSLUCENT 0x200000
MATERIAL_VAR_NORMALMAPALPHAENVMAPMASK 0x400000
MATERIAL_VAR_NEEDS_SOFTWARE_SKINNING 0x800000
MATERIAL_VAR_OPAQUETEXTURE 0x1000000
MATERIAL_VAR_ENVMAPMODE 0x2000000
MATERIAL_VAR_SUPPRESS_DECALS 0x4000000
MATERIAL_VAR_HALFLAMBERT 0x8000000
MATERIAL_VAR_WIREFRAME 0x10000000
MATERIAL_VAR_ALLOWALPHATOCOVERAGE 0x20000000
MATERIAL_VAR_IGNORE_ALPHA_MODULATION 0x40000000

$flags2

$flags2 can contain the following flags:

Flag Value Comment
MATERIAL_VAR2_LIGHTING_UNLIT 0x0000
MATERIAL_VAR2_LIGHTING_VERTEX_LIT 0x0001
MATERIAL_VAR2_LIGHTING_LIGHTMAP0 0x0002
MATERIAL_VAR2_LIGHTING_BUMPED_LIGHTMAP 0x0004
MATERIAL_VAR2_LIGHTING_MASK 0x0001 + 0x0002 + 0x0004
MATERIAL_VAR2_DIFFUSE_BUMPMAPPED_MODEL 0x0008
MATERIAL_VAR2_USES_ENV_CUBEMAP 0x0010
MATERIAL_VAR2_NEEDS_TANGENT_SPACES 0x0020
MATERIAL_VAR2_NEEDS_SOFTWARE_LIGHTING 0x0040
MATERIAL_VAR2_BLEND_WITH_LIGHTMAP_ALPHA 0x0080
MATERIAL_VAR2_NEEDS_BAKED_LIGHTING_SNAPSHOTS 0x0100
MATERIAL_VAR2_USE_FLASHLIGHT 0x0200
MATERIAL_VAR2_USE_FIXED_FUNCTION_BAKED_LIGHTING 0x0400
MATERIAL_VAR2_NEEDS_FIXED_FUNCTION_FLASHLIGHT 0x0800
MATERIAL_VAR2_USE_EDITOR 0x1000
MATERIAL_VAR2_NEEDS_POWER_OF_TWO_FRAME_BUFFER_TEXTURE 0x2000
MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE 0x4000
MATERIAL_VAR2_IS_SPRITECARD 0x8000
MATERIAL_VAR2_USES_VERTEXID 0x10000
MATERIAL_VAR2_SUPPORTS_HW_SKINNING 0x20000
MATERIAL_VAR2_SUPPORTS_FLASHLIGHT 0x40000