$vertexcolor and $vertexalpha: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(21 intermediate revisions by 9 users not shown)
Line 1: Line 1:
'''<code>$vertexalpha</code>''' and '''<code>$vertexcolor</code>''' are two [[VMT]] commands that make the surface derive its [[alpha]] and [[RGB|color]] values from per-[[vertex]] data provided by the engine.
{{DISPLAYTITLE:{{mono|$vertexcolor}} and {{mono|$vertexalpha}}}}
'''<code>$vertexalpha</code>''' and '''<code>$vertexcolor</code>''' are two [[Material|VMT]] commands that make the surface derive its [[alpha]] and [[RGB|color]] values from per-[[vertex]] data provided by the engine.


Only [[particle]]s 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.
Only [[particle]]s 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.
[[LightmappedGeneric]] materials support $vertexalpha, and can be painted on [[Displacements]] using the standard vertex alpha paint tool. This effect is incompatible with $translucent.
{{note|Using a modified StudioMDL and VRAD, it is possible to get user-defined vertex colors on [[Prop static|static props]].}}


Both commands are currently unfunctional in [[Counter-Strike: Global Offensive]]. Using either of the commands will result in the material to turn completely black in-game. Examples are detail props and particles who extensivly used these commands in older versions of the Source Engine, which now cannot use these anymore, resulting in the dissapearance of these entities.


For HUDs in ''Garry's Mod'', the parameter '''<code>$vertexalpha</code>''' is needed in order to make the alpha parameter of [http://wiki.garrysmod.com/page/surface/SetDrawColor <code>surface.SetDrawColor()</code>] working.
For HUDs in {{game link|Garry's Mod}}, the parameter '''<code>$vertexalpha</code>''' is needed in order to make the alpha parameter of {{code|[https://wiki.facepunch.com/gmod/surface.SetDrawColor surface.SetDrawColor()]}} working.
 
 
 
<code>[[LightmappedGeneric]]</code> and <code>[[UnlitGeneric]]</code> materials support per-vertex alpha; however, a few conditions must be met:
* <code>$vertexalpha</code> must be set to 1
* <code>$vertexcolor</code> must be set to 1 (except on <code>UnlitGeneric</code>)
* 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 <code>$vertexalpha 1</code> will render as translucent materials and thus suffer from the same sorting issues and caveats as materials with [[$translucent]].
 
{{bug|hidetested=1|{{mono|$vertexalpha}} implies {{mono|$translucent}}. Materials with {{mono|$vertexalpha}} will use the alpha channel of the {{mono|$basetexture}} for translucency, in addition to the vertices' alpha, regardless of if {{mono|$translucent}} is enabled.}}


{{todo|Are these commands shader-agnostic?}}
{{todo|Are these commands shader-agnostic?}}


[[Category:List of Shader Parameters|V]]
[[Category:Shader parameters|v]]

Latest revision as of 07:15, 20 May 2025

$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 possible to get user-defined vertex colors on static props.


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.
Todo: Are these commands shader-agnostic?