$vertexalpha

From Valve Developer Community
Revision as of 16:48, 19 September 2019 by SlimekPL (talk | contribs) (It works in CS:GO, and it works with $translucent. Stop spreading nonsense.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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.


For HUDs in 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 <bool>
Must be set to 1
$vertexcolor <bool>
Must be set to 1 (This is not necessary on UnlitGeneric)
The surface must be a displacement.
You can use the "paint alpha" tool to paint the alpha.

There are some caveats.

You can define a second base texture, but it will be invisible.
Material renders as a translucent materials, and as such, suffers from the same sorting issues and caveats as materials with $translucent


To do: Are these commands shader-agnostic?