Difference between revisions of "$phong"
m (→See also: Added external guide for $phong on brushes) |
Gaming chair (talk | contribs) m (Added mapbase stuff) |
||
Line 3: | Line 3: | ||
{{Shaderparam|$phong|since=Source 2006|shader1=VertexLitGeneric|shader2=LightmappedGeneric|shader3=WorldVertexTransition}} It provides diffuse reflections, masked by a texture to control its intensity per-texel. For a full explanation, see [[Phong materials]]. | {{Shaderparam|$phong|since=Source 2006|shader1=VertexLitGeneric|shader2=LightmappedGeneric|shader3=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 <code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> is only available in {{csgo}}. It requires the material to be lit by 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.}} | {{Note|Phong shading for <code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> is only available in {{csgo}}. It requires the material to be lit by 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.}} | ||
+ | {{Note|Phong shading for <code>LightmappedGeneric</code> is also available in {{mapbase}}}} | ||
==Syntax== | ==Syntax== | ||
Line 46: | Line 47: | ||
=== Brightness === | === Brightness === | ||
− | {{MatParam|$phongboost|float|Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.|shaders=VertexLitGeneric}} | + | {{MatParam|$phongboost|float|Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase}})}} |
{{MatParam|$phongfresnelranges|matrix|See [[Phong materials#Phong Fresnel ranges|Phong Fresnel ranges]]. Default is <code>"[0 0.5 1]"</code>. | {{MatParam|$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.}}|shaders=VertexLitGeneric}} | + | :{{note|<code>$envmap</code> is also affected by these fresnel ranges if both it and Phong are enabled in a material.}}|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase}})}} |
{{MatParam|$phongdisablehalflambert|bool|Disables forced [[$halflambert|half-lambertian]] shading on Phong materials.|since={{as}}|also={{Mapbase}}|shaders=VertexLitGeneric}} | {{MatParam|$phongdisablehalflambert|bool|Disables forced [[$halflambert|half-lambertian]] shading on Phong materials.|since={{as}}|also={{Mapbase}}|shaders=VertexLitGeneric}} | ||
Revision as of 09:40, 21 January 2021
$phong
is a material shader parameter available in all Source games since 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.

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.Contents
Syntax
$phong <bool>


- 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>
(in all games since)
- Use
$basetexture
's alpha channel as the Phong mask instead of$bumpmap
's. The Phong will not be influenced by the bump map, however. - Shaders: VertexLitGeneric
$basemapluminancephongmask
<boolean>
(in all games since)
- Mask phong intensity based on the brightness of the
$basetexture
. - Shaders: VertexLitGeneric
$phongexponent
and$phongexponent2
<integer>
- A global exponent value. Overrides an exponent mask if present.
$phongexponent2
is forWorldVertexTransition
's second material in.
$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
andWorldVertexTransition
do not have support for$phongexponenttexture
. You must use$phongexponent
instead.- Shaders: VertexLitGeneric
$phongexponentfactor
<integer>
(only in)
- Multiply the exponent texture by this amount.
- Shaders: VertexLitGeneric
$invertphongmask
<boolean>
(in all games since)
- Invert the value of the phong mask. To do: What types of mask does this work on?
- Shaders: VertexLitGeneric
$forcephong
<boolean>
(in all games since)
- 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] - Shaders: VertexLitGeneric
$diffuseexp
<float>
(only in)
- To do: Does this have something to do with the $phongexponent, $phongexponenttexture or both?
$shinyblood
<integer>
(only in)
$shinybloodexponent
<integer>
(only in)
- 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.
- Shaders: VertexLitGeneric, LightmappedGeneric(
)
$phongfresnelranges
<matrix>
- 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.- Shaders: VertexLitGeneric, LightmappedGeneric(
)
$phongdisablehalflambert
<boolean>
(in all games since) (also in
)
- Disables forced half-lambertian shading on Phong materials.
- Shaders: VertexLitGeneric
Colors
$phongalbedotint
<boolean>
(in all games since)
- 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. 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.
- Shaders: VertexLitGeneric
$phongalbedoboost
<float>
(in all games since)
- Phong albedo overbrightening factor. Ranges 0-255. To do: Test and add a better description.
- Shaders: VertexLitGeneric
$phongtint
<RGB matrix>
(in all games since)
- 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.
- Shaders: VertexLitGeneric
$phongwarptexture
<texture>
(in all games since)
- Used to create an iridescence effect, as seen on Episode Two's Hunters. To do: How does $phongwarptexture actually work?
- Shaders: VertexLitGeneric
Brush Shader Parameters
$phongmaskcontrastbrightness
and$phongmaskcontrastbrightness2
<vector2>
(only in)
- 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.- To do: Find out the range of both values.
- Shaders: LightmappedGeneric, WorldVertexTransition
$phongamount
and$phongamount2
<vector4>
(only in)
- 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.- Shaders: LightmappedGeneric, WorldVertexTransition
$phongbasetint
and$phongbasetint2
<float>
(only in)
- Allows the
$basetexture
and/or$basetexture2
to tint the color of the Phong highlight. - Shaders: LightmappedGeneric, WorldVertexTransition
Console Commands
mat_phong
<boolean>
- Disable or enable phong shading. Default 1.