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
No edit summary
No edit summary
 
(34 intermediate revisions by 15 users not shown)
Line 1: Line 1:
'''<code>VertexLitGeneric</code>''' is the shader most commonly used to render [[model]]s.
{{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 effects ==
== Supported Parameters ==


*<code>[[$bumpmap]]</code>
=== Basics ===
*<code>[[$detail]]</code>
{{MatParamDef|$basetexture|texture|[[$basetexture]] defines [[diffuse]] texture.}}
*<code>[[$envmap]]</code>
{{MatParamDef|$detail|texture|[[$detail|Detail]] texturing.}}
*<code>[[$flesh]]</code>
{{MatParamDef|$decaltexture|texture|Use a 2nd UV channel for high-resolution decal support.|only={{csgo}}}}
*<code>[[$halflambert]]</code>
*<code>[[$phong]]</code>
*<code>[[$translucent]]</code> and <code>[[$alpha]]</code>
*<code>[[$emissiveblend]]</code> (the 'Vortessence' effect?)
*<code>[[$compress]]</code>


=== Cloak ===
=== Adjustment ===
{{MatParamDef|$color2|RGB matrix|[[$color#Models|Color tinting]].}}
{{MatParamDef|$basetexturetransform|matrix|[[$basetexture#.24basetexturetransform|Transform]] [[$basetexture]]'s alignment, scale, rotation and position.}}
{{MatParamDef|$allowdiffusemodulation|bool|Prevents the model's material from being tinted by [[$color2]] or <code>rendercolor.</code>|since={{l4d}}}}
{{MatParamDef|$seperatedetailuvs|bool|{{todo|''Confirm use of texcoord1 for [[$detail|detail]] texture''}}|since={{src07}}}}
{{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}}}}
{{MatParamDef|$notint|bool|Prevents the model's material from being tinted by [[$color2]] or <code>rendercolor.</code>|only={{csgo}}|also={{P2CE}}}}


VertexLitGeneric natively supports the Spy cloak effect from [[Team Fortress 2]]. You will want to combine it with a sine wave [[Material Proxies|proxy]] for the full effect.
=== Transparency ===
'''VertexLitGeneric''' support a few different methods for transparency, each for different purposes
{{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}}.}}}}
{{MatParamDef|$alphatest|bool|[[$alphatest]] is a [[Cheap]] transparency using a binary opacity mask.}}
{{MatParamDef|$nocull|bool|[[$nocull]] disables backface culling optimization.}}
{{MatParamDef|$translucent|bool|[[$translucent]] is a [[Expensive|expensive]] translucency using a full [[Alpha]] mask, for very fine gradients.<br/>{{note|Add material sorting issues}}}}
{{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.}}
{{MatParamDef|$distancealpha|bool|[[$distancealpha]] is a vector-like edge filtering.|since={{src07}}}}


; <code>$cloakpassenabled <[[bool]]></code>
=== Lighting ===
: Enables cloaking effects.
{{MatParamDef|$bumpmap|texture| [[Bump_map|Normal map]].}}
; <code>$cloakfactor <[[normal]]></code>
{{MatParamDef|$lightwarptexture|texture|1 dimension Per-texel color modification via a [[$lightwarptexture|warp texture]].|since={{src06}}}}
: 1 = fully visible, 0 = fully invisible.
{{MatParamDef|$halflambert|bool|Use [[$halflambert|Half-lambertian]] shading.}}
; <code>$cloakcolortint <[[RGB]] matrix></code>
{{MatParamDef|$selfillum|bool|Determines whether the surface is [[Glowing_Textures#.24selfillum|self-illuminated]] independent of environment lighting.}}
: Colours the refraction effect. Default is white.
{{MatParamDef|$emissiveblendenabled|bool|[[Glowing_Textures#.24emissiveblend|Advanced flowing self-illumination]], used on the [[Vortigaunt|Vortigaunts]] in {{Game link|Half-Life 2: Episode Two}}.|since={{src07}}}}
; <code>$refractamount <[[float]]></code>
{{MatParamDef|$lightmap|texture|Pre-baked [[lightmap]]; subject to [[$lightmap#Limitations_and_caveats|limitations]].|only={{src13mp}}|also={{gmod}}}}
: How strong the refraction effect should be when the material is partially cloaked (default = 2).
 
=== 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}}}}
 
===Cloak===
 
<code>VertexLitGeneric</code> natively supports the Spy cloak effect from {{Game link|Team Fortress 2}}. Combine it with a sine wave [[Material Proxies|proxy]] for the full effect.
 
{{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''.}}
 
== Caveats ==
 
=== Mapbase ===
VertexLitGeneric materials in [[Mapbase]] should have the shader '''<code>SDK_VertexLitGeneric</code>'''.


== 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]]
*<code>[[Eyes]]</code>
*{{ent|EyeRefract}}, the shader for modeled eyes.
*<code>[[Teeth]]</code>
*{{ent|Teeth}}, the shader for modeled teeth.
 
[[Category:Shaders]]
[[Category:Stubs]]

Latest revision as of 11:38, 23 August 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> (only in 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 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