$phong: Difference between revisions
Jump to navigation
Jump to search
Note:Phong shading for
CS:GO engine branch. It requires the material to be lit by the sunlight from 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.
Note:Phong shading for
Mapbase, but it is implemented differently.
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.
Brush Shader Parameters (only in
m (→Masking: point a issue since ever for the outdated Garry's Mod shaders: https://github.com/Facepunch/garrysmod-issues/issues/4692) |
Kestrelguy (talk | contribs) m (added language bar.) |
||
Line 1: | Line 1: | ||
{{lang|$phong}}[[Category:List of Shader Parameters|P]][[Category:VMT Lighting]] | |||
[[File:Alyx phong closeup.jpg|thumb|200px|Phong shading provides Alyx's skin, hairband and lip highlights.]] | [[File:Alyx phong closeup.jpg|thumb|200px|Phong shading provides Alyx's skin, hairband and lip highlights.]] | ||
{{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 {{ | {{Note|Phong shading for <code>LightmappedGeneric</code> and <code>WorldVertexTransition</code> is only available in {{csgobranch|4}}. It requires the material to be lit by the sunlight from 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}}, but it is implemented differently.}} | {{Note|Phong shading for <code>LightmappedGeneric</code> is also available in {{mapbase|4}}, but it is implemented differently.}} | ||
==Syntax== | ==Syntax== | ||
$phong <[[bool]]> | $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}}.}} | {{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|4}}.}} | ||
:{{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 24: | Line 25: | ||
== Parameters == | == Parameters == | ||
=== Masking === | === Masking === | ||
{{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={{src07}}|shaders=VertexLitGeneric}} | {{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>.{{bug| | {{MatParam|$basemapluminancephongmask|bool|Mask phong intensity based on the brightness of the <code>$basetexture</code>.{{bug|Doesn't work in {{gmod|4}}.}}|not={{gmod}}|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 {{ | : <code>$phongexponent2</code> is for <code>WorldVertexTransition</code>'s second material in {{csgobranch|4}}.}} | ||
{{MatParam|$phongexponenttexture|texture|A per-texel exponent map. In an exponent map: | {{MatParam|$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.) | :* '''Red channel:''' Exponent mask (size of highlight, 0-255, where a value of 0 is a large highlight, 255 small.) | ||
Line 46: | Line 45: | ||
=== Brightness === | === Brightness === | ||
{{MatParam|$phongboost|float|Phong brightness factor. Larger values create a more intense highlight, useful for surfaces like metal and glass.|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase|only}})}} | |||
{{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.}} | :{{note|<code>$envmap</code> is 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.}}|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase}})}} | :{{note| drives the x component of a phongwarptexture if specified.}}|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase|only}})}} | ||
{{MatParam|$phongdisablehalflambert|bool|Disables forced [[$halflambert|half-lambertian]] shading on Phong materials. {{note|This parameter is effectively forced on in {{ | {{MatParam|$phongdisablehalflambert|bool|Disables forced [[$halflambert|half-lambertian]] shading on Phong materials. {{note|This parameter is effectively forced on in {{csgobranch|4}} due to <code>$halflambert</code> being disabled.}}|since={{as}}|also={{Mapbase}}|shaders=VertexLitGeneric}} | ||
=== Colors === | === Colors === | ||
{{MatParam|$phongalbedotint|bool|Tints the phong reflection by the color of the <code>$basetexture</code>. The amount of tint is defined by the green channel of <code>$phongexponenttexture</code>. A <code>$phongexponenttexture</code> must be specified in order for <code>$phongalbedotint</code> to work. | {{MatParam|$phongalbedotint|bool|Tints the phong reflection by the color of the <code>$basetexture</code>. The amount of tint is defined by the green channel of <code>$phongexponenttexture</code>. A <code>$phongexponenttexture</code> must be specified in order for <code>$phongalbedotint</code> to work. | ||
: {{Note|<code>$phongalbedotint</code> works by multiplying the <code>$basetexture</code> 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 <code>$phongboost</code>.}} | : {{Note|<code>$phongalbedotint</code> works by multiplying the <code>$basetexture</code> 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 <code>$phongboost</code>.}} | ||
Line 61: | Line 58: | ||
: {{note|Tint color is PhongAlbedoBoost * baseColor, mixed with the phong color by the albedo tint mask in <code>$phongexponenttexutre.</code>}} | : {{note|Tint color is PhongAlbedoBoost * baseColor, mixed with the phong color by the albedo tint mask in <code>$phongexponenttexutre.</code>}} | ||
: {{todo|Test and add a better description.}}|since={{csgo}}|shaders=VertexLitGeneric}} | : {{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 <code>$phongwarptexture</code>, showing how it affects the Phong reflection.]] | ||
{{MatParam|$phongtint|RGB matrix|Color tint of the phong reflection. | {{MatParam|$phongtint|RGB matrix|Color tint of the phong reflection. | ||
: {{Warning|This will override <code>$phongalbedotint</code> if both are used.}} | : {{Warning|This will override <code>$phongalbedotint</code> if both are used.}} | ||
Line 71: | Line 68: | ||
:y: 1 - (fresnel component as computed by [[Phong materials#Phong Fresnel ranges|Phong Fresnel ranges]]) | :y: 1 - (fresnel component as computed by [[Phong materials#Phong Fresnel ranges|Phong Fresnel ranges]]) | ||
: {{note|Disables the initial phongfresnelranges masking}} | : {{note|Disables the initial phongfresnelranges masking}} | ||
: {{bug|Does not work in {{l4d2}} | : {{bug|Does not work in {{l4d2|4}}.}}|since={{src07}}|shaders=VertexLitGeneric}} | ||
[[File:Brush_phong.jpg|thumb|200px|Brush phong in {{csgo}}. Note the complete absence of the reflection in the shaded area.]] | [[File:Brush_phong.jpg|thumb|200px|Brush phong in {{csgo|2}}. Note the complete absence of the reflection in the shaded area.]] | ||
===Brush Shader Parameters {{csgobranch|only}}=== | |||
{{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. | {{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. | : {{todo|Find out the range of both values.}}|shaders=LightmappedGeneric, WorldVertexTransition}} | ||
{{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. | {{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. | : <code>$phongamount2</code> is for <code>WorldVertexTransition</code>'s second material.|shaders=LightmappedGeneric, WorldVertexTransition}} | ||
{{MatParam|$phongbasetint|and=$phongbasetint2|float|Allows the <code>$basetexture</code> and/or <code>$basetexture2</code> to tint the color of the Phong highlight. | {{MatParam|$phongbasetint|and=$phongbasetint2|float|Allows the <code>$basetexture</code> and/or <code>$basetexture2</code> to tint the color of the Phong highlight.|shaders=LightmappedGeneric, WorldVertexTransition}} | ||
== Console Commands == | == Console Commands == | ||
{{IO|mat_phong|param=bool|Disable or enable phong shading. Default 1.}} | {{IO|mat_phong|param=bool|Disable or enable phong shading. Default 1.}} | ||
== See | == See Also == | ||
* [[Phong materials]] | * [[Phong materials]] | ||
* | * {{ent|$envmap}} (environment map) | ||
* | * {{ent|$lightwarptexture}} | ||
* | * {{ent|$rimlight}} | ||
* [https://tf2maps.net/threads/phong-on-brushes-the-hacky-way.26765 $Phong on brushes*: The Hacky Way (a TF2maps.net guide on how to fake $Phong on brushes for games prior to CS:GO)] | * [https://tf2maps.net/threads/phong-on-brushes-the-hacky-way.26765 $Phong on brushes*: The Hacky Way (a TF2maps.net guide on how to fake $Phong on brushes for games prior to CS:GO)] | ||
*[https://share.substance3d.com/libraries/6595 SubstancePainter Source Engine Complex Phong Shader] | *[https://share.substance3d.com/libraries/6595 SubstancePainter Source Engine Complex Phong Shader] | ||
Revision as of 15:42, 9 May 2022
Template:Shaderparam 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 

LightmappedGeneric
is also available in 
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
$bumpmap
$basemapalphaphongmask
$basemapluminancephongmask
$phongexponent
$phongexponenttexture
$phongexponentfactor
$invertphongmask
$forcephong
$diffuseexp
$shinyblood
$shinybloodexponent
Brightness
$phongboost
$phongfresnelranges
$phongdisablehalflambert
Colors
$phongalbedotint
$phongalbedoboost

Brush phong in
Counter-Strike: Global Offensive. Note the complete absence of the reflection in the shaded area.

Brush Shader Parameters (only in
)
$phongmaskcontrastbrightness
$phongamount
$phongbasetint
Console Commands
- mat_phong <boolean >
- Disable or enable phong shading. Default 1.