$vertexcolor and $vertexalpha

From Valve Developer Community
(Redirected from $vertexcolor)
Jump to: navigation, search

$vertexalpha and $vertexcolor are two VMT commands that make the surface derive its alpha and color values from per-vertex data provided by the engine.

Only particles and decals are known to modify their vertex data, but it should be possible to implement your own scenarios, too. Vertex alpha and color cannot be compiled into a model, however.

Note.pngNote:Using a modified StudioMDL and VRAD, it is theoretically possible to get user-defined vertex colors on static props; this is not dynamically colored, however.

For HUDs in Garry's Mod Garry's Mod , the parameter $vertexalpha is needed in order to make the alpha parameter of surface.SetDrawColor() working.

LightmappedGeneric and UnlitGeneric materials support per-vertex alpha; however, a few conditions must be met:

  • $vertexalpha must be set to 1
  • $vertexcolor must be set to 1 (except on UnlitGeneric)
  • The surface must be a displacement.
    • You can use the "paint alpha" tool to paint the alpha.

There are some additional caveats.

  • You can define a second base texture, but it will be invisible.
  • Materials with $vertexalpha 1 will render as translucent materials and thus suffer from the same sorting issues and caveats as materials with $translucent.
Icon-Bug.pngBug:$vertexalpha implies $translucent. Materials with $vertexalpha will use the alpha channel of the $basetexture for translucency, in addition to the vertices' alpha, regardless of if $translucent is enabled.
Blank image.pngTodo: Are these commands shader-agnostic?