This article's documentation is for anything that uses the Source engine. Click here for more information.

VertexLitGeneric: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Changed to use Shader, MatParam, and ent templates where applicable, added game add information, added misc CSGO parameters)
No edit summary
 
(33 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{Shader|VertexLitGeneric}} It is the shader most commonly used to render [[models]], and supports a variety of effects.
{{LanguageBar}}
 
{{this is a|vertex shader|name=VertexLitGeneric}} It is the shader most commonly used to render [[models|models]], and supports a variety of effects. Do not use this on world geometry, else you may encounter lighting bugs.


== Supported Parameters ==
== Supported Parameters ==


;{{ent|$bumpmap}}
=== Basics ===
: Bumpmapping.
{{MatParamDef|$basetexture|texture|[[$basetexture]] defines [[diffuse]] texture.}}
;<code>[[$color#Models|$color2]]</code>
{{MatParamDef|$detail|texture|[[$detail|Detail]] texturing.}}
: Color tinting.
{{MatParamDef|$decaltexture|texture|Use a 2nd UV channel for high-resolution decal support.|only={{csgo}}}}
;{{ent|$detail}}
 
: Detail texturing.
=== Adjustment ===
;{{ent|$envmap}}
{{MatParamDef|$color2|RGB matrix|[[$color#Models|Color tinting]].}}
: Specular reflections.
{{MatParamDef|$basetexturetransform|matrix|[[$basetexture#.24basetexturetransform|Transform]] [[$basetexture]]'s alignment, scale, rotation and position.}}
;{{ent|$emissiveblend}} {{EP2 add}}
{{MatParamDef|$allowdiffusemodulation|bool|Prevents the model's material from being tinted by [[$color2]] or <code>rendercolor.</code>|since={{l4d}}}}
: Advanced flowing self-illumination, used on the Vortigaunts in {{Game link|Half-Life 2: Episode Two}}
{{MatParamDef|$seperatedetailuvs|bool|{{todo|''Confirm use of texcoord1 for [[$detail|detail]] texture''}}|since={{src07}}}}
;{{ent|$flesh}} {{EP2 add}}
{{MatParamDef|$desaturatewithbasealpha|float|Use the base alpha to desaturate the base texture. Set to non-zero to enable, value gets multiplied into the alpha channel before desaturating.|since={{as}}}}
: The flesh effect used for Alyx in Half-Life 2: Episode Two.
{{MatParamDef|$notint|bool|Prevents the model's material from being tinted by [[$color2]] or <code>rendercolor.</code>|only={{csgo}}|also={{P2CE}}}}
;{{ent|$halflambert}}
 
: Half-lambertian shading.
=== Transparency ===
;{{ent|$lightwarptexture}} {{EP1 add}}
'''VertexLitGeneric''' support a few different methods for transparency, each for different purposes
: Per-texel color modification via a warp texture.
{{MatParamDef|$alpha|bool|[[$alpha]] [[Cheap|Cheaply]] scales the opacity of an entire material.{{confirm|Does this work in any engine branch? It does not in {{src13mp}}.}}}}
;{{ent|$phong}} {{EP1 add}}
{{MatParamDef|$alphatest|bool|[[$alphatest]] is a [[Cheap]] transparency using a binary opacity mask.}}
: Diffuse reflections.
{{MatParamDef|$nocull|bool|[[$nocull]] disables backface culling optimization.}}
;{{ent|$rimlight}} {{EP2 add}}
{{MatParamDef|$translucent|bool|[[$translucent]] is a [[Expensive|expensive]] translucency using a full [[Alpha]] mask, for very fine gradients.<br/>{{note|Add material sorting issues}}}}
: Constant rimlight based on phong and the ambient lighting.
{{MatParamDef|$additive|bool|[[$additive]] alike [[$translucent]] perform full [[Alpha]] mask, however it add colors instead of performing a multiplication. This renders in a always brighter material.}}
;{{ent|$selfillum}}
{{MatParamDef|$distancealpha|bool|[[$distancealpha]] is a vector-like edge filtering.|since={{src07}}}}
: Self-illumination.
 
;{{ent|$translucent}}
=== Lighting ===
;{{ent|$alpha}}
{{MatParamDef|$bumpmap|texture| [[Bump_map|Normal map]].}}
: Expensive and cheap transparency.
{{MatParamDef|$lightwarptexture|texture|1 dimension Per-texel color modification via a [[$lightwarptexture|warp texture]].|since={{src06}}}}
;<code>[[Wrinkle_maps#Materials_and_textures|$compress]]</code> {{EP2 add}}
{{MatParamDef|$halflambert|bool|Use [[$halflambert|Half-lambertian]] shading.}}
;<code>[[Wrinkle_maps#Materials_and_textures|$stretch]]</code> {{EP2 add}}
{{MatParamDef|$selfillum|bool|Determines whether the surface is [[Glowing_Textures#.24selfillum|self-illuminated]] independent of environment lighting.}}
: Wrinklemaps for character faces.
{{MatParamDef|$emissiveblendenabled|bool|[[Glowing_Textures#.24emissiveblend|Advanced flowing self-illumination]], used on the [[Vortigaunt|Vortigaunts]] in {{hl2ep2|1}}.|since={{src07}}}}
;{{ent|$treeSway}} {{L4D add}}
{{MatParamDef|$lightmap|texture|Pre-baked [[lightmap]]; subject to [[$lightmap#Limitations_and_caveats|limitations]].|since={{src13mp}}|also={{gmod}}}}
: Vertex manipulation to give the effect of trees swaying in the wind.
 
=== Reflection ===
{{MatParamDef|$envmap|texture|[[$envmap|Specular reflections]].}}
{{MatParamDef|$phong|bool|[[$phong|Diffuse reflections]].|since={{src06}}}}
{{MatParamDef|$rimlight|bool|Constant [[$rimlight|rimlight]] based on [[phong]] and the ambient lighting.|since={{src07}}}}
 
=== Effect ===
{{MatParamDef|$compress|texture|[[Wrinkle_maps#Materials_and_textures|Wrinklemaps]] for character faces.|since={{src07}}}}
{{MatParamDef|$stretch|texture|[[Wrinkle_maps#Materials_and_textures|Wrinklemaps]] for character faces.|since={{src07}}}}
{{MatParamDef|$flesh|bool|The [[$flesh|flesh]] effect used for Alyx in Half-Life 2: Episode Two.|since={{src07}}}}
{{MatParamDef|$treeSway|bool|Vertex manipulation to give the effect of [[$treeSway|trees swaying]] in the wind.|since={{l4d}}|also={{tf2}}{{mapbase}}{{gmod}}{{bms}}}}
 
=== Technical Workarounds ===
{{MatParamDef|$flashlightnolambert|bool|Tell [[env_projectedtexture|projected textures]] such as the flashlight to ignore the surface normal of the model. Useful for models with {{ent|$nocull}} such as foilage. Otherwise, lighting the face with a flashlight from behind will not affect it. ''Default 0''.|since={{src07}}}}
{{MatParamDef|$lowqualityflashlightshadows|bool|Force low quality flashlight/projected texture shadows for faster performance.|since={{portal2}}}}
{{MatParamDef|$allowfencerenderstatehack|bool|Fence render hack for cascade shadow maps, allows shadow maps to work properly with fences.|since={{csgo}}}}
{{MatParamDef|$disablecsmlookup|bool|Disable cascade shadow map lookup/filtering, useful on dense foilage.|since={{csgo}}}}
{{MatParamDef|$noshadowpass|bool|Allows turning off the shadow pass of this material.|only={{lw}}}}
{{MatParamDef|$nodeferredlight|bool|No deferred light input.|only={{lw}}}}
{{MatParamDef|$modelglobalnormal|bool|Use global light direction as normal for all model vertices.|only={{lw}}}}


===Misc Parameters===
===Cloak===


{{MatParam|$desaturatewithbasealpha|float|Use the base alpha to desaturate the base texture. Set to non-zero to enable, value gets multiplied into the alpha channel before desaturating.|since=AS}}
<code>VertexLitGeneric</code> natively supports the Spy cloak effect from {{tf2|1}}. Combine it with a sine wave [[Material Proxies|proxy]] for the full effect.
{{MatParam|$flashlightnolambert|bool|{{todo|''Flashlight pass sets N.L{{=}}1.0''}}}}
{{MatParam|$seperatedetailuvs|bool|{{todo|''Use texcoord1 for detail texture''}}}}
{{MatParam|$allowfencerenderstatehack|bool|Fence render hack for cascade shadow maps, allows shadow maps to work properly with fences.|since=CSGO}}
{{MatParam|$disablecsmlookup|bool|Disable cascade shadow map lookup/filtering, useful on dense foilage.|since=CSGO}}


=== Cloak ===
{{MatParamDef|$cloakpassenabled|bool|Enables cloaking effects. {{warning|Enabling this on static props causes a heavy performance penalty, even if the cloak effect itself isn't being used!}}}}
{{MatParamDef|$cloakfactor|normal|0.00 {{=}} fully visible,<br/>
1.00 {{=}} fully invisible.}}
{{MatParamDef|$cloakcolortint|RGB matrix|Colors the refraction effect. ''Default " [ 1 1 1 ] "''.}}
{{MatParamDef|$refractamount|float|How strong the refraction effect should be when the material is partially cloaked. ''Default 2''.}}


<code>VertexLitGeneric</code> natively supports the Spy cloak effect from {{Game link|Team Fortress 2}}. You will want to combine it with a sine wave [[Material Proxies|proxy]] for the full effect.
== Caveats ==


{{MatParam|$cloakpassenabled|bool|Enables cloaking effects.}}
=== Mapbase ===
{{MatParam|$cloakfactor|normal|0 {{=}} fully visible, 1 {{=}} fully invisible.}}
VertexLitGeneric materials in [[Mapbase]] should have the shader '''<code>SDK_VertexLitGeneric</code>'''.
{{MatParam|$cloakcolortint|RGB matrix|Colors the refraction effect. Default is white.}}
{{MatParam|$refractamount|float|How strong the refraction effect should be when the material is partially cloaked. Default 2.}}


=== See also ===
== See also ==
* [[Materials_for_models#Compiling_your.VMT_:_Valve_Material_Type|Materials for models]]
* [[Materials_for_models#Compiling_your.VMT_:_Valve_Material_Type|Materials for models]]
*{{ent|EyeRefract}}, the shader for modeled eyes.
*{{ent|EyeRefract}}, the shader for modeled eyes.
*{{ent|Teeth}}, the shader for modeled teeth.
*{{ent|Teeth}}, the shader for modeled teeth.

Latest revision as of 11:17, 23 September 2025

English (en)Français (fr)中文 (zh)Translate (Translate)

VertexLitGeneric is a Vertex shader available in all Source Source games. It is the shader most commonly used to render models, and supports a variety of effects. Do not use this on world geometry, else you may encounter lighting bugs.

Supported Parameters

Basics

Detail texturing.
$decaltexture <texture> (only in Counter-Strike: Global Offensive)
Use a 2nd UV channel for high-resolution decal support.

Adjustment

Transform $basetexture's alignment, scale, rotation and position.
Prevents the model's material from being tinted by $color2 or rendercolor.
$seperatedetailuvs <boolean> (in all games since Source 2007)
Todo: Confirm use of texcoord1 for detail texture
$desaturatewithbasealpha <float> (in all games since Alien Swarm)
Use the base alpha to desaturate the base texture. Set to non-zero to enable, value gets multiplied into the alpha channel before desaturating.
$notint <boolean> (only in Counter-Strike: Global Offensive) (also in Portal 2: Community Edition)
Prevents the model's material from being tinted by $color2 or rendercolor.

Transparency

VertexLitGeneric support a few different methods for transparency, each for different purposes

$alpha Cheaply scales the opacity of an entire material.
Confirm:Does this work in any engine branch? It does not in Source 2013 Multiplayer.
$alphatest is a Cheap transparency using a binary opacity mask.
$nocull disables backface culling optimization.
$translucent is a expensive translucency using a full Alpha mask, for very fine gradients.
Note.pngNote:Add material sorting issues
$additive alike $translucent perform full Alpha mask, however it add colors instead of performing a multiplication. This renders in a always brighter material.
$distancealpha <boolean> (in all games since Source 2007)
$distancealpha is a vector-like edge filtering.

Lighting

$lightwarptexture <texture> (in all games since Source 2006)
1 dimension Per-texel color modification via a warp texture.
Determines whether the surface is self-illuminated independent of environment lighting.
$lightmap <texture> (in all games since Source 2013 Multiplayer) (also in Garry's Mod)
Pre-baked lightmap; subject to limitations.

Reflection

$phong <boolean> (in all games since Source 2006)
$rimlight <boolean> (in all games since Source 2007)
Constant rimlight based on phong and the ambient lighting.

Effect

$compress <texture> (in all games since Source 2007)
Wrinklemaps for character faces.
$stretch <texture> (in all games since Source 2007)
Wrinklemaps for character faces.
$flesh <boolean> (in all games since Source 2007)
The flesh effect used for Alyx in Half-Life 2: Episode Two.
$treeSway <boolean> (in all games since Left 4 Dead) (also in Team Fortress 2MapbaseGarry's ModBlack Mesa)
Vertex manipulation to give the effect of trees swaying in the wind.

Technical Workarounds

$flashlightnolambert <boolean> (in all games since Source 2007)
Tell projected textures such as the flashlight to ignore the surface normal of the model. Useful for models with $nocull such as foilage. Otherwise, lighting the face with a flashlight from behind will not affect it. Default 0.
Force low quality flashlight/projected texture shadows for faster performance.
Fence render hack for cascade shadow maps, allows shadow maps to work properly with fences.
$disablecsmlookup <boolean> (in all games since Counter-Strike: Global Offensive)
Disable cascade shadow map lookup/filtering, useful on dense foilage.
$noshadowpass <boolean> (only in Lambda Wars)
Allows turning off the shadow pass of this material.
$nodeferredlight <boolean> (only in Lambda Wars)
No deferred light input.
$modelglobalnormal <boolean> (only in Lambda Wars)
Use global light direction as normal for all model vertices.

Cloak

VertexLitGeneric natively supports the Spy cloak effect from Team Fortress 2. Combine it with a sine wave proxy for the full effect.

Enables cloaking effects.
Warning.pngWarning:Enabling this on static props causes a heavy performance penalty, even if the cloak effect itself isn't being used!
0.00 = fully visible,
1.00 = fully invisible.
Colors the refraction effect. Default " [ 1 1 1 ] ".
How strong the refraction effect should be when the material is partially cloaked. Default 2.

Caveats

Mapbase

VertexLitGeneric materials in Mapbase should have the shader SDK_VertexLitGeneric.

See also