$phong

From Valve Developer Community
(Redirected from $phongwarptexture)
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 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.

Syntax

$phong <bool>
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>.
To do: 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

$bumpmap <texture>
There must be a Phong mask. The alpha channel of a bump map acts as a Phong mask by default.
$basemapalphaphongmask <boolean> (New with Half-Life 2: Episode Two / Source 2007)
Use $basetexture's alpha channel as the Phong mask instead of $bumpmap's. The Phong will not be influenced by the bump map, however.
$basemapluminancephongmask <boolean> (New with Left 4 Dead)
Mask phong intensity based on the brightness of the $basetexture.
$phongexponent and $phongexponent2 <integer>
A global exponent value. Overrides an exponent mask if present.
$phongexponent2 is for WorldVertexTransition's second material in <Counter-Strike: Global Offensive>.
$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.)
  • 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 and WorldVertexTransition do not have support for $phongexponenttexture. You must use $phongexponent instead.
$phongexponentfactor <integer> (Only in Source 2013 MP)
Multiply the exponent texture by this amount.
$invertphongmask <boolean> (New with Half-Life 2: Episode Two / Source 2007)
Invert the value of the phong mask. To do: What types of mask does this work on?
$forcephong <boolean> (New with Left 4 Dead)
Force phong shading on phong materials even at low GPU levels. This requires the convar mat_phong to be set to 1, otherwise it won't work.[confirm]
$diffuseexp <float> (Only in the Left 4 Dead series)
To do: Does this have something to do with the $phongexponent, $phongexponenttexture or both?
$shinyblood <integer> (Only in the Left 4 Dead series)
$shinybloodexponent <integer> (Only in the Left 4 Dead series)
To do: See Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2.

Brightness

$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> (New with Alien Swarm) (Also in Mapbase)
Disables forced half-lambertian shading on Phong materials.

Colors

$phongalbedotint <boolean> (New with Half-Life 2: Episode Two / Source 2007)
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> (New with Counter-Strike: Global Offensive)
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> (New with Half-Life 2: Episode Two / Source 2007)
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> (New with Half-Life 2: Episode Two / Source 2007)
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 Counter-Strike: Global Offensive)
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.
$phongamount and $phongamount2 <vector4> (Only in Counter-Strike: Global Offensive)
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 Counter-Strike: Global Offensive)
LightmappedGeneric and WorldVertexTransition only. Allows the $basetexture and/or $basetexture2 to tint the color of the Phong highlight.

Console Commands

mat_phong <boolean>
Disable or enable phong shading. Default 1.

See also