From Valve Developer Community
Revision as of 20:57, 24 August 2019 by Deprecated (talk | contribs) (Combined some "2" parameters with their counterpart parameters, changed brush shader parameters to CSGO only as they aren't in any other games)

Jump to: navigation, search
Phong shading provides Alyx's skin, hairband and lip highlights.

$phong is a material shader parameter available in all Source games since <Source><Source> Source 2006 for VertexLitGeneric, LightmappedGeneric, WorldVertexTransition. It provides diffuse reflections, masked by a texture to control its intensity per-texel. For a full explanation, see Phong materials.

Note:Phong shading for LightmappedGeneric and WorldVertexTransition is only available in <Counter-Strike: Global Offensive>. It requires the material to be lit by 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.


$phong <bool>
Note:All parameters in the following example must be specified in the material, otherwise the phong shader won't show up at all, except in <Insurgency>.
To do: Other games that don't require all phong parameters present (likely Portal 2 and up)
	$phong 1

	$bumpmap				[texture]
	$phongexponent			5			// either/or
	$phongexponenttexture	[texture]	// either/or
	$phongboost				1.0
	$phongfresnelranges		"[0 0.5 1]"



$bumpmap <texture>
There must be a Phong mask. The alpha channel of a bump map acts as a Phong mask by default.
$basemapalphaphongmask <boolean>
Use $basetexture's alpha channel as the Phong mask instead of $bumpmap's. The phong will not be influenced by the bumpmap, however.
$basemapluminancephongmask <boolean> (in all games since L4D)
Mask phong intensity based on the brightness of the $basetexture.
$phongexponent and $phongexponent2 <integer>
The numeric value overrides an exponent mask if present.
$phongexponent2 is for WorldVertexTransition's second material in <Counter-Strike: Global Offensive>.
$phongexponenttexture <texture>
A global exponent value, or a per-texel exponent texture map. In an exponent map:
  • Red channel: Exponent (size of highlight, 0-255, where a value of 0 is a large highlight, 255 small.)
  • Green channel: Albedo tint (if $phongalbedotint 1, higher is more tint)
  • Blue channel: Nothing
  • Alpha channel: $rimlight mask.
Note:LightmappedGeneric and WorldVertexTransition do not have support for $phongexponenttexture. You must use $phongexponent instead.
$invertphongmask <boolean>
Appears to invert the value of the phong mask, as the name suggests. To do: What types of mask does this work on?
$phongexponentfactor <integer>
Multiply the exponent texture by this amount. To do: Is this available in every engine branch?
$forcephong <boolean> (in all games since L4D)
Force phong to be enabled even at low GPU levels. This requires phong to already be enabled in the material.
$shinyblood <integer> (only in L4ds)
$shinybloodexponent <integer> (only in L4ds)
To do: See Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2.
$diffuseexp <float>
To do: Does this have something to do with the $phongexponent, $phongexponenttexture or both? Confirm engine branches, likely Left 4 Dead series only.


$phongboost <float>
Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.
$phongfresnelranges <matrix>
See Phong Fresnel ranges. Default is "[0 0.5 1]".
$phongdisablehalflambert <boolean> (in all games since AS)
Disables forced half-lambertian shading on Phong materials.
$ambientocclusiontexture <texture>
A "dirtmap". Mentioned in the SDK samples and seen in the VMT for Alyx's face. Ambient Occlusion is generally used for the eyes and face. To do: Does this actually do anything?


$phongalbedotint <boolean>
Allows the $basetexture to tint the color of the Phong highlight. The amount of tint is defined by the green channel of $phongexponenttexture (see above).
Note:$phongalbedotint will tint highlights by the original color of the $basetexture even when the material is tinted by $color2 or rendercolor.
$phongalbedoboost <float> (in all games since CSGO)
Phong albedo overbrightening factor. Ranges 0-255. To do: Test and add a better description.
The Hunter without and with its $phongwarptexture, showing how it affects the Phong reflection.
$phongtint <RGB matrix>
Color tint of the phong reflection. The channels are interpreted relative to each other (so "[0 0 0]" and "[1 1 1]" are the same).
Warning: This will override $phongalbedotint if both are used.
Bug: This does not work with $basemapalphaphongmask.
$phongwarptexture <texture> (in all games since EP2)
Used to create an iridescence effect, as seen on Episode Two's Hunters. To do: How does $phongwarptexture actually work?
Note:Does not work in <Left 4 Dead 2>, despite the game being released in 2009.

Brush Shader Parameters

$phongmaskcontrastbrightness and $phongmaskcontrastbrightness2 <vector2> (only in CSGO)
LightmappedGeneric and WorldVertexTransition only. 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 for WorldVertexTransition's second material.
To do: Find out the range of both values, and whether or not VertexLitGeneric can support this parameter.
$phongamount and $phongamount2 <vector4> (only in CSGO)
LightmappedGeneric and WorldVertexTransition only. 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 for WorldVertexTransition's second material.
$phongbasetint and $phongbasetint2 <float> (only in CSGO)
To do: What are these?

See also