Zh/$phong: Difference between revisions
< Zh
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(10 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LanguageBar}} | ||
[[ | {{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}} 中同样可用,但其实现方式有所不同。}} | |||
$phong <[[bool]]> | $phong <[[bool]]> | ||
{{note| | {{note|以下参数必须全部在材质中指定,Phong阴影才能正常工作,除非在{{insurgency|4}}中。}} | ||
:{{todo| | :{{todo|记录其他不需要所有Phong参数的游戏(可能包括Portal 2及其更高版本)。}} | ||
<syntaxhighlight | |||
<syntaxhighlight> | |||
VertexLitGeneric | VertexLitGeneric | ||
{ | { | ||
$phong 1 | $phong 1 | ||
$bumpmap [ | $bumpmap [texture] // 表面的法线贴图 | ||
$phongexponent 5 | $phongexponent 5 // Phong指数值(任选其一) | ||
$phongexponenttexture [ | $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|<code>$phongalbedotint</code>无法与<code>$phongtint</code>同时使用,后者会禁用该效果。}} | ||
: {{Note|<code>$phongalbedotint</code>通过将<code>$basetexture</code>的颜色乘以反射实现,而不会使原材质变暗。反射的亮度会因此减弱,因此需在Phong遮罩或使用<code>$phongboost</code>时加以补偿。}} | |||
: {{Note|即使材质被<code>$color2</code>或<code>rendercolor</code>调整颜色,<code>$phongalbedotint</code>仍会使用<code>$basetexture</code>的原始颜色来染色高光。}}|since={{src07}}|shaders=VertexLitGeneric}} | |||
[[File:Albedotint example.jpg|thumb|200px|一个展示AlbedoTint效果的模型示例。]] | |||
{{MatParamDef|$phongalbedoboost|float|Phong Albedo亮度增强因子,范围为0-255。 | |||
< | : {{note|这会乘以<code>$phongalbedotint</code>应用到Phong上的染色。}} | ||
: {{bug|当使用[[$detail]]时,此功能无效。}}|since={{csgo}}|also={{gmod}}|shaders=VertexLitGeneric}} | |||
{{ | [[File:Phongwarp example.png|thumb|200px|Hunter模型在使用<code>$phongwarptexture</code>前后的对比,展示其对Phong反射的影响。]] | ||
{{MatParamDef|$phongtint|RGB矩阵|对Phong反射进行颜色染色。 | |||
: {{Warning|如果同时使用<code>$phongtint</code>和<code>$phongalbedotint</code>,前者会覆盖后者的效果。}} | |||
{{ | : {{note|也会对{{ent|$rimlight}}进行染色。}}|since={{src07}}|shaders=VertexLitGeneric}} | ||
[[File:Phongwarp_coordinate_guide.png|thumb|200px|<code>$phongwarptexture</code>的坐标分解:计算的坐标、纹理和结果。]] | |||
{{bug| | {{MatParamDef|$phongwarptexture|texture|用于创建虹彩效果,例如在《第二章》的[[npc_hunter|Hunter]]中体现的效果。 | ||
| | : 高光会与纹理相乘。采样像素的坐标如下: | ||
:x: 1 - (距离高光中心的距离) | |||
: | :y: 1 - (由[[Phong materials#Phong Fresnel ranges|Phong Fresnel范围]]计算的Fresnel分量) | ||
: {{note|禁用初始的<code>phongfresnelranges</code>遮罩}} | |||
: {{bug|在{{l4d2|4}}中无效。}}|since={{src07}}|shaders=VertexLitGeneric}} | |||
[[File:Brush_phong.jpg|thumb|200px|在{{csgo|2}}中使用tile/hr_t/inferno/tile_a的刷子Phong效果。注意阴影区域完全缺乏反射。]] | |||
:{{ | |||
{{ | |||
{{ | |||
| | |||
{{ | |||
{{ | |||
{{ | |||
=== | === 刷子着色器参数 === | ||
{{ | :{{csgobranch|only}}{{also|{{gmod}}}} | ||
: {{ | {{MatParamDef|$phongmaskcontrastbrightness|and=$phongmaskcontrastbrightness2|vector2|第一个值控制遮罩中光亮和暗区域之间的对比度,第二个值控制整体亮度。 | ||
: <code>$phongmaskcontrastbrightness2</code> 是用于<code>WorldVertexTransition</code>的第二个材质。 | |||
: {{todo|找出这两个值的范围。}}|shaders=LightmappedGeneric, WorldVertexTransition}} | |||
{{ | {{MatParamDef|$phongamount|and=$phongamount2|vector4|前3个值控制颜色染色,第四个值控制亮度。第四个值可以超过1,但影响的是整个纹理的亮度,而不是仅仅高光。 | ||
: <code>$phongamount2</code> 是用于<code>WorldVertexTransition</code>的第二个材质。|shaders=LightmappedGeneric, WorldVertexTransition}} | |||
{{MatParamDef|$phongbasetint|and=$phongbasetint2|float|允许<code>$basetexture</code>和/或<code>$basetexture2</code>为Phong高光染色。|shaders=LightmappedGeneric, WorldVertexTransition}} | |||
== | == 控制命令 == | ||
{{ | {{varcom|start}} | ||
{{varcom|mat_phong||bool|禁用或启用Phong阴影。默认值为1。}} | |||
{{varcom|end}} | |||
{{ | |||
{{ | |||
== | == 另请参阅 == | ||
{{ | * [[Phong materials]] | ||
* {{ent|$envmap}}(环境贴图) | |||
* {{ent|$lightwarptexture}} | |||
* {{ent|$rimlight}} | |||
== | == 外部链接 == | ||
* [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|静态模型]] | |||
* [https://share.substance3d.com/libraries/6595 SubstancePainter Source Engine Complex Phong Shader] - 提供Substance Painter对Source引擎的复杂Phong着色器 | |||
[[Category:Shader parameters|p]][[Category:VMT Lighting]] | |||
[[Category:Material System]] | |||
* [https://tf2maps.net/threads/phong-on-brushes-the-hacky-way.26765 $Phong on brushes*: The Hacky Way | |||
*[https://share.substance3d.com/libraries/6595 SubstancePainter Source Engine Complex Phong Shader] |
Latest revision as of 11:50, 23 August 2025
$phong
是一个用于着色器 VertexLitGeneric 的材质着色器 参数,可在所有的 起源 游戏,自从
起源2006 以来中使用。
此参数同样适用于 LightmappedGeneric 和 WorldVertexTransition shaders,并在所有 反恐精英:全球攻势 及以后的游戏中可用(也存在于
之中)。它通过一个纹理控制每个 texel 的强度,提供了
diffuse reflection 的低强度反射以及
specular highlight 的峰值高光。详细说明请参见 Phong materials。

LightmappedGeneric
和 WorldVertexTransition
的 Phong 着色仅在 



LightmappedGeneric
的 Phong 着色在 
$phong <bool>


- 待完善: 记录其他不需要所有Phong参数的游戏(可能包括Portal 2及其更高版本)。
VertexLitGeneric
{
$phong 1
$bumpmap [texture] // 表面的法线贴图
$phongexponent 5 // Phong指数值(任选其一)
$phongexponenttexture [texture] // 控制Phong指数的纹理(任选其一)
$phongboost 1.0 // 高光强度的倍增系数
$phongfresnelranges "[0 0.5 1]" // 控制反射强度的菲涅耳范围设置
}
遮罩

- 使用$selfillumfresnel而不使用$normalmapalphaenvmapmask时,$envmap将使用$basetexture的alpha通道作为遮罩。
- 使用$selfillumfresnel并启用$normalmapalphaenvmapmask时,$envmap将乘以
0.0f
,实际上禁用了该效果! - 当不使用$selfillumfresnel时,$envmap所用的遮罩将是$basetexture的alpha通道,除非也使用了$normalmapalphaenvmapmask。
- 如果使用了$normalmapalphaenvmapmask,则将使用$bumpmap的alpha通道作为Phong遮罩,但使用
$basemapalphaphongmask
或$basemapluminancephongmask
将会覆盖此行为。
Shader(s): VertexLitGeneric
使用$basetexture的alpha通道作为Phong遮罩,而不是
警告:与$normalmapalphaenvmapmask一起使用时,将覆盖$envmap所用的遮罩为$basetexture的alpha通道内容!
警告:
Garry's Mod 如果同时使用$normalmapalphaenvmapmask、$envmap和$basemapalphaphongmask,则
$bumpmap
的alpha通道。



$phong
和$envmap将同时被$basemapalphaphongmask
alpha通道和$normalmapalphaenvmapmask alpha通道遮罩。
Shader(s): VertexLitGeneric
基于
错误:当使用$normalmapalphaenvmapmask时,Basetexture Luminance将替换$envmap的遮罩。 [todo tested in ?]
错误:在
Garry's Mod中不起作用。 [todo tested in ?]
$basetexture
的亮度遮罩Phong强度。



一个全局指数值。覆盖任何存在的指数遮罩。
$phongexponent2
是用于CS:GO 引擎分支中的
WorldVertexTransition
第二材质的参数。
Shader(s): VertexLitGeneric
一个逐像素的指数贴图。在指数贴图中:
- 红色通道: 指数遮罩(高光大小,0-255,其中0表示大高光,255表示小高光。)
- 绿色通道: Albedo色调遮罩(仅当
$phongalbedotint 1
时,0-255,其中0为无色调,255为完全色调。) - 蓝色通道: 无作用。
- Alpha通道: $rimlight遮罩(仅当
$rimmask 1
时。)
注意:
LightmappedGeneric
和WorldVertexTransition
不支持$phongexponenttexture
,您必须使用$phongexponent
代替。
Shader(s): VertexLitGeneric
将
提示:该参数的默认值为
$phongexponenttexture
中的指数乘以该参数的值。
"0.0"
。然而,更合理的默认值应为"149.0"
。
Shader(s): VertexLitGeneric
Shader(s): VertexLitGeneric
即使在GPU等级较低并且
mat_phong
被禁用时,仍强制启用使用Phong的材质的Phong阴影效果。
Shader(s): VertexLitGeneric, Infected
仅用于动态光的漫反射指数。
注意:与$halflambert一起使用会大幅降低其效果。

Shader(s): VertexLitGeneric, Infected
根据区域的红色程度衍生Phong遮罩。仅在禁用变化时有效。
Shader(s): VertexLitGeneric, Infected
用于上述的指数值。
亮度
$phongboost <浮点型 >
Shader(s): VertexLitGeneric, LightmappedGeneric((仅存在于 
Phong亮度系数。较大的值会产生更强烈的高光,适用于金属和玻璃等表面。
请参见Phong Fresnel范围。默认值为
"[0 0.5 1]"
。
注意:如果材质同时启用了
$envmap
和Phong,这些Fresnel范围也会影响$envmap
。注意:如果指定了
phongwarptexture
,它会驱动该纹理的x分量。
Shader(s): VertexLitGeneric
禁用强制的半朗伯阴影效果。
注意:在
CS:GO 引擎分支中,由于


$halflambert
被禁用,此参数实际上被强制启用。
颜色
Shader(s): VertexLitGeneric
通过
$basetexture
的颜色对Phong反射进行染色。染色的程度由$phongexponenttexture
的绿色通道决定。必须指定$phongexponenttexture
才能使$phongalbedotint
生效。
警告:
$phongalbedotint
无法与$phongtint
同时使用,后者会禁用该效果。注意:
$phongalbedotint
通过将$basetexture
的颜色乘以反射实现,而不会使原材质变暗。反射的亮度会因此减弱,因此需在Phong遮罩或使用$phongboost
时加以补偿。注意:即使材质被
$color2
或rendercolor
调整颜色,$phongalbedotint
仍会使用$basetexture
的原始颜色来染色高光。
Shader(s): VertexLitGeneric
Shader(s): VertexLitGeneric
对Phong反射进行颜色染色。
警告:如果同时使用
$phongtint
和$phongalbedotint
,前者会覆盖后者的效果。注意:也会对$rimlight进行染色。
Shader(s): VertexLitGeneric
用于创建虹彩效果,例如在《第二章》的Hunter中体现的效果。
- 高光会与纹理相乘。采样像素的坐标如下:
- x: 1 - (距离高光中心的距离)
- y: 1 - (由Phong Fresnel范围计算的Fresnel分量)
注意:禁用初始的
phongfresnelranges
遮罩

在
反恐精英:全球攻势中使用tile/hr_t/inferno/tile_a的刷子Phong效果。注意阴影区域完全缺乏反射。

刷子着色器参数
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。 |
另请参阅
外部链接
- $Phong on brushes*: The Hacky Way - TF2maps.net上的指南,解释了如何在CS:GO之前的游戏中伪造$Phong对刷子进行渲染。也可用于伪造在Vertex光照下进行点光源处理的静态模型
- SubstancePainter Source Engine Complex Phong Shader - 提供Substance Painter对Source引擎的复杂Phong着色器