$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.
Warning:There are some caveats regarding $normalmapalphaenvmapmask and $selfillumfresnel when using $phong!
Brush Shader Parameters (only in
ShiroDkxtro2 (talk | contribs) m (Oversight fixup) |
(Phong does bump accordingly diffuse bump and under some cveats. Add more details for $diffuseexp. $phongalbedoboost bug links to $detail page) |
||
Line 31: | Line 31: | ||
* Using [[Glowing_Textures#.24selfillum|$selfillumfresnel]] '''with''' {{ent|$normalmapalphaenvmapmask}} will multiply the {{ent|$envmap}} by <code>0.0f</code>. Effectively disabling the effect! | * Using [[Glowing_Textures#.24selfillum|$selfillumfresnel]] '''with''' {{ent|$normalmapalphaenvmapmask}} will multiply the {{ent|$envmap}} by <code>0.0f</code>. Effectively disabling the effect! | ||
* When '''not''' using [[Glowing_Textures#.24selfillum|$selfillumfresnel]]. The mask used for {{ent|$envmap}} will be the {{ent|$basetexture}}'s alpha channel '''unless''' {{ent|$normalmapalphaenvmapmask}} is also used. | * When '''not''' using [[Glowing_Textures#.24selfillum|$selfillumfresnel]]. The mask used for {{ent|$envmap}} will be the {{ent|$basetexture}}'s alpha channel '''unless''' {{ent|$normalmapalphaenvmapmask}} is also used. | ||
'''If''' {{ent|$normalmapalphaenvmapmask}} is used, the {{ent|$bumpmap}}'s alpha channel will be used. Using either <code>$basemapalphaphongmask</code> or <code>$basemapluminancephongmask</code> will override it. | * '''If''' {{ent|$normalmapalphaenvmapmask}} is used, the {{ent|$bumpmap}}'s alpha channel will be used for Phong masking. Using either <code>$basemapalphaphongmask</code> or <code>$basemapluminancephongmask</code> will override it. | ||
<br> | <br> | ||
{{MatParam|$bumpmap|texture| | {{MatParam|$bumpmap|texture|Phong requires 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 | {{MatParam|$basemapalphaphongmask|bool|Use {{ent|$basetexture}}'s [[alpha channel]] as the Phong mask instead of <code>$bumpmap</code>'s [[alpha channel]]. | ||
{{warning|Using this with {{ent|$normalmapalphaenvmapmask}} will override the mask used for {{ent|$envmap}} to be the contents of the {{ent|$basetexture}}'s alpha channel!}} |since={{src07}}|shaders=VertexLitGeneric}} | {{warning|Using this with {{ent|$normalmapalphaenvmapmask}} will override the mask used for {{ent|$envmap}} to be the contents of the {{ent|$basetexture}}'s alpha channel!}} | ||
{{warning|{{gmod|4}} Using this with {{ent|$normalmapalphaenvmapmask}} and {{ent|$envmap}} renders in {{ent|$envmap}} and '''<code>$phong</code>''' be masked by both '''<code>$basemapalphaphongmask</code>''' alpha channel and {{ent|$normalmapalphaenvmapmask}} alpha channel.}} |since={{src07}}|shaders=VertexLitGeneric}} | |||
{{MatParam|$basemapluminancephongmask|bool|Mask phong intensity based on the brightness of the <code>$basetexture</code>. | {{MatParam|$basemapluminancephongmask|bool|Mask phong intensity based on the brightness of the <code>$basetexture</code>. | ||
{{bug|Basetexture Luminance will replace the mask used for {{ent|$envmap}}, '''if''' {{ent|$normalmapalphaenvmapmask}} is used.}} | {{bug|Basetexture Luminance will replace the mask used for {{ent|$envmap}}, '''if''' {{ent|$normalmapalphaenvmapmask}} is used.}} | ||
Line 46: | Line 47: | ||
:* '''Green channel:''' Albedo tint mask (only if <code>$phongalbedotint 1</code>, 0-255, where a value of 0 is no tint, 255 full 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 (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.}}|shaders=VertexLitGeneric}} | :{{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|float|Multiply the exponent from the <code>$phongexponenttexture</code> by this amount. {{tip| The default value of this parameter is <code>"0.0"</code>. However, a more reasonable default value would be <code>"149.0"</code>}}|only={{src13mp}}{{tf2}}|shaders=VertexLitGeneric}} | {{MatParam|$phongexponentfactor|float|Multiply the exponent from the <code>$phongexponenttexture</code> by this amount. {{tip| The default value of this parameter is <code>"0.0"</code>. However, a more reasonable default value would be <code>"149.0"</code>}}|only={{src13mp}}{{tf2}}|shaders=VertexLitGeneric}} | ||
Line 54: | Line 55: | ||
|since={{src07}}|shaders=VertexLitGeneric}} | |since={{src07}}|shaders=VertexLitGeneric}} | ||
{{MatParam|$forcephong|bool|Force phong shading on phong-using materials even at low GPU levels when <code>mat_phong</code> is disabled.|since={{portal2}}|shaders=VertexLitGeneric}} | {{MatParam|$forcephong|bool|Force phong shading on phong-using materials even at low GPU levels when <code>mat_phong</code> is disabled.|since={{portal2}}|shaders=VertexLitGeneric}} | ||
{{MatParam|$diffuseexp|float|Diffuse exponent used for dynamic lights only.|only={{L4ds}}}} | {{MatParam|$diffuseexp|float|Diffuse exponent used for dynamic lights only. | ||
{{MatParam|$shinyblood|int|Derive phong mask from areas that are more red than others. Only when variation is disabled.|only={{L4ds}}}} | {{note|have this with {{ent|$halflambert}} greatly decrease it effect.}}|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} | ||
{{MatParam|$shinybloodexponent|int|Exponent for the above.|only={{L4ds}}}} | {{MatParam|$shinyblood|int|Derive phong mask from areas that are more red than others. Only when variation is disabled.|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} | ||
{{MatParam|$shinybloodexponent|int|Exponent for the above.|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} | |||
=== Brightness === | === Brightness === | ||
Line 69: | Line 71: | ||
: {{Warning|<code>$phongalbedotint</code> cannot be used with <code>$phongtint</code>. The later will disable the effect.}} | : {{Warning|<code>$phongalbedotint</code> cannot be used with <code>$phongtint</code>. The later will disable the effect.}} | ||
: {{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>.}} | ||
: {{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}} | : {{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>}} | ||
: {{note| Also tints {{ent|$rimlight}}}}|since={{src07}}|shaders=VertexLitGeneric}} | |||
{{MatParam|$phongalbedoboost|float|Phong albedo overbrightening factor. Ranges 0-255. | {{MatParam|$phongalbedoboost|float|Phong albedo overbrightening factor. Ranges 0-255. | ||
: {{note| This will multiply the tint that is being applied to phong from $phongalbedotint.}} | : {{note| This will multiply the tint that is being applied to phong from $phongalbedotint.}} | ||
: {{bug| This does not work when using | : {{bug| This does not work when using [[$detail]]. }}|since={{csgo}}|shaders=VertexLitGeneric}} | ||
[[File:Phongwarp example.png|thumb|200px|The Hunter without and with its <code>$phongwarptexture</code>, 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. |
Revision as of 22:24, 17 March 2023
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

- Using $selfillumfresnel without $normalmapalphaenvmapmask will mask the $envmap using the $basetexture's alpha channel.
- Using $selfillumfresnel with $normalmapalphaenvmapmask will multiply the $envmap by
0.0f
. Effectively disabling the effect! - When not using $selfillumfresnel. The mask used for $envmap will be the $basetexture's alpha channel unless $normalmapalphaenvmapmask is also used.
- If $normalmapalphaenvmapmask is used, the $bumpmap's alpha channel will be used for Phong masking. Using either
$basemapalphaphongmask
or$basemapluminancephongmask
will override it.
$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 using tile/hr_t/inferno/tile_a. 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.