$phong: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Added $phongdisablehalflambert is also in Mapbase)
(Removed $ambientocclusiontexture as that does nothing for $phong in any branch, confirmed engine branches for $diffuseexp and $phongexponentfactor, misc improvements)
Line 7: Line 7:
  $phong <[[bool]]>
  $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}}.}}
{{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}}.}}
:{{todo|Other games that don't require all phong parameters present (likely Portal 2 and up)}}
:{{todo|Other games that don't require all phong parameters present (likely Portal 2 and up)}}
<syntaxhighlight lang=php>
<syntaxhighlight lang=php>
Line 27: Line 27:


{{MatParam|$bumpmap|texture|There must be a Phong mask. The [[alpha channel]] of a [[$bumpmap|bump map]] acts as a Phong mask by default.}}
{{MatParam|$bumpmap|texture|There must be a Phong mask. The [[alpha channel]] of a [[$bumpmap|bump map]] acts as a Phong mask by default.}}
{{MatParam|$basemapalphaphongmask|bool|Use {{ent|$basetexture}}'s [[alpha channel]] as the Phong mask instead of <code>$bumpmap</code>'s. The phong will not be influenced by the bumpmap, however.|since=EP2}}
{{MatParam|$basemapalphaphongmask|bool|Use {{ent|$basetexture}}'s [[alpha channel]] as the Phong mask instead of <code>$bumpmap</code>'s. The Phong will not be influenced by the bump map, however.|since=EP2}}
{{MatParam|$basemapluminancephongmask|bool|Mask phong intensity based on the brightness of the <code>$basetexture</code>.|since=L4D}}
{{MatParam|$basemapluminancephongmask|bool|Mask phong intensity based on the brightness of the <code>$basetexture</code>.|since=L4D}}
{{MatParam|$phongexponent|and=$phongexponent2|int|The numeric value overrides an exponent mask if present.
{{MatParam|$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 {{csgo}}.}}
: <code>$phongexponent2</code> is for <code>WorldVertexTransition</code>'s second material in {{csgo}}.}}
{{MatParam|$phongexponenttexture|texture|A global [[Phong materials#Phong mask and exponent texture|exponent]] value, or a per-texel exponent texture map. In an exponent map:
{{MatParam|$phongexponenttexture|texture|A per-texel exponent map. In an exponent map:
:* '''Red channel:''' Exponent (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 (if <code>$phongalbedotint 1</code>, higher is more 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.)
:* '''Blue channel:''' Nothing
:* '''Blue channel:''' Nothing.
:* '''Alpha channel:''' {{ent|$rimlight}} mask.
:* '''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.}}}}
:{{Note|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> do not have support for <code>$phongexponenttexture</code>. You must use <code>$phongexponent</code> instead.}}}}
{{MatParam|$phongexponentfactor|int|Multiply the exponent texture by this amount.|only=2013MP}}
{{MatParam|$invertphongmask|bool|Invert the value of the phong mask. {{todo|What types of mask does this work on?}}|since=EP2}}
{{MatParam|$invertphongmask|bool|Invert the value of the phong mask. {{todo|What types of mask does this work on?}}|since=EP2}}
{{MatParam|$phongexponentfactor|int|Multiply the exponent texture by this amount. {{todo|Is this available in every engine branch? Seems to be only in {{tf2}}.}}}}
{{MatParam|$forcephong|bool|Force phong shading on phong materials even at low GPU levels. This requires the convar <code>mat_phong</code> to be set to 1, otherwise it won't work.{{confirm}}|since=L4D}}
{{MatParam|$forcephong|bool|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}}|since=L4D}}
{{MatParam|$diffuseexp|float|{{todo|Does this have something to do with the $phongexponent, $phongexponenttexture or both?}}|only=L4ds}}
{{MatParam|$shinyblood|int|only=L4ds}}
{{MatParam|$shinyblood|int|only=L4ds}}
{{MatParam|$shinybloodexponent|int|{{todo|1=See ''[https://steamcdn-a.akamaihd.net/apps/valve/2010/GDC10_ShaderTechniquesL4D2.pdf#page=33 Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2]''.}}|only=L4ds}}
{{MatParam|$shinybloodexponent|int|{{todo|1=See ''[https://steamcdn-a.akamaihd.net/apps/valve/2010/GDC10_ShaderTechniquesL4D2.pdf#page=33 Shading a Bigger, Better Sequel: Techniques in Left 4 Dead 2]''.}}|only=L4ds}}
{{MatParam|$diffuseexp|float|{{todo|Does this have something to do with the <code>$phongexponent</code>, <code>$phongexponenttexture</code> or both? Confirm engine branches, likely Left 4 Dead series only.}}}}


=== Brightness ===
=== Brightness ===
Line 49: Line 49:
{{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>.}}
{{MatParam|$phongdisablehalflambert|bool|Disables forced [[$halflambert|half-lambertian]] shading on Phong materials.|since=AS|also=Mapbase}}
{{MatParam|$phongdisablehalflambert|bool|Disables forced [[$halflambert|half-lambertian]] shading on Phong materials.|since=AS|also=Mapbase}}
{{MatParam|$ambientocclusiontexture|texture|A "dirtmap". Mentioned in the SDK samples and seen in the VMT for Alyx's face. [[$ambientocclusion|Ambient Occlusion]] is generally used for the eyes and face. {{Todo|Does this actually do anything?}}}}


=== Colours ===
=== Colors ===


{{MatParam|$phongalbedotint|bool|Allows the <code>$basetexture</code> to tint the color of the Phong highlight. The amount of tint is defined by the green channel of <code>$phongexponenttexture</code> (see above).
{{MatParam|$phongalbedotint|bool|Allows the <code>$basetexture</code> to tint the color of the Phong highlight. The amount of tint is defined by the green channel of <code>$phongexponenttexture</code> (see above).
Line 67: Line 66:
{{MatParam|$phongmaskcontrastbrightness|and=$phongmaskcontrastbrightness2|vector2|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> only. The first value controls the contrast level between light and dark areas in the mask, and the second value controls the overall brightness.  
{{MatParam|$phongmaskcontrastbrightness|and=$phongmaskcontrastbrightness2|vector2|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> only. 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, and whether or not <code>VertexLitGeneric</code> can support this parameter.}}|only=CSGO}}
: {{todo|Find out the range of both values.}}|only=CSGO}}
{{MatParam|$phongamount|and=$phongamount2|vector4|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> 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.  
{{MatParam|$phongamount|and=$phongamount2|vector4|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> 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.  
: <code>$phongamount2</code> is for <code>WorldVertexTransition</code>'s second material.|only=CSGO}}
: <code>$phongamount2</code> is for <code>WorldVertexTransition</code>'s second material.|only=CSGO}}
{{MatParam|$phongbasetint|and=$phongbasetint2|float|Tints the phong color by the diffuse texture|only=CSGO}}
{{MatParam|$phongbasetint|and=$phongbasetint2|float|<code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> only. Allows the <code>$basetexture</code> and/or <code>$basetexture2</code> to tint the color of the Phong highlight.|only=CSGO}}


== Console Commands ==
== Console Commands ==

Revision as of 19:58, 8 December 2019

Phong shading provides Alyx's skin, hairband and lip highlights.

Template:Shaderparam It provides diffuse reflections, masked by a texture to control its intensity per-texel. For a full explanation, see Phong materials.

Note.pngNote: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.pngNote:All parameters in the following example must be specified in the material, otherwise Phong shading won't show up at all, except in Insurgency.
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

$bumpmap $basemapalphaphongmask $basemapluminancephongmask $phongexponent $phongexponenttexture $phongexponentfactor $invertphongmask $forcephong $diffuseexp $shinyblood $shinybloodexponent

Brightness

$phongboost $phongfresnelranges $phongdisablehalflambert

Colors

$phongalbedotint $phongalbedoboost

The Hunter without and with its $phongwarptexture, showing how it affects the Phong reflection.

$phongtint $phongwarptexture

Brush Shader Parameters

$phongmaskcontrastbrightness $phongamount $phongbasetint

Console Commands

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

See also