这篇条目有关 Source引擎。如需详情,点击这里。

Zh/$phong: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
No edit summary
No edit summary
 
(15 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{lang|$phong|title=冯氏反射}}[[Category:List of Shader Parameters|P]][[Category:VMT Lighting]]
{{LanguageBar}}
[[File:Alyx phong closeup.jpg|thumb|200px|Phong shading provides Alyx's skin, hairband and lip highlights.]]
{{this is a|shader parameter|name=$phong|since=Source 2006|shader=VertexLitGeneric}}  
[[File:Alyx phong closeup.jpg|thumb|200px|Phong shading enhances Alyx's skin, hairband, and lip highlights.]]
此参数同样适用于 {{code|[[LightmappedGeneric]]}} 和 {{code|[[WorldVertexTransition]]}} shaders,并在所有 {{csgo|4}} 及以后的游戏中可用{{also|{{gmod}}{{xengine}}{{mapbase}}}}。它通过一个纹理控制每个 texel 的强度,提供了 {{w|diffuse reflection|icon=hide}} 的低强度反射以及 {{w|specular highlight|icon=hide}} 的峰值高光。详细说明请参见 [[Phong materials]]。
 
{{Note|<code>LightmappedGeneric</code> 和 <code>WorldVertexTransition</code> 的 Phong 着色仅在 {{csgobranch}}{{strata}} 中可用。它要求材质由 {{ent|env_cascade_light}} 实体的阳光照亮才能正常工作,并使用由其生成的动态阴影作为传统 phong 遮罩之上的额外遮罩。({{Strata|since}} {{ent|env_projectedtexture}} 也会影响启用 phong 的刷子) 
{{bug*|{{gmod|4}} 从 {{ent|env_sun}} 读取刷子 Phong 的光照方向;在有多个太阳的地图中,刷子上的 Phong 反射可能不准确。}}}}
 
{{Note|<code>LightmappedGeneric</code> 的 Phong 着色在 {{mapbase|4}} 中同样可用,但其实现方式有所不同。}}


{{Shaderparam|$phong|since=Source 2006|shader1=VertexLitGeneric|shader2=LightmappedGeneric|shader3=WorldVertexTransition}} It provides [[Wikipedia:Diffuse_reflection|diffuse reflections]] at low intensity and [[Wikipedia:Specular_highlights|specular highlights]] at apex intensity, masked by a texture which control per-texel its intensity. For a full explanation, see [[Phong materials]].
{{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|4}}, but it is implemented differently.}}
== 语法 ==


  $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|4}}.}}
{{note|以下参数必须全部在材质中指定,Phong阴影才能正常工作,除非在{{insurgency|4}}中。}}
:{{todo|Other games that don't require all phong parameters present (likely Portal 2 and up)}}
:{{todo|记录其他不需要所有Phong参数的游戏(可能包括Portal 2及其更高版本)。}}
<syntaxhighlight lang=php>
 
<syntaxhighlight>
VertexLitGeneric
VertexLitGeneric
{
{
$phong 1
$phong 1


$bumpmap [texture]
$bumpmap [texture]           // 表面的法线贴图
$phongexponent 5 // either/or
$phongexponent 5                   // Phong指数值(任选其一)
$phongexponenttexture [texture] // either/or
$phongexponenttexture [texture]           // 控制Phong指数的纹理(任选其一)
$phongboost 1.0
$phongboost 1.0                 // 高光强度的倍增系数
$phongfresnelranges "[0 0.5 1]"
$phongfresnelranges "[0 0.5 1]"         // 控制反射强度的菲涅耳范围设置
}
}
</syntaxhighlight>
</syntaxhighlight>
=== 遮罩 === 
{{warning|在使用{{ent|$phong}}时,{{ent|$normalmapalphaenvmapmask}}和[[Glowing_Textures#.24selfillum|$selfillumfresnel]]存在一些注意事项!}} 
* 使用[[Glowing_Textures#.24selfillum|$selfillumfresnel]]而'''不使用'''{{ent|$normalmapalphaenvmapmask}}时,{{ent|$envmap}}将使用{{ent|$basetexture}}的alpha通道作为遮罩。 
* 使用[[Glowing_Textures#.24selfillum|$selfillumfresnel]]并'''启用'''{{ent|$normalmapalphaenvmapmask}}时,{{ent|$envmap}}将乘以<code>0.0f</code>,实际上禁用了该效果! 
* 当'''不使用'''[[Glowing_Textures#.24selfillum|$selfillumfresnel]]时,{{ent|$envmap}}所用的遮罩将是{{ent|$basetexture}}的alpha通道,'''除非'''也使用了{{ent|$normalmapalphaenvmapmask}}。 
* '''如果'''使用了{{ent|$normalmapalphaenvmapmask}},则将使用{{ent|$bumpmap}}的alpha通道作为Phong遮罩,但使用<code>$basemapalphaphongmask</code>或<code>$basemapluminancephongmask</code>将会覆盖此行为。 
<br> 
{{MatParamDef|$bumpmap|texture|Phong需要遮罩。[[$bumpmap|法线贴图]]的[[alpha通道]]默认作为Phong遮罩。}} 
{{MatParamDef|$basemapalphaphongmask|bool|使用{{ent|$basetexture}}的[[alpha通道]]作为Phong遮罩,而不是<code>$bumpmap</code>的[[alpha通道]]。 
{{warning|与{{ent|$normalmapalphaenvmapmask}}一起使用时,将覆盖{{ent|$envmap}}所用的遮罩为{{ent|$basetexture}}的alpha通道内容!}} 
{{warning|{{gmod|4}} 如果同时使用{{ent|$normalmapalphaenvmapmask}}、{{ent|$envmap}}和{{ent|$basemapalphaphongmask}},则'''<code>$phong</code>'''和{{ent|$envmap}}将同时被'''<code>$basemapalphaphongmask</code>''' alpha通道和{{ent|$normalmapalphaenvmapmask}} alpha通道遮罩。}} |since={{src07}}|shaders=VertexLitGeneric}} 
{{MatParamDef|$basemapluminancephongmask|bool|基于<code>$basetexture</code>的亮度遮罩Phong强度。 
{{bug|当使用{{ent|$normalmapalphaenvmapmask}}时,Basetexture Luminance将替换{{ent|$envmap}}的遮罩。}} 
{{bug|在{{gmod|4}}中不起作用。}} 
|not={{gmod}}|since={{l4d}}|shaders=VertexLitGeneric}} 
{{MatParamDef|$phongexponent|and=$phongexponent2|int|一个全局[[Phong materials#Phong mask and exponent texture|指数]]值。覆盖任何存在的指数遮罩。 
: <code>$phongexponent2</code>是用于{{csgobranch|4}}中的<code>WorldVertexTransition</code>第二材质的参数。}} 
{{MatParamDef|$phongexponenttexture|texture|一个逐像素的指数贴图。在指数贴图中: 
:* '''红色通道:''' 指数遮罩(高光大小,0-255,其中0表示大高光,255表示小高光。) 
:* '''绿色通道:''' Albedo色调遮罩(仅当<code>$phongalbedotint 1</code>时,0-255,其中0为无色调,255为完全色调。) 
:* '''蓝色通道:''' 无作用。 
:* '''Alpha通道:''' {{ent|$rimlight}}遮罩(仅当'''<code>$rimmask 1</code>'''时。) 
:{{Note|<code>LightmappedGeneric</code>和<code>WorldVertexTransition</code>不支持<code>$phongexponenttexture</code>,您必须使用<code>$phongexponent</code>代替。}}|shaders=VertexLitGeneric}} 
{{MatParamDef|$phongexponentfactor|float|将<code>$phongexponenttexture</code>中的指数乘以该参数的值。{{tip|该参数的默认值为<code>"0.0"</code>。然而,更合理的默认值应为<code>"149.0"</code>。}}|only={{src13mp}}{{tf2}}|shaders=VertexLitGeneric}} 
{{MatParamDef|$invertphongmask|bool|反转Phong遮罩的值。 
{{bug|在{{as}}和{{src13}}的Shadercode中,使用此参数将反转用于{{ent|$envmap}}的遮罩,而不是用于<code>$phong</code>的遮罩!}} 
{{confirm| 这种情况是否适用于所有分支?}} 
|since={{src07}}|shaders=VertexLitGeneric}} 
{{MatParamDef|$forcephong|bool|即使在GPU等级较低并且<code>mat_phong</code>被禁用时,仍强制启用使用Phong的材质的Phong阴影效果。|since={{portal2}}|shaders=VertexLitGeneric}} 
{{MatParamDef|$diffuseexp|float|仅用于动态光的漫反射指数。 
{{note|与{{ent|$halflambert}}一起使用会大幅降低其效果。}}|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} 
{{MatParamDef|$shinyblood|int|根据区域的红色程度衍生Phong遮罩。仅在禁用变化时有效。|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} 
{{MatParamDef|$shinybloodexponent|int|用于上述的指数值。|only={{L4ds}}|shaders=VertexLitGeneric, Infected}} 
===亮度===
{{MatParamDef|$phongboost|float|Phong亮度系数。较大的值会产生更强烈的高光,适用于金属和玻璃等表面。|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase|only}})}} 
{{MatParamDef|$phongfresnelranges|matrix|请参见[[Phong materials#Phong Fresnel ranges|Phong Fresnel范围]]。默认值为<code>"[0 0.5 1]"</code>。 
:{{note|如果材质同时启用了<code>$envmap</code>和Phong,这些Fresnel范围也会影响<code>$envmap</code>。}} 
:{{note|如果指定了<code>phongwarptexture</code>,它会驱动该纹理的x分量。}}|shaders=VertexLitGeneric, LightmappedGeneric({{mapbase|only}})}} 
{{MatParamDef|$phongdisablehalflambert|bool|禁用强制的[[$halflambert|半朗伯]]阴影效果。{{note|在{{csgobranch|4}}中,由于<code>$halflambert</code>被禁用,此参数实际上被强制启用。}}|since={{as}}|also={{gmod}},{{Mapbase}}|shaders=VertexLitGeneric}} 




== 参数 ==
=== 颜色 ===
=== 蒙版 ===
{{MatParamDef|$phongalbedotint|bool|通过<code>$basetexture</code>的颜色对Phong反射进行染色。染色的程度由<code>$phongexponenttexture</code>的绿色通道决定。必须指定<code>$phongexponenttexture</code>才能使<code>$phongalbedotint</code>生效。 
{{warning|There are some caveats regarding {{ent|$normalmapalphaenvmapmask}} and [[Glowing_Textures#.24selfillum|$selfillumfresnel]] when using {{ent|$phong}}!}}
: {{Warning|<code>$phongalbedotint</code>无法与<code>$phongtint</code>同时使用,后者会禁用该效果。}}
* Using [[Glowing_Textures#.24selfillum|$selfillumfresnel]] '''without''' {{ent|$normalmapalphaenvmapmask}} will mask the {{ent|$envmap}} using the {{ent|$basetexture}}'s alpha channel.
: {{Note|<code>$phongalbedotint</code>通过将<code>$basetexture</code>的颜色乘以反射实现,而不会使原材质变暗。反射的亮度会因此减弱,因此需在Phong遮罩或使用<code>$phongboost</code>时加以补偿。}}
* Using [[Glowing_Textures#.24selfillum|$selfillumfresnel]] '''with''' {{ent|$normalmapalphaenvmapmask}} will multiply the {{ent|$envmap}} by <code>0.0f</code>. Effectively disabling the effect!
: {{Note|即使材质被<code>$color2</code>或<code>rendercolor</code>调整颜色,<code>$phongalbedotint</code>仍会使用<code>$basetexture</code>的原始颜色来染色高光。}}|since={{src07}}|shaders=VertexLitGeneric}}
* 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.
[[File:Albedotint example.jpg|thumb|200px|一个展示AlbedoTint效果的模型示例。]] 
* '''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.
{{MatParamDef|$phongalbedoboost|float|Phong Albedo亮度增强因子,范围为0-255。 
<br>
: {{note|这会乘以<code>$phongalbedotint</code>应用到Phong上的染色。}}
{{MatParam|$bumpmap|texture|Phong requires mask. The [[alpha channel]] of a [[$bumpmap|bump map]] acts as a Phong mask by default.}}
: {{bug|当使用[[$detail]]时,此功能无效。}}|since={{csgo}}|also={{gmod}}|shaders=VertexLitGeneric}}
{{MatParam|$basemapalphaphongmask|bool|Use {{ent|$basetexture}}'s [[alpha channel]] as the Phong mask instead of <code>$bumpmap</code>'s [[alpha channel]].
[[File:Phongwarp example.png|thumb|200px|Hunter模型在使用<code>$phongwarptexture</code>前后的对比,展示其对Phong反射的影响。]] 
{{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!}}
{{MatParamDef|$phongtint|RGB矩阵|对Phong反射进行颜色染色。 
{{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}}
: {{Warning|如果同时使用<code>$phongtint</code><code>$phongalbedotint</code>,前者会覆盖后者的效果。}}
{{MatParam|$basemapluminancephongmask|bool|Mask phong intensity based on the brightness of the <code>$basetexture</code>.
: {{note|也会对{{ent|$rimlight}}进行染色。}}|since={{src07}}|shaders=VertexLitGeneric}}
{{bug|Basetexture Luminance will replace the mask used for {{ent|$envmap}}, '''if''' {{ent|$normalmapalphaenvmapmask}} is used.}}
[[File:Phongwarp_coordinate_guide.png|thumb|200px|<code>$phongwarptexture</code>的坐标分解:计算的坐标、纹理和结果。]] 
{{bug|Doesn't work in {{gmod|4}}.}}
{{MatParamDef|$phongwarptexture|texture|用于创建虹彩效果,例如在《第二章》的[[npc_hunter|Hunter]]中体现的效果。 
|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.
:x: 1 - (距离高光中心的距离) 
: <code>$phongexponent2</code> is for <code>WorldVertexTransition</code>'s second material in {{csgobranch|4}}.}}
:y: 1 - (由[[Phong materials#Phong Fresnel ranges|Phong Fresnel范围]]计算的Fresnel分量) 
{{MatParam|$phongexponenttexture|texture|A per-texel exponent map. In an exponent map:
: {{note|禁用初始的<code>phongfresnelranges</code>遮罩}}
:* '''Red channel:''' Exponent mask (size of highlight, 0-255, where a value of 0 is a large highlight, 255 small.)
: {{bug|{{l4d2|4}}中无效。}}|since={{src07}}|shaders=VertexLitGeneric}}
:* '''Green channel:''' Albedo tint mask (only if <code>$phongalbedotint 1</code>, 0-255, where a value of 0 is no tint, 255 full tint.)
[[File:Brush_phong.jpg|thumb|200px|{{csgo|2}}中使用tile/hr_t/inferno/tile_a的刷子Phong效果。注意阴影区域完全缺乏反射。]] 
:* '''Blue channel:''' Nothing.
:* '''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}}
{{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|$invertphongmask|bool|Invert the value of the phong mask.
{{bug|In {{as}}s and {{src13}}s Shadercode, using this parameter will invert the mask used for {{ent|$envmap}}, not the one used for <code>$phong</code>! }}
{{confirm| Is this the case for all branches?}}
|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|$diffuseexp|float|Diffuse exponent used for dynamic lights only.
{{note|have this with {{ent|$halflambert}} greatly decrease it effect.}}|only={{L4ds}}|shaders=VertexLitGeneric, Infected}}
{{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 ===
{{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|$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| 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 {{csgobranch|4}} due to <code>$halflambert</code> being disabled.}}|since={{as}}|also={{Mapbase}}|shaders=VertexLitGeneric}}


=== 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.
:{{csgobranch|only}}{{also|{{gmod}}}} 
: {{Warning|<code>$phongalbedotint</code> cannot be used with <code>$phongtint</code>. The later will disable the effect.}}
{{MatParamDef|$phongmaskcontrastbrightness|and=$phongmaskcontrastbrightness2|vector2|第一个值控制遮罩中光亮和暗区域之间的对比度,第二个值控制整体亮度。 
: {{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>.}}
: <code>$phongmaskcontrastbrightness2</code> 是用于<code>WorldVertexTransition</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}}
: {{todo|找出这两个值的范围。}}|shaders=LightmappedGeneric, WorldVertexTransition}}
{{MatParam|$phongalbedoboost|float|Phong albedo overbrightening factor. Ranges 0-255.
{{MatParamDef|$phongamount|and=$phongamount2|vector4|前3个值控制颜色染色,第四个值控制亮度。第四个值可以超过1,但影响的是整个纹理的亮度,而不是仅仅高光。 
: {{note| This will multiply the tint that is being applied to phong from $phongalbedotint.}}
: <code>$phongamount2</code> 是用于<code>WorldVertexTransition</code>的第二个材质。|shaders=LightmappedGeneric, WorldVertexTransition}}
: {{bug| This does not work when using [[$detail]]. }}|since={{csgo}}|shaders=VertexLitGeneric}}
{{MatParamDef|$phongbasetint|and=$phongbasetint2|float|允许<code>$basetexture</code>和/或<code>$basetexture2</code>为Phong高光染色。|shaders=LightmappedGeneric, WorldVertexTransition}}
[[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.
: {{Warning|This will override <code>$phongalbedotint</code> if both are used.}}
: {{note| Also tints {{ent|$rimlight}}}}|since={{src07}}|shaders=VertexLitGeneric}}
[[File:Phongwarp_coordinate_guide.png|thumb|200px|Breakdown of the $phongwarptexture: computed coordinates, texture and result]]
{{MatParam|$phongwarptexture|texture|Used to create an iridescence effect, as seen on Episode Two's [[npc_hunter|Hunters]].
: The highlight is multiplied with a texture. The coordinates of the sampled pixel are as follows:
:x: 1 - (distance to the center of the highlight)
:y: 1 - (fresnel component as computed by [[Phong materials#Phong Fresnel ranges|Phong Fresnel ranges]])
: {{note|Disables the initial phongfresnelranges masking}}
: {{bug|Does not work in {{l4d2|4}}.}}|since={{src07}}|shaders=VertexLitGeneric}}
[[File:Brush_phong.jpg|thumb|200px|Brush phong in {{csgo|2}} using tile/hr_t/inferno/tile_a. 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.
{{varcom|start}}
: <code>$phongmaskcontrastbrightness2</code> is for <code>WorldVertexTransition</code>'s second material.
{{varcom|mat_phong||bool|禁用或启用Phong阴影。默认值为1。}}
: {{todo|Find out the range of both values.}}|shaders=LightmappedGeneric, WorldVertexTransition}}
{{varcom|end}}
{{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.|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.|shaders=LightmappedGeneric, WorldVertexTransition}}


== 控制台命令 ==
== 另请参阅 ==
{{IO|mat_phong|param=bool|禁用或启用冯氏反射渲染。默认为 1。}}
* [[Phong materials]] 
* {{ent|$envmap}}(环境贴图) 
* {{ent|$lightwarptexture}} 
* {{ent|$rimlight}}


== 另见 ==
== 外部链接 ==
* [[Phong materials]]
* [https://tf2maps.net/threads/phong-on-brushes-the-hacky-way.26765 $Phong on brushes*: The Hacky Way] - TF2maps.net上的指南,解释了如何在CS:GO之前的游戏中伪造$Phong对刷子进行渲染。也可用于伪造在Vertex光照下进行点光源处理的[[prop_static|静态模型]]
* {{ent|$envmap}} (environment map)
* [https://share.substance3d.com/libraries/6595 SubstancePainter Source Engine Complex Phong Shader] - 提供Substance Painter对Source引擎的复杂Phong着色器 
* {{ent|$lightwarptexture}}
[[Category:Shader parameters|p]][[Category:VMT Lighting]] 
* {{ent|$rimlight}}
[[Category:Material System]]
* [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]

Latest revision as of 11:50, 23 August 2025

English (en)Español (es)Русский (ru)中文 (zh)Translate (Translate)

$phong是一个用于着色器 VertexLitGeneric材质(en)着色器(en)参数,可在所有的 起源 起源 游戏,自从 起源2006 起源2006 以来中使用。

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

此参数同样适用于 LightmappedGenericWorldVertexTransition shaders,并在所有 反恐精英:全球攻势 反恐精英:全球攻势 及以后的游戏中可用(也存在于 Garry's ModXengineMapbase 之中)。它通过一个纹理控制每个 texel 的强度,提供了 Wikipedia icon diffuse reflection 的低强度反射以及 Wikipedia icon specular highlight 的峰值高光。详细说明请参见 Phong materials

Note.png注意:LightmappedGenericWorldVertexTransition 的 Phong 着色仅在 CS:GO 引擎分支地层起源 中可用。它要求材质由 env_cascade_light 实体的阳光照亮才能正常工作,并使用由其生成的动态阴影作为传统 phong 遮罩之上的额外遮罩。((存在于自 地层起源 以来) env_projectedtexture 也会影响启用 phong 的刷子)
Icon-Bug.png错误*:Garry's Mod Garry's Modenv_sun 读取刷子 Phong 的光照方向;在有多个太阳的地图中,刷子上的 Phong 反射可能不准确。
Note.png注意:LightmappedGeneric 的 Phong 着色在 Mapbase Mapbase 中同样可用,但其实现方式有所不同。


$phong <bool>
Note.png注意:以下参数必须全部在材质中指定,Phong阴影才能正常工作,除非在Insurgency Insurgency中。
待完善: 记录其他不需要所有Phong参数的游戏(可能包括Portal 2及其更高版本)。
VertexLitGeneric
{
	$phong 1

	$bumpmap				[texture]            // 表面的法线贴图
	$phongexponent			5                   // Phong指数值(任选其一)
	$phongexponenttexture	[texture]            // 控制Phong指数的纹理(任选其一)
	$phongboost				1.0                 // 高光强度的倍增系数
	$phongfresnelranges		"[0 0.5 1]"         // 控制反射强度的菲涅耳范围设置
}

遮罩

Warning.png警告:在使用$phong时,$normalmapalphaenvmapmask$selfillumfresnel存在一些注意事项!


Phong需要遮罩。法线贴图alpha通道默认作为Phong遮罩。
$basemapalphaphongmask(en) <布尔值(en)> (存在于自 起源2007 以来)
Shader(s): VertexLitGeneric
使用$basetexturealpha通道作为Phong遮罩,而不是$bumpmapalpha通道
Warning.png警告:$normalmapalphaenvmapmask一起使用时,将覆盖$envmap所用的遮罩为$basetexture的alpha通道内容!
Warning.png警告:Garry's Mod Garry's Mod 如果同时使用$normalmapalphaenvmapmask$envmap$basemapalphaphongmask,则$phong$envmap将同时被$basemapalphaphongmask alpha通道和$normalmapalphaenvmapmask alpha通道遮罩。
$basemapluminancephongmask(en) <布尔值(en)> (存在于自 求生之路 以来)
Shader(s): VertexLitGeneric
基于$basetexture的亮度遮罩Phong强度。
Icon-Bug.png错误:当使用$normalmapalphaenvmapmask时,Basetexture Luminance将替换$envmap的遮罩。  [todo tested in ?]
Icon-Bug.png错误:Garry's Mod Garry's Mod中不起作用。  [todo tested in ?]
一个全局指数值。覆盖任何存在的指数遮罩。
$phongexponent2是用于CS:GO 引擎分支 CS:GO 引擎分支中的WorldVertexTransition第二材质的参数。
Shader(s): VertexLitGeneric
一个逐像素的指数贴图。在指数贴图中:
  • 红色通道: 指数遮罩(高光大小,0-255,其中0表示大高光,255表示小高光。)
  • 绿色通道: Albedo色调遮罩(仅当$phongalbedotint 1时,0-255,其中0为无色调,255为完全色调。)
  • 蓝色通道: 无作用。
  • Alpha通道: $rimlight遮罩(仅当$rimmask 1时。)
Note.png注意:LightmappedGenericWorldVertexTransition不支持$phongexponenttexture,您必须使用$phongexponent代替。
$phongexponentfactor(en) <浮点型(en)> (存在于 起源2013 多人分支军团要塞2 之中)
Shader(s): VertexLitGeneric
$phongexponenttexture中的指数乘以该参数的值。
Tip.png提示:该参数的默认值为"0.0"。然而,更合理的默认值应为"149.0"
$invertphongmask(en) <布尔值(en)> (存在于自 起源2007 以来)
Shader(s): VertexLitGeneric
反转Phong遮罩的值。
Icon-Bug.png错误:异形丛生起源2013的Shadercode中,使用此参数将反转用于$envmap的遮罩,而不是用于$phong的遮罩!  [todo tested in ?]
证实: 这种情况是否适用于所有分支?
$forcephong(en) <布尔值(en)> (存在于自 传送门2 以来)
Shader(s): VertexLitGeneric
即使在GPU等级较低并且mat_phong被禁用时,仍强制启用使用Phong的材质的Phong阴影效果。
$diffuseexp(en) <浮点型(en)> (存在于 求生之路系列求生之路系列 之中)
Shader(s): VertexLitGeneric, Infected
仅用于动态光的漫反射指数。
Note.png注意:$halflambert一起使用会大幅降低其效果。
$shinyblood(en) <整数(en)> (存在于 求生之路系列求生之路系列 之中)
Shader(s): VertexLitGeneric, Infected
根据区域的红色程度衍生Phong遮罩。仅在禁用变化时有效。
$shinybloodexponent(en) <整数(en)> (存在于 求生之路系列求生之路系列 之中)
Shader(s): VertexLitGeneric, Infected
用于上述的指数值。

亮度

Shader(s): VertexLitGeneric, LightmappedGeneric((存在于 Mapbase 之中))
Phong亮度系数。较大的值会产生更强烈的高光,适用于金属和玻璃等表面。
Shader(s): VertexLitGeneric, LightmappedGeneric((存在于 Mapbase 之中))
请参见Phong Fresnel范围。默认值为"[0 0.5 1]"
Note.png注意:如果材质同时启用了$envmap和Phong,这些Fresnel范围也会影响$envmap
Note.png注意:如果指定了phongwarptexture,它会驱动该纹理的x分量。
$phongdisablehalflambert(en) <布尔值(en)> (存在于自 异形丛生 以来) (也存在于 Garry's Mod,Mapbase 之中)
Shader(s): VertexLitGeneric
禁用强制的半朗伯阴影效果。
Note.png注意:CS:GO 引擎分支 CS:GO 引擎分支中,由于$halflambert被禁用,此参数实际上被强制启用。


颜色

$phongalbedotint(en) <布尔值(en)> (存在于自 起源2007 以来)
Shader(s): VertexLitGeneric
通过$basetexture的颜色对Phong反射进行染色。染色的程度由$phongexponenttexture的绿色通道决定。必须指定$phongexponenttexture才能使$phongalbedotint生效。
Warning.png警告:$phongalbedotint无法与$phongtint同时使用,后者会禁用该效果。
Note.png注意:$phongalbedotint通过将$basetexture的颜色乘以反射实现,而不会使原材质变暗。反射的亮度会因此减弱,因此需在Phong遮罩或使用$phongboost时加以补偿。
Note.png注意:即使材质被$color2rendercolor调整颜色,$phongalbedotint仍会使用$basetexture的原始颜色来染色高光。
一个展示AlbedoTint效果的模型示例。
$phongalbedoboost(en) <浮点型(en)> (存在于自 反恐精英:全球攻势 以来) (也存在于 Garry's Mod 之中)
Shader(s): VertexLitGeneric
Phong Albedo亮度增强因子,范围为0-255。
Note.png注意:这会乘以$phongalbedotint应用到Phong上的染色。
Icon-Bug.png错误:当使用$detail时,此功能无效。  [todo tested in ?]
Hunter模型在使用$phongwarptexture前后的对比,展示其对Phong反射的影响。
$phongtint(en) <RGB矩阵(en)> (存在于自 起源2007 以来)
Shader(s): VertexLitGeneric
对Phong反射进行颜色染色。
Warning.png警告:如果同时使用$phongtint$phongalbedotint,前者会覆盖后者的效果。
Note.png注意:也会对$rimlight进行染色。
$phongwarptexture的坐标分解:计算的坐标、纹理和结果。
$phongwarptexture(en) <texture(en)> (存在于自 起源2007 以来)
Shader(s): VertexLitGeneric
用于创建虹彩效果,例如在《第二章》的Hunter中体现的效果。
高光会与纹理相乘。采样像素的坐标如下:
x: 1 - (距离高光中心的距离)
y: 1 - (由Phong Fresnel范围计算的Fresnel分量)
Note.png注意:禁用初始的phongfresnelranges遮罩
Icon-Bug.png错误:求生之路2 求生之路2中无效。  [todo tested in ?]
反恐精英:全球攻势 反恐精英:全球攻势中使用tile/hr_t/inferno/tile_a的刷子Phong效果。注意阴影区域完全缺乏反射。


刷子着色器参数

(存在于 CS:GO 引擎分支 之中)(也存在于 Garry's Mod 之中)
Shader(s): LightmappedGeneric, WorldVertexTransition
第一个值控制遮罩中光亮和暗区域之间的对比度,第二个值控制整体亮度。
$phongmaskcontrastbrightness2 是用于WorldVertexTransition的第二个材质。
待完善: 找出这两个值的范围。
Shader(s): LightmappedGeneric, WorldVertexTransition
前3个值控制颜色染色,第四个值控制亮度。第四个值可以超过1,但影响的是整个纹理的亮度,而不是仅仅高光。
$phongamount2 是用于WorldVertexTransition的第二个材质。
Shader(s): LightmappedGeneric, WorldVertexTransition
允许$basetexture和/或$basetexture2为Phong高光染色。

控制命令

控制台变量/命令 参数或默认值 描述符 效果
mat_phong bool 禁用或启用Phong阴影。默认值为1。

另请参阅

外部链接