$phong: Difference between revisions
Jump to navigation
Jump to search
Note:All parameters in the following example must be specified in the material, otherwise Phong shading won't show up at all, except in
Insurgency.
Warning:There are some caveats regarding $normalmapalphaenvmapmask and $selfillumfresnel when using $phong!
Note:Phong shading for 
. It requires the material to be lit by the sunlight from a env_cascade_light entity to work properly and uses the dynamic shadows generated by it as a mask on top of the traditional phong masking. ((in all games since
) env_projectedtexture also affects brushes with phong enabled)
Bug:
Garry's Mod reads lighting direction for brush phong from env_sun instead; maps with multiple suns may not get accurate phong reflections on brushes.
Note:Phong shading for
Mapbase, but it is implemented differently.
Important:In all Source Engine games since
Source 2007 (until
) enabling this shader will also enable $halflambert automatically (including gbuffer's halflambert in Black Mesa), unless $phongdisablehalflambert(in all games since
) is used. This effect isn't physically accurate, so it should be disabled if possible in most cases.
Bug:Phong reflection vectors are broken on static props with vertex lighting. (tested in:
,
)
Tip:Use new specular shader in
Black Mesa as an alternative of phong on brushes.
Darkness8163 (talk | contribs) m (→Colors: fixed a typo in the word latter) |
No edit summary |
||
(25 intermediate revisions by 7 users not shown) | |||
Line 2: | Line 2: | ||
{{this is a|shader parameter|name=$phong|since=Source 2006|shader=VertexLitGeneric}} | {{this is a|shader parameter|name=$phong|since=Source 2006|shader=VertexLitGeneric}} | ||
[[File:Alyx phong closeup.jpg|thumb|200px|Phong shading provides Alyx's skin, hairband and lip highlights.]] | [[File:Alyx phong closeup.jpg|thumb|200px|Phong shading provides Alyx's skin, hairband and lip highlights.]] | ||
It is also available on the {{code|[[LightmappedGeneric]]}} and {{code|[[WorldVertexTransition]]}} shaders in all games since {{csgo|4}}{{also|{{gmod | It is also available on the {{code|[[LightmappedGeneric]]}} and {{code|[[WorldVertexTransition]]}} shaders in all games since {{csgo|4}}{{also|{{gmod}}{{mapbase}}}}. It provides {{w|diffuse reflection|icon=hide|diffuse reflections}} at low intensity and {{w|specular highlight|icon=hide|specular highlights}} at apex intensity, masked by a texture which control per-texel its intensity. For a full explanation, see [[Phong materials]]. | ||
==Syntax== | ==Syntax== | ||
Line 33: | Line 31: | ||
* '''If''' {{ent|$normalmapalphaenvmapmask}} is used, the {{ent|$bumpmap}}'s alpha channel will be used for Phong masking. Using either <code>$basemapalphaphongmask</code> or <code>$basemapluminancephongmask</code> will override it. | * '''If''' {{ent|$normalmapalphaenvmapmask}} is used, the {{ent|$bumpmap}}'s alpha channel will be used for Phong masking. Using either <code>$basemapalphaphongmask</code> or <code>$basemapluminancephongmask</code> will override it. | ||
<br> | <br> | ||
{{ | {{MatParamDef|$bumpmap|texture|Phong requires mask. The [[alpha channel]] of a [[$bumpmap|bump map]] acts as a Phong mask by default.}} | ||
{{ | {{MatParamDef|$basemapalphaphongmask|bool|Use {{ent|$basetexture}}'s [[alpha channel]] as the Phong mask instead of <code>$bumpmap</code>'s [[alpha channel]]. | ||
{{warning|Using this with {{ent|$normalmapalphaenvmapmask}} will override the mask used for {{ent|$envmap}} to be the contents of the {{ent|$basetexture}}'s alpha channel!}} | {{warning|Using this with {{ent|$normalmapalphaenvmapmask}} will override the mask used for {{ent|$envmap}} to be the contents of the {{ent|$basetexture}}'s alpha channel!}} | ||
{{warning|{{gmod|4}} Using this with {{ent|$normalmapalphaenvmapmask}} and {{ent|$envmap}} renders in {{ent|$envmap}} and '''<code>$phong</code>''' be masked by both '''<code>$basemapalphaphongmask</code>''' alpha channel and {{ent|$normalmapalphaenvmapmask}} alpha channel.}} |since={{src07}}|shaders=VertexLitGeneric}} | {{warning|{{gmod|4}} Using this with {{ent|$normalmapalphaenvmapmask}} and {{ent|$envmap}} renders in {{ent|$envmap}} and '''<code>$phong</code>''' be masked by both '''<code>$basemapalphaphongmask</code>''' alpha channel and {{ent|$normalmapalphaenvmapmask}} alpha channel.}} |since={{src07}}|shaders=VertexLitGeneric}} | ||
{{ | {{MatParamDef|$basemapluminancephongmask|bool|Mask phong intensity based on the brightness of the <code>$basetexture</code>. | ||
{{bug|Basetexture Luminance will replace the mask used for {{ent|$envmap}}, '''if''' {{ent|$normalmapalphaenvmapmask}} is used.}} | {{bug|Basetexture Luminance will replace the mask used for {{ent|$envmap}}, '''if''' {{ent|$normalmapalphaenvmapmask}} is used.}} | ||
{{bug|Doesn't work in {{gmod|4}}.}} | {{bug|Doesn't work in {{gmod|4}}.}} | ||
|not={{gmod}}|since={{l4d}}|shaders=VertexLitGeneric}} | |not={{gmod}}|since={{l4d}}|shaders=VertexLitGeneric}} | ||
{{ | {{MatParamDef|$phongexponent|and=$phongexponent2|int|A global [[Phong materials#Phong mask and exponent texture|exponent]] value. Overrides an exponent mask if present. | ||
: <code>$phongexponent2</code> is for <code>WorldVertexTransition</code>'s second material in {{csgobranch|4}}.}} | : <code>$phongexponent2</code> is for <code>WorldVertexTransition</code>'s second material in {{csgobranch|4}}.}} | ||
{{ | {{MatParamDef|$phongexponenttexture|texture|A per-texel exponent map. In an exponent map: | ||
:* '''Red channel:''' Exponent mask (size of highlight, 0-255, where a value of 0 is a large highlight, 255 small.) | :* '''Red channel:''' Exponent mask (size of highlight, 0-255, where a value of 0 is a large highlight, 255 small.) | ||
:* '''Green channel:''' Albedo tint mask (only if <code>$phongalbedotint 1</code>, 0-255, where a value of 0 is no tint, 255 full tint.) | :* '''Green channel:''' Albedo tint mask (only if <code>$phongalbedotint 1</code>, 0-255, where a value of 0 is no tint, 255 full tint.) | ||
Line 49: | Line 47: | ||
:* '''Alpha channel:''' {{ent|$rimlight}} mask (only if '''<code>$rimmask 1</code>'''.) | :* '''Alpha channel:''' {{ent|$rimlight}} mask (only if '''<code>$rimmask 1</code>'''.) | ||
:{{Note|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> do not have support for <code>$phongexponenttexture</code>. You must use <code>$phongexponent</code> instead.}}|shaders=VertexLitGeneric}} | :{{Note|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> do not have support for <code>$phongexponenttexture</code>. You must use <code>$phongexponent</code> instead.}}|shaders=VertexLitGeneric}} | ||
{{ | {{MatParamDef|$phongexponentfactor|float|Multiply the exponent from the <code>$phongexponenttexture</code> by this amount. {{tip| The default value of this parameter is <code>"0.0"</code>. However, a more reasonable default value would be <code>"149.0"</code>}}|only={{src13mp}}{{tf2}}|shaders=VertexLitGeneric}} | ||
{{ | {{MatParamDef|$invertphongmask|bool|Invert the value of the phong mask. | ||
{{bug|In {{as}}s and {{src13}}s Shadercode, using this parameter will invert the mask used for {{ent|$envmap}}, not the one used for <code>$phong</code>! }} | {{bug|In {{as}}s and {{src13}}s Shadercode, using this parameter will invert the mask used for {{ent|$envmap}}, not the one used for <code>$phong</code>! }} | ||
{{confirm| Is this the case for all branches?}} | {{confirm| Is this the case for all branches?}} | ||
|since={{src07}}|shaders=VertexLitGeneric}} | |since={{src07}}|shaders=VertexLitGeneric}} | ||
{{ | {{MatParamDef|$forcephong|bool|Force phong shading on phong-using materials even at low GPU levels when <code>mat_phong</code> is disabled.|since={{portal2}}|shaders=VertexLitGeneric}} | ||
{{ | {{MatParamDef|$diffuseexp|float|Diffuse exponent used for dynamic lights only. | ||
{{note|have this with {{ent|$halflambert}} greatly decrease it effect.}}|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} | {{note|have this with {{ent|$halflambert}} greatly decrease it effect.}}|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} | ||
{{ | {{MatParamDef|$shinyblood|int|Derive phong mask from areas that are more red than others. Only when variation is disabled.|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} | ||
{{ | {{MatParamDef|$shinybloodexponent|int|Exponent for the above.|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} | ||
=== Brightness === | === Brightness === | ||
{{ | {{MatParamDef|$phongboost|float|Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.{{tip|A phong boost of zero is visually identical to no phong, and can be used to work around certain shader parameter combinations that require phong (ex [[$lightwarptexture]]).}}|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase|only}})}} | ||
{{ | {{MatParamDef|$phongfresnelranges|matrix|See [[Phong materials#Phong Fresnel ranges|Phong Fresnel ranges]]. Default is <code>"[0 0.5 1]"</code>. | ||
:{{note|<code>$envmap</code> is also affected by these fresnel ranges if both it and Phong are enabled in a material.}} | :{{note|<code>$envmap</code> is also affected by these fresnel ranges if both it and Phong are enabled in a material.}} | ||
:{{note| drives the x component of a phongwarptexture if specified.}}|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase|only}})}} | :{{note| drives the x component of a phongwarptexture if specified.}}|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase|only}})}} | ||
{{ | {{MatParamDef|$phongdisablehalflambert|bool|Disables forced [[$halflambert|half-lambertian]] shading on Phong materials. {{note|This parameter is effectively forced on in {{csgobranch|4}} due to <code>$halflambert</code> being disabled.}}<!-- | ||
-->{{tip|In games without this command, the effect can be simulated by using the {{cmd|$lightwarptexture}} found [[:File:Phongdisablehalflambert_warp.png|here]].}}|since={{as}}|also={{gmod}},{{Mapbase}}|shaders=VertexLitGeneric}} | |||
=== Colors === | === Colors === | ||
{{ | {{MatParamDef|$phongalbedotint|bool|Tints the phong reflection by the color of the <code>$basetexture</code>. The amount of tint is defined by the green channel of <code>$phongexponenttexture</code>. A <code>$phongexponenttexture</code> must be specified in order for <code>$phongalbedotint</code> to work. | ||
: {{Warning|<code>$phongalbedotint</code> cannot be used with <code>$phongtint</code>. The latter will disable the effect.}} | : {{Warning|<code>$phongalbedotint</code> cannot be used with <code>$phongtint</code>. The latter will disable the effect.}} | ||
: {{Note|<code>$phongalbedotint</code> works by multiplying the <code>$basetexture</code> over the reflection, without darkening the albedo. The reflection will get dimmer as a result, so account for this in the phong mask or with <code>$phongboost</code>.}} | : {{Note|<code>$phongalbedotint</code> works by multiplying the <code>$basetexture</code> over the reflection, without darkening the albedo. The reflection will get dimmer as a result, so account for this in the phong mask or with <code>$phongboost</code>.}} | ||
: {{Note|<code>$phongalbedotint</code> will tint highlights by the original color of the <code>$basetexture</code> even when the material is tinted by <code>$color2</code> or <code>rendercolor.</code>}}|since={{src07}}|shaders=VertexLitGeneric}} | : {{Note|<code>$phongalbedotint</code> will tint highlights by the original color of the <code>$basetexture</code> even when the material is tinted by <code>$color2</code> or <code>rendercolor.</code>}}|since={{src07}}|shaders=VertexLitGeneric}} | ||
[[File:Albedotint example.jpg|thumb|200px|An example model showing how AlbedoTint appears on a model.]] | [[File:Albedotint example.jpg|thumb|200px|An example model showing how AlbedoTint appears on a model.]] | ||
{{ | {{MatParamDef|$phongalbedoboost|float|Phong albedo overbrightening factor. Ranges 0-255. | ||
: {{note| This will multiply the tint that is being applied to phong from $phongalbedotint.}} | : {{note| This will multiply the tint that is being applied to phong from $phongalbedotint.}} | ||
: {{bug| This does not work when using [[$detail]]. }}|since={{csgo}}|also={{gmod}}|shaders=VertexLitGeneric}} | : {{bug| This does not work when using [[$detail]]. }}|since={{csgo}}|also={{gmod}}|shaders=VertexLitGeneric}} | ||
[[File:Phongwarp example.png|thumb|200px|The Hunter without and with its <code>$phongwarptexture</code>, showing how it affects the Phong reflection.]] | [[File:Phongwarp example.png|thumb|200px|The Hunter without and with its <code>$phongwarptexture</code>, showing how it affects the Phong reflection.]] | ||
{{ | {{MatParamDef|$phongtint|RGB matrix|Color tint of the phong reflection. | ||
: {{Warning|This will override <code>$phongalbedotint</code> if both are used.}} | : {{Warning|This will override <code>$phongalbedotint</code> if both are used.}} | ||
: {{note| Also tints {{ent|$rimlight}}}}|since={{src07}}|shaders=VertexLitGeneric}} | : {{note| Also tints {{ent|$rimlight}}}}|since={{src07}}|shaders=VertexLitGeneric}} | ||
[[File:Phongwarp_coordinate_guide.png|thumb|200px|Breakdown of the $phongwarptexture: computed coordinates, texture and result]] | [[File:Phongwarp_coordinate_guide.png|thumb|200px|Breakdown of the $phongwarptexture: computed coordinates, texture and result]] | ||
{{ | {{MatParamDef|$phongwarptexture|texture|Used to create an iridescence effect, as seen on Episode Two's [[npc_hunter|Hunters]]. | ||
: The highlight is multiplied with a texture. The coordinates of the sampled pixel are as follows: | : The highlight is multiplied with a texture. The coordinates of the sampled pixel are as follows: | ||
:x: 1 - (distance to the center of the highlight) | :x: 1 - (distance to the center of the highlight) | ||
Line 91: | Line 90: | ||
===Brush Shader Parameters === | ===Brush Shader Parameters === | ||
:{{csgobranch|only}}{{also|{{gmod}}}} | :{{csgobranch|only}}{{also|{{gmod}}}} | ||
{{ | {{MatParamDef|$phongmaskcontrastbrightness|and=$phongmaskcontrastbrightness2|vector2|The first value controls the contrast level between light and dark areas in the mask, and the second value controls the overall brightness. | ||
: <code>$phongmaskcontrastbrightness2</code> is for <code>WorldVertexTransition</code>'s second material. | : <code>$phongmaskcontrastbrightness2</code> is for <code>WorldVertexTransition</code>'s second material. | ||
: {{todo|Find out the range of both values.}}|shaders=LightmappedGeneric, WorldVertexTransition}} | : {{todo|Find out the range of both values.}}|shaders=LightmappedGeneric, WorldVertexTransition}} | ||
{{ | {{MatParamDef|$phongamount|and=$phongamount2|vector4|The first 3 values control the color tint, and the fourth value controls the brightness. The fourth value can go beyond 1, but affects the brightness of the whole texture, not just the highlight. | ||
: <code>$phongamount2</code> is for <code>WorldVertexTransition</code>'s second material.|shaders=LightmappedGeneric, WorldVertexTransition}} | : <code>$phongamount2</code> is for <code>WorldVertexTransition</code>'s second material.|shaders=LightmappedGeneric, WorldVertexTransition}} | ||
{{ | {{MatParamDef|$phongbasetint|and=$phongbasetint2|float|Allows the <code>$basetexture</code> and/or <code>$basetexture2</code> to tint the color of the Phong highlight.|shaders=LightmappedGeneric, WorldVertexTransition}} | ||
== Console Commands == | == Console Commands == | ||
{{ | {{varcom|start}} | ||
{{varcom|mat_phong|1|bool|Disable or enable phong shading. {{bug|Doesn't work in {{csgo|4}} branch.|tested={{p2ce}}}}}} | |||
{{varcom|end}} | |||
== Notes == | |||
{{Note|Phong shading for <code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> is only available in {{csgobranch}}{{strata}}. It requires the material to be lit by the sunlight from a {{ent|env_cascade_light}} entity to work properly and uses the dynamic shadows generated by it as a mask on top of the traditional phong masking. ({{Strata|since}} {{ent|env_projectedtexture}} also affects brushes with phong enabled) | |||
{{bug|hidetested=1|{{gmod|4}} reads lighting direction for brush phong from {{ent|env_sun}} instead; maps with multiple suns may not get accurate phong reflections on brushes.}}}} | |||
{{Note|Phong shading for <code>LightmappedGeneric</code> is also available in {{mapbase|4}}, but it is implemented differently.}} | |||
{{important|In all [[Source Engine]] games since {{src07|4}} (until {{csgo}}) enabling this shader will also enable [[$halflambert]] automatically (including [[$halflambert_gbuffer_off|gbuffer's halflambert]] in {{bms|1}}), unless {{cmd|$phongdisablehalflambert}}{{since|{{as}}}} is used. This effect isn't physically accurate, so it should be disabled if possible in most cases.}} | |||
{{bug|tested={{bms}},{{csgo}}|Phong reflection vectors are broken on [[prop_static|static props]] with vertex lighting.}} | |||
{{tip|Use [[$specmap_mode|new specular]] shader in {{bms|4}} as an alternative of phong on brushes.}} | |||
== See also == | == See also == | ||
Line 108: | Line 117: | ||
== External links == | == External links == | ||
* {{YouTube|tLCUE25KEmM|page=watch|A comprehensive YouTube video on how phong materials work in Source}} | |||
* [https://tf2maps.net/threads/phong-on-brushes-the-hacky-way.26765 $Phong on brushes*: The Hacky Way] - A TF2maps.net guide on how to fake $Phong on brushes for games prior to CS:GO. Can also be used to fake phong on [[prop_static|static props]] which are lit per-vertex, without falling back to lower-quality point lighting on the main prop | * [https://tf2maps.net/threads/phong-on-brushes-the-hacky-way.26765 $Phong on brushes*: The Hacky Way] - A TF2maps.net guide on how to fake $Phong on brushes for games prior to CS:GO. Can also be used to fake phong on [[prop_static|static props]] which are lit per-vertex, without falling back to lower-quality point lighting on the main prop | ||
*[https://share.substance3d.com/libraries/6595 SubstancePainter Source Engine Complex Phong Shader] | *[https://share.substance3d.com/libraries/6595 SubstancePainter Source Engine Complex Phong Shader] | ||
[[Category:Shader parameters|p]][[Category:VMT Lighting]] | [[Category:Shader parameters|p]][[Category:VMT Lighting]] | ||
[[Category:Material System]] | [[Category:Material System]] |
Latest revision as of 11:40, 23 August 2025
$phong
is a material shader parameter for the VertexLitGeneric shader available in all Source games since
Source 2006.
It is also available on the LightmappedGeneric and WorldVertexTransition shaders in all games since Counter-Strike: Global Offensive(also in
). It provides
diffuse reflections at low intensity and
specular highlights at apex intensity, masked by a texture which control per-texel its intensity. For a full explanation, see Phong materials.
Syntax
$phong <bool>


- Todo: Other games that don't require all phong parameters present (likely Portal 2 and up)
VertexLitGeneric
{
$phong 1
$bumpmap [texture]
$phongexponent 5 // either/or
$phongexponenttexture [texture] // either/or
$phongboost 1.0
$phongfresnelranges "[0 0.5 1]"
}
Parameters
Masking

- Using $selfillumfresnel without $normalmapalphaenvmapmask will mask the $envmap using the $basetexture's alpha channel.
- Using $selfillumfresnel with $normalmapalphaenvmapmask will multiply the $envmap by
0.0f
. Effectively disabling the effect! - When not using $selfillumfresnel. The mask used for $envmap will be the $basetexture's alpha channel unless $normalmapalphaenvmapmask is also used.
- If $normalmapalphaenvmapmask is used, the $bumpmap's alpha channel will be used for Phong masking. Using either
$basemapalphaphongmask
or$basemapluminancephongmask
will override it.
Phong requires mask. The alpha channel of a bump map acts as a Phong mask by default.
Shader(s): VertexLitGeneric
Use $basetexture's alpha channel as the Phong mask instead of
Warning:Using this with $normalmapalphaenvmapmask will override the mask used for $envmap to be the contents of the $basetexture's alpha channel!
Warning:
Garry's Mod Using this with $normalmapalphaenvmapmask and $envmap renders in $envmap and
$bumpmap
's alpha channel.



$phong
be masked by both $basemapalphaphongmask
alpha channel and $normalmapalphaenvmapmask alpha channel.
Shader(s): VertexLitGeneric
Mask phong intensity based on the brightness of the
Bug:Basetexture Luminance will replace the mask used for $envmap, if $normalmapalphaenvmapmask is used. [todo tested in ?]
Bug:Doesn't work in
Garry's Mod. [todo tested in ?]
$basetexture
.



A global exponent value. Overrides an exponent mask if present.
$phongexponent2
is forWorldVertexTransition
's second material inCS:GO engine branch.
Shader(s): VertexLitGeneric
A per-texel exponent map. In an exponent map:
- Red channel: Exponent mask (size of highlight, 0-255, where a value of 0 is a large highlight, 255 small.)
- Green channel: Albedo tint mask (only if
$phongalbedotint 1
, 0-255, where a value of 0 is no tint, 255 full tint.) - Blue channel: Nothing.
- Alpha channel: $rimlight mask (only if
$rimmask 1
.)
Note:
LightmappedGeneric
andWorldVertexTransition
do not have support for$phongexponenttexture
. You must use$phongexponent
instead.
Shader(s): VertexLitGeneric
Multiply the exponent from the
Tip: The default value of this parameter is
$phongexponenttexture
by this amount. 
"0.0"
. However, a more reasonable default value would be "149.0"
Shader(s): VertexLitGeneric
Shader(s): VertexLitGeneric
Force phong shading on phong-using materials even at low GPU levels when
mat_phong
is disabled.
Shader(s): VertexLitGeneric, Infected
Diffuse exponent used for dynamic lights only.
Note:have this with $halflambert greatly decrease it effect.

Shader(s): VertexLitGeneric, Infected
Derive phong mask from areas that are more red than others. Only when variation is disabled.
Shader(s): VertexLitGeneric, Infected
Exponent for the above.
Brightness
Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.
Tip:A phong boost of zero is visually identical to no phong, and can be used to work around certain shader parameter combinations that require phong (ex $lightwarptexture).

See Phong Fresnel ranges. Default is
"[0 0.5 1]"
.
Note:
$envmap
is also affected by these fresnel ranges if both it and Phong are enabled in a material.Note: drives the x component of a phongwarptexture if specified.
Shader(s): VertexLitGeneric
Disables forced half-lambertian shading on Phong materials.
Note:This parameter is effectively forced on in
CS:GO engine branch due to
Tip:In games without this command, the effect can be simulated by using the $lightwarptexture found here.


$halflambert
being disabled.
Colors
Shader(s): VertexLitGeneric
Tints the phong reflection by the color of the
$basetexture
. The amount of tint is defined by the green channel of $phongexponenttexture
. A $phongexponenttexture
must be specified in order for $phongalbedotint
to work.
Warning:
$phongalbedotint
cannot be used with$phongtint
. The latter will disable the effect.Note:
$phongalbedotint
works by multiplying the$basetexture
over the reflection, without darkening the albedo. The reflection will get dimmer as a result, so account for this in the phong mask or with$phongboost
.Note:
$phongalbedotint
will tint highlights by the original color of the$basetexture
even when the material is tinted by$color2
orrendercolor.
Shader(s): VertexLitGeneric
Shader(s): VertexLitGeneric
Color tint of the phong reflection.
Warning:This will override
$phongalbedotint
if both are used.Note: Also tints $rimlight
Shader(s): VertexLitGeneric
Used to create an iridescence effect, as seen on Episode Two's Hunters.
- The highlight is multiplied with a texture. The coordinates of the sampled pixel are as follows:
- x: 1 - (distance to the center of the highlight)
- y: 1 - (fresnel component as computed by Phong Fresnel ranges)
Note:Disables the initial phongfresnelranges masking
Bug:Does not work in
Left 4 Dead 2. [todo tested in ?]

Brush phong in
Counter-Strike: Global Offensive using tile/hr_t/inferno/tile_a. Note the complete absence of the reflection in the shaded area.

Brush Shader Parameters
Shader(s): LightmappedGeneric, WorldVertexTransition
The first value controls the contrast level between light and dark areas in the mask, and the second value controls the overall brightness.
$phongmaskcontrastbrightness2
is forWorldVertexTransition
's second material.- Todo: Find out the range of both values.
Shader(s): LightmappedGeneric, WorldVertexTransition
The first 3 values control the color tint, and the fourth value controls the brightness. The fourth value can go beyond 1, but affects the brightness of the whole texture, not just the highlight.
$phongamount2
is forWorldVertexTransition
's second material.
Shader(s): LightmappedGeneric, WorldVertexTransition
Allows the
$basetexture
and/or $basetexture2
to tint the color of the Phong highlight.Console Commands
Cvar/Command | Parameters or default value | Descriptor | Effect |
---|---|---|---|
mat_phong | 1 | bool | Disable or enable phong shading. ![]() ![]() ![]() |
Notes

LightmappedGeneric
and WorldVertexTransition
is only available in 





LightmappedGeneric
is also available in 









See also
- Phong materials
- $envmap (environment map)
- $lightwarptexture
- $rimlight
External links
A comprehensive YouTube video on how phong materials work in Source
- $Phong on brushes*: The Hacky Way - A TF2maps.net guide on how to fake $Phong on brushes for games prior to CS:GO. Can also be used to fake phong on static props which are lit per-vertex, without falling back to lower-quality point lighting on the main prop
- SubstancePainter Source Engine Complex Phong Shader