$phong: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Removed $ambientocclusiontexture as that does nothing for $phong in any branch, confirmed engine branches for $diffuseexp and $phongexponentfactor, misc improvements)
(Added shader information, revamped for MatParam changes)
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 bump map, 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={{src07}}|shaders=VertexLitGeneric}}
{{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}}|shaders=VertexLitGeneric}}
{{MatParam|$phongexponent|and=$phongexponent2|int|A global [[Phong materials#Phong mask and exponent texture|exponent]] 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}}.}}
Line 36: Line 36:
:* '''Blue channel:''' Nothing.
:* '''Blue channel:''' Nothing.
:* '''Alpha channel:''' {{ent|$rimlight}} mask (only if <code>$rimmask 1</code>.)
:* '''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.}}|shaders=VertexLitGeneric}}
{{MatParam|$phongexponentfactor|int|Multiply the exponent texture by this amount.|only=2013MP}}
{{MatParam|$phongexponentfactor|int|Multiply the exponent texture by this amount.|only={{src13}}MP|shaders=VertexLitGeneric}}
{{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={{src07}}|shaders=VertexLitGeneric}}
{{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 <code>mat_phong</code> to be set to 1, otherwise it won't work.{{confirm}}|since={{l4d}}|shaders=VertexLitGeneric}}
{{MatParam|$diffuseexp|float|{{todo|Does this have something to do with the $phongexponent, $phongexponenttexture or both?}}|only=L4ds}}
{{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}}}}


=== Brightness ===
=== Brightness ===


{{MatParam|$phongboost|float|Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.}}
{{MatParam|$phongboost|float|Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.|shaders=VertexLitGeneric}}
{{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>.|shaders=VertexLitGeneric}}
{{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}}|shaders=VertexLitGeneric}}


=== Colors ===
=== 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).
: {{Note|<code>$phongalbedotint</code> will tint highlights by the original color of the <code>$basetexture</code> even when the material is tinted by <code>$color2</code> or <code>rendercolor.</code>}}|since=EP2}}
: {{Note|<code>$phongalbedotint</code> will tint highlights by the original color of the <code>$basetexture</code> even when the material is tinted by <code>$color2</code> or <code>rendercolor.</code>}}|since={{src07}}|shaders=VertexLitGeneric}}
{{MatParam|$phongalbedoboost|float|Phong albedo overbrightening factor. Ranges 0-255. {{todo|Test and add a better description.}}|since=CSGO}}
{{MatParam|$phongalbedoboost|float|Phong albedo overbrightening factor. Ranges 0-255. {{todo|Test and add a better description.}}|since={{csgo}}|shaders=VertexLitGeneric}}
[[File:Phongwarp example.png|thumb|200px|The Hunter without and with its $phongwarptexture, showing how it affects the Phong reflection.]]
[[File:Phongwarp example.png|thumb|200px|The Hunter without and with its $phongwarptexture, showing how it affects the Phong reflection.]]
{{MatParam|$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).
{{MatParam|$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 <code>$phongalbedotint</code> if both are used.}}
: {{Warning|This will override <code>$phongalbedotint</code> if both are used.}}
: {{bug|This does not work with <code>$basemapalphaphongmask.</code>}}|since=EP2}}
: {{bug|This does not work with <code>$basemapalphaphongmask.</code>}}|since={{src07}}|shaders=VertexLitGeneric}}
{{MatParam|$phongwarptexture|texture|Used to create an iridescence effect, as seen on Episode Two's [[npc_hunter|Hunters]]. {{Todo|How does $phongwarptexture actually work?}}
{{MatParam|$phongwarptexture|texture|Used to create an iridescence effect, as seen on Episode Two's [[npc_hunter|Hunters]]. {{Todo|How does $phongwarptexture actually work?}}
: {{note|Does not work in {{l4d2}}, despite the game being released in 2009.}}|since=EP2}}
: {{note|Does not work in {{l4d2}}, despite the game being released in 2009.}}|since={{src07}}|shaders=VertexLitGeneric}}


=== Brush Shader Parameters ===
=== Brush Shader Parameters ===


{{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|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.}}|only=CSGO}}
: {{todo|Find out the range of both values.}}|only={{csgo}}|shaders=LightmappedGeneric, WorldVertexTransition}}
{{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|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}}|shaders=LightmappedGeneric, WorldVertexTransition}}
{{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}}
{{MatParam|$phongbasetint|and=$phongbasetint2|float|Allows the <code>$basetexture</code> and/or <code>$basetexture2</code> to tint the color of the Phong highlight.|only={{csgo}}|shaders=LightmappedGeneric, WorldVertexTransition}}


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

Revision as of 20:34, 22 April 2020

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