$phong
(Redirected from Phong)
$phong is a material shader parameter available in all
Source games since
Source 2006 for VertexLitGeneric, LightmappedGeneric, WorldVertexTransition. 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.
LightmappedGeneric and WorldVertexTransition is only available in 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.LightmappedGeneric is also available in Contents
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
$normalmapalphaenvmapmask and $selfillumfresnel when using $phong!- Using $selfillumfresnel without
$normalmapalphaenvmapmaskwill mask the$envmapusing the$basetexture's alpha channel. - Using $selfillumfresnel with
$normalmapalphaenvmapmaskwill multiply the$envmapby0.0f. Effectively disabling the effect! - When not using $selfillumfresnel. The mask used for
$envmapwill be the$basetexture's alpha channel unless$normalmapalphaenvmapmaskis also used. - If
$normalmapalphaenvmapmaskis used, the$bumpmap's alpha channel will be used for Phong masking. Using either$basemapalphaphongmaskor$basemapluminancephongmaskwill override it.
Phong requires mask. The alpha channel of a bump map acts as a Phong mask by default.
Shader(s): VertexLitGeneric
Use
Warning:Using this with
Warning:
Garry's Mod Using this with
$basetexture's alpha channel as the Phong mask instead of $bumpmap's alpha channel.
$normalmapalphaenvmapmask will override the mask used for $envmap to be the contents of the $basetexture's alpha channel!$normalmapalphaenvmapmask and $envmap renders in $envmap and $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
Bug:Doesn't work in
Garry's Mod.
$basetexture.
$envmap, if $normalmapalphaenvmapmask is used.A global exponent value. Overrides an exponent mask if present.
$phongexponent2is forWorldVertexTransition's second material in
CS: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:
$rimlightmask (only if$rimmask 1.)
Note:LightmappedGenericandWorldVertexTransitiondo not have support for$phongexponenttexture. You must use$phongexponentinstead.
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
Invert the value of the phong mask.
Bug:In
s and
s Shadercode, using this parameter will invert the mask used for
Confirm: Is this the case for all branches?
$envmap, not the one used for $phong!
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
See Phong Fresnel ranges. Default is
"[0 0.5 1]".
Note:$envmapis 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
$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:$phongalbedotintcannot be used with$phongtint. The later will disable the effect.
Note:$phongalbedotintworks by multiplying the$basetextureover 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:$phongalbedotintwill tint highlights by the original color of the$basetextureeven when the material is tinted by$color2orrendercolor.
Shader(s): VertexLitGeneric
Phong albedo overbrightening factor. Ranges 0-255.
Note: This will multiply the tint that is being applied to phong from $phongalbedotint.
Bug:This does not work when using $detail.
Shader(s): VertexLitGeneric
Color tint of the phong reflection.
Warning:This will override $phongalbedotintif 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.
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 (only in
)(also in
)
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.
$phongmaskcontrastbrightness2is 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.
$phongamount2is forWorldVertexTransition's second material.
Shader(s): LightmappedGeneric, WorldVertexTransition
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.