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

Zh/$envmapmask: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
No edit summary
(deepseek translation)
Line 1: Line 1:
{{wip}}{{translating}}
{{Machine Translation}}
{{LanguageBar}}
{{LanguageBar}}


{{toc-right}}
{{toc-right}}


{{this is a|shader parameter|name=$envmapmask}} It defines a '''specular mask''' which affects how strongly each pixel of a material reflects light from the {{ent|$envmap}}. The mask should be a grayscale image in which entirely reflective areas are white and entirely matte areas are black. For diffuse type specularity which does not rely on <code>$envmap</code>, see {{ent|$phong}}.
{{this is a|shader parameter|name=$envmapmask}} 它定义了'''高光遮罩''',用于控制材质的每个像素对{{ent|$envmap}}光线的反射强度。遮罩应为灰度图像,其中纯白区域表示完全反射,纯黑区域表示无反射。对于不依赖<code>$envmap</code>的漫反射类型高光,请参见{{ent|$phong}}
{{bug|hidetested=1|In {{src07|2}} games, using an <code>$envmapmask</code> which is not stored in a subfolder will cause the texture to fail loading in-game.}}
{{bug|hidetested=1|{{src07|2}}引擎游戏中,若<code>$envmapmask</code>未存储在子文件夹中,将导致纹理无法在游戏中加载。}}
{{warning|<code>$envmapmask</code> will not work with materials using {{ent|$bumpmap}}/ in most situations; see [[#Alternative_methods]].
{{warning|<code>$envmapmask</code>在多数情况下无法与使用{{ent|$bumpmap}}/的材质共同作用;详见[[#替代方法]]
{{note|Exceptions:
{{note|例外情况:
* '''{{L|LightmappedReflective}}''' (uses {{ent|$normalmap}})
* '''{{L|LightmappedReflective}}'''(使用{{ent|$normalmap}}
* {{mapbase|only}} '''{{L|VertexLitGeneric}}'''
* {{mapbase|仅限}} '''{{L|VertexLitGeneric}}'''
* {{csgo|only}}'''{{L|LightmappedGeneric}}'''
* {{csgo|仅限}}'''{{L|LightmappedGeneric}}'''
}} }}
}} }}
{{warning|<code>$envmapmask</code> will not work with materials using {{ent|$phong}}, at all. By default it will use the $basetexture's alpha channel for masking the envmap.}}
{{warning|<code>$envmapmask</code>完全无法与使用{{ent|$phong}}的材质共同工作。默认情况下,它会使用$basetexture的alpha通道作为环境贴图遮罩。}}
{{note|While specular masks are traditionally greyscale, they can be colored. In such an instance, the color data will act as a per-texel $envmaptint.}}
{{note|尽管高光遮罩传统上是灰阶的,但也可使用彩色图像。此时颜色数据将作为逐像素的$envmaptint参数生效。}}


==VMT syntax example==
==VMT语法示例==


  $envmapmask <texture>
  $envmapmask <纹理路径>


  {{L|VertexLitGeneric}}
  {{L|VertexLitGeneric}}
Line 25: Line 25:
  }
  }


==Additional parameters==
==附加参数==


[[File:Scanner mask.jpg|thumb|250px|{{L|npc_cscanner}}'s mask.]]
[[File:Scanner mask.jpg|thumb|250px|{{L|npc_cscanner}}的遮罩效果]]


{{MatParam|$envmapmasktransform|matrix|
{{MatParam|$envmapmasktransform|矩阵|
: Transforms the specular mask texture.
: 用于变换高光遮罩纹理。
{{bug|Does not work on {{ent|VertexLitGeneric}}.}}
{{bug|{{ent|VertexLitGeneric}}材质上无效。}}
{{VMT UVtransform}}|dx9=1}}
{{VMT UVtransform}}|dx9=1}}
{{MatParam|$envmapmaskscale|float|Scales the specular mask by the given value. See also <code>$envmapmasktransform</code>, above.|dx8=1}}
{{MatParam|$envmapmaskscale|浮点数|按给定值缩放高光遮罩。另见上文<code>$envmapmasktransform</code>参数。|dx8=1}}
{{MatParam|$envmapmaskframe|int|The frame to start an animated specular mask on.}}
{{MatParam|$envmapmaskframe|整数|动画高光遮罩的起始帧编号。}}
====CS:GO WorldVertexTransition Parameters====
====CS:GO WorldVertexTransition专用参数====
{{MatParam|$envmapmask2|texture|Specular mask for {{ent|WorldVertexTransition}}'s second layer.|only={{csgo}}|shaders=WorldVertexTransition}}
{{MatParam|$envmapmask2|纹理|{{ent|WorldVertexTransition}}第二层的高光遮罩。|only={{csgo}}|shaders=WorldVertexTransition}}
{{MatParam|$envmapmasktransform2|matrix|Texture transformation for <code>$envmapmask2</code>.|only={{csgo}}|shaders=WorldVertexTransition}}
{{MatParam|$envmapmasktransform2|矩阵|<code>$envmapmask2</code>的纹理变换矩阵。|only={{csgo}}|shaders=WorldVertexTransition}}
{{MatParam|$envmapframe2|int|The frame to start an animated <code>$envmapmask2</code> on.|only={{csgo}}|shaders=WorldVertexTransition}}
{{MatParam|$envmapframe2|整数|动画<code>$envmapmask2</code>的起始帧编号。|only={{csgo}}|shaders=WorldVertexTransition}}


==Alternative methods==
==替代方法==


Rather than creating a whole new texture for a specular mask, you can embed one into the {{L|alpha channel}} of the {{ent|$basetexture}} or {{code|$bumpmap}}. Model materials with {{code|$bumpmap}} '''must''' do this. Unfortunately, it ''won't'' reduce memory usage.
无需为高光遮罩创建全新纹理,可将其嵌入{{ent|$basetexture}}{{code|$bumpmap}}{{L|alpha通道}}中。使用{{code|$bumpmap}}的模型材质'''必须'''采用此方法。但请注意,这''不会''降低内存占用。


If you do use these commands, transformations and other such parameters applied to {{code|$basetexture / $bumpmap}} will also apply to the specular mask.
若使用以下命令,应用于{{code|$basetexture / $bumpmap}}的变换及其他参数将同时影响高光遮罩。


{{MatParam|$basealphaenvmapmask|bool|Use the alpha channel of the {{code|$basetexture}} as the specular mask.}}
{{MatParam|$basealphaenvmapmask|布尔值|使用{{code|$basetexture}}的alpha通道作为高光遮罩。}}
{{note|
{{note|
* Alpha channels embedded in {{code|$basetexture}} work in reverse. Transparent areas are reflective, opaque areas are matte. This is because, say, a window texture's alpha mask would be mostly black to allow for transparency -- yet that black part of the mask would also be the most reflective part. To avoid having to duplicate a texture file simply to invert the alpha mask, you can use this material parameter instead.
* 嵌入{{code|$basetexture}}的alpha通道作用相反:透明区域反光,不透明区域哑光。这是因为(例如)窗户纹理的alpha遮罩通常为黑色以实现透明效果——而黑色遮罩区域恰好应是高反光区域。为避免仅为反转alpha遮罩而复制纹理文件,可使用此材质参数。
* The alpha channel '''''is not''''' inverted in {{src07|2}} ''and'' {{csgo|2}} for models, but the alpha channel '''''is''''' inverted for brushes!
* {{src07|2}}{{csgo|2}}中,模型的alpha通道'''不会'''反转,但笔刷材质的alpha通道''''''反转!
:* In {{src13}}, the alpha channel is only inverted for models if {{cmd|$phong}} is disabled!
:* {{src13}}中,模型的alpha通道仅在{{cmd|$phong}}禁用时反转!
* {{l4d2}} auto enables if '''$envmap''' is present. Opaque areas are reflective while transparent are matte. Set as {{L|bool|true}} to invert {{code|$basetexture}} alpha channel behaviour. This allow {{code|{{L|$bumpmap}}}} have a dedicated {{code|{{L|$phong}}}} mask, when material transparency is not needed.}}
* {{l4d2}}中若存在'''$envmap'''则自动启用。不透明区域反光,透明区域哑光。设为{{L|布尔值|true}}可反转{{code|$basetexture}}的alpha通道行为。当材质无需透明效果时,允许{{code|{{L|$bumpmap}}}}拥有独立的{{code|{{L|$phong}}}}遮罩。}}
{{bug|<ul>
{{bug|<ul>
<li> In CSGO, this parameter breaks materials using {{ent|$translucent}}. Use {{code|$envmapmask}} or {{code|$normalmapalphaenvmapmask}} instead.<br>
<li> 在CSGO中,此参数会破坏使用{{ent|$translucent}}的材质。请改用{{code|$envmapmask}}{{code|$normalmapalphaenvmapmask}}<br>
<li> In all of: {{gmod}}{{src13}}{{tf2}}{{as}}{{csgo}} on {{ent|VertexLitGeneric}} ('''Without''' {{ent|$phong}}), {{ent|WorldVertexTransition}} and {{ent|LightmappedGeneric}}, <code>$basealphaenvmapmask</code> cannot be used with {{ent|$bumpmap}}.<br>
<li> 在以下引擎中:{{gmod}}{{src13}}{{tf2}}{{as}}{{csgo}}{{ent|VertexLitGeneric}}'''未启用'''{{ent|$phong}})、{{ent|WorldVertexTransition}}{{ent|LightmappedGeneric}}材质上,<code>$basealphaenvmapmask</code>无法与{{ent|$bumpmap}}共用。<br>
<li> In all of: {{gmod}}{{src13}}{{tf2}}{{as}}{{csgo}} on {{ent|LightmappedGeneric}} and {{ent|WorldVertexTransition}}, <code>$basealphaenvmapmask</code> cannot be used with {{ent|$selfillum}}, {{ent|$seamless_detail}} or {{ent|$distancealpha}}.<br>
<li> 在以下引擎中:{{gmod}}{{src13}}{{tf2}}{{as}}{{csgo}}{{ent|LightmappedGeneric}}{{ent|WorldVertexTransition}}材质上,<code>$basealphaenvmapmask</code>无法与{{ent|$selfillum}}{{ent|$seamless_detail}}{{ent|$distancealpha}}共用。<br>
<li> In {{csgo}}, on {{ent|LightmappedGeneric}} and {{ent|WorldVertexTransition}}, <code>$basealphaenvmapmask</code> cannot be used with {{L|$detail#Parameters and Effects|$detailblendmode}} "9" or {{ent|$envmapanisotropy}}.<br>
<li> {{csgo}}{{ent|LightmappedGeneric}}{{ent|WorldVertexTransition}}材质上,<code>$basealphaenvmapmask</code>无法与{{L|$detail#参数与效果|$detailblendmode}} "9"{{ent|$envmapanisotropy}}共用。<br>
<li> In {{csgo}}, on {{ent|Lightmapped_4WayBlend}}, <code>$basealphaenvmapmask</code> cannot be used with {{ent|$selfillum}}.
<li> {{csgo}}{{ent|Lightmapped_4WayBlend}}材质上,<code>$basealphaenvmapmask</code>无法与{{ent|$selfillum}}共用。
<li> This cannot be used with {{ent|$bumpmap}} on {{ent|LightmappedGeneric}}
<li> {{ent|LightmappedGeneric}}材质上无法与{{ent|$bumpmap}}共用
</ul>}}
</ul>}}


<br>{{MatParam|$normalmapalphaenvmapmask|bool|Use the alpha channel of the {{code|$bumpmap}} or {{code|$normalmap}} as the specular mask.
<br>{{MatParam|$normalmapalphaenvmapmask|布尔值|使用{{code|$bumpmap}}{{code|$normalmap}}的alpha通道作为高光遮罩。
{{warning|Using this in combination with {{code|{{L|$phong|$basemapalphaphongmask}}}} or {{code|{{L|$phong|$basemapluminancephongmask}}}} will set the mask used for the {{ent|$envmap}} to be those instead. <br>
{{warning|若同时使用{{code|{{L|$phong|$basemapalphaphongmask}}}}{{code|{{L|$phong|$basemapluminancephongmask}}}},将导致{{ent|$envmap}}的遮罩被后者覆盖。<br>
'''There are additional caveats''' when using {{ent|$phong}}. See its entry for more information about possible issues.}}
使用{{ent|$phong}}时'''存在额外限制''',请查阅其条目了解潜在问题。}}
}}
}}
{{bug|
{{bug|
* In all of: {{gmod}}{{src13}}{{tf2}}{{as}}{{csgo}} on {{ent|VertexLitGeneric}} ('''Without''' {{ent|$phong}}), <code>$normalmapalphaenvmapmask</code> cannot be used with {{L|Glowing_Textures#.24selfillum|$selfillumfresnel}}.<br>
* 在以下引擎中:{{gmod}}{{src13}}{{tf2}}{{as}}{{csgo}}{{ent|VertexLitGeneric}}'''未启用'''{{ent|$phong}})材质上,<code>$normalmapalphaenvmapmask</code>无法与{{L|发光纹理#.24selfillum|$selfillumfresnel}}共用。<br>
:{{note| Using <code>$normalmapalphaenvmapmask</code> with {{ent|$phong}} and {{L|Glowing_Textures#.24selfillum|$selfillumfresnel}} has special caveats that should be considered. Check {{ent|$phong}} for  for more information.}}
:{{note| {{ent|$phong}}{{L|发光纹理#.24selfillum|$selfillumfresnel}}共同作用时使用<code>$normalmapalphaenvmapmask</code>有特殊限制,请查阅{{ent|$phong}}条目获取详情。}}
* In {{csgo}}, on {{ent|LightmappedGeneric}} and {{ent|WorldVertexTransition}}, {{code|{{L|$normalmapalphaenvmapmask}}}} cannot be used with {{L|$detail#Parameters and Effects|$detailblendmode}} "9" or {{ent|$envmapanisotropy}}.}}<br>
* {{csgo}}{{ent|LightmappedGeneric}}{{ent|WorldVertexTransition}}材质上,{{code|{{L|$normalmapalphaenvmapmask}}}}无法与{{L|$detail#参数与效果|$detailblendmode}} "9"{{ent|$envmapanisotropy}}共用。}}<br>
<br>{{MatParam|$selfillum_envmapmask_alpha|float|Use the alpha channel of the {{code|$envmapmask}} as the {{ent|$selfillum}} mask instead of {{code|$basetexture}}'s alpha.<br>
<br>{{MatParam|$selfillum_envmapmask_alpha|浮点数|使用{{code|$envmapmask}}的alpha通道替代{{code|$basetexture}}的alpha作为{{ent|$selfillum}}遮罩。<br>
: {{bug|This Parameter replaces {{code|$selfillum}}. If both are used it will result in an error. The material will not render.}}
: {{bug|此参数会取代{{code|$selfillum}}。若两者共用将导致错误,材质无法渲染。}}
: {{warning|Only on {{ent|VertexLitGeneric}} - Note that <code>$envmapmask</code> does not work '''with''' {{ent|$bumpmap}} or {{ent|$phong}} on VertexLitGeneric.}}
: {{warning|仅适用于{{ent|VertexLitGeneric}}材质——注意<code>$envmapmask</code>在VertexLitGeneric上'''无法'''{{ent|$bumpmap}}{{ent|$phong}}共同工作。}}
{{todo|This is not an alternative method to <code>$envmapmask</code> and in fact that parameter is required to use this. <code>Move it to Additional Parameters</code> and pray links on other pages don't break.}}}}
{{todo|此参数并非<code>$envmapmask</code>的替代方案,实际需依赖该参数。<code>应移至"附加参数"章节</code>,并确保其他页面链接不受影响。}}}}
<br>{{MatParam|$envmapmaskintintmasktexture|bool|Use the red channel of the {{ent|$tintmasktexture}} as the specular mask.|only={{csgo}}|shaders=VertexLitGeneric}}
<br>{{MatParam|$envmapmaskintintmasktexture|布尔值|使用{{ent|$tintmasktexture}}的红色通道作为高光遮罩。|only={{csgo}}|shaders=VertexLitGeneric}}


==Merging Specular Level into Normal Alpha in 3ds Max==
==在3ds Max中将高光层级合并至法线贴图Alpha通道==


To merge a Specular Level map into the Normal Map alpha, you can create a Composite Map node with the normal map in Layer 1 and the specular map in Mask 1. Then right-click the composite map, click Render Map and save this new image to file (remembering to keep the Gamma at 1.0 and using 32 bits per pixel in the save options).
要将高光层级贴图合并到法线贴图的Alpha通道,可创建复合贴图节点:法线贴图置于图层1,高光贴图置于遮罩1。右键点击复合贴图,选择"渲染贴图"并将新图像保存为文件(保存时需保持Gamma值为1.0,并选择32位/像素)。


These steps are automated in the [http://dev.wallworm.com/topic/34/alpha_spec.html Alpha Spec] tool in Wall Worm 2.72+.
Wall Worm 2.72+中的[Alpha Spec工具](http://dev.wallworm.com/topic/34/alpha_spec.html)可自动完成此流程。


==See also==
==另请参阅==
* {{L|$basetexture}}
* {{L|$basetexture}}
* {{L|$envmap}} (environment map)
* {{L|$envmap}}(环境贴图)
* {{L|$phong}} (diffuse reflection)
* {{L|$phong}}(漫反射)
* {{L|$selfillum }}
* {{L|$selfillum}}(自发光)
{{ACategory|Shader parameters|e}}
{{ACategory|Shader parameters}}
{{ACategory|VMT Reflections}}
{{ACategory|VMT Reflections}}

Revision as of 20:53, 7 August 2025

Info content.png
This page is Machine translated
It is not recommended to use machine translation without any corrections.
If the article is not corrected in the long term, it will be removed.
Also, please make sure the article complies with the alternate languages guide.(en)
English (en)Français (fr)Русский (ru)中文 (zh)Translate (Translate)

$envmapmask是一个材质(en)着色器(en)参数,可在所有的 起源 起源 游戏中使用。 它定义了高光遮罩,用于控制材质的每个像素对$envmap光线的反射强度。遮罩应为灰度图像,其中纯白区域表示完全反射,纯黑区域表示无反射。对于不依赖$envmap的漫反射类型高光,请参见$phong

Icon-Bug.png错误:起源2007 起源2007引擎游戏中,若$envmapmask未存储在子文件夹中,将导致纹理无法在游戏中加载。
Warning.png警告:$envmapmask在多数情况下无法与使用$bumpmap/的材质共同作用;详见#替代方法
Warning.png警告:$envmapmask完全无法与使用$phong的材质共同工作。默认情况下,它会使用$basetexture的alpha通道作为环境贴图遮罩。
Note.png注意:尽管高光遮罩传统上是灰阶的,但也可使用彩色图像。此时颜色数据将作为逐像素的$envmaptint参数生效。

VMT语法示例

$envmapmask <纹理路径>
VertexLitGeneric(en)
{
	$envmap(en)			env_cubemap
	$envmapmask		"props/tvscreen_test"
}

附加参数

npc_cscanner(en)的遮罩效果

$envmapmasktransform $envmapmaskscale $envmapmaskframe

CS:GO WorldVertexTransition专用参数

$envmapmask2 $envmapmasktransform2 $envmapframe2

替代方法

无需为高光遮罩创建全新纹理,可将其嵌入$basetexture$bumpmapalpha通道(en)中。使用$bumpmap的模型材质必须采用此方法。但请注意,这不会降低内存占用。

若使用以下命令,应用于$basetexture / $bumpmap的变换及其他参数将同时影响高光遮罩。

$basealphaenvmapmask

Note.png注意:
  • 嵌入$basetexture的alpha通道作用相反:透明区域反光,不透明区域哑光。这是因为(例如)窗户纹理的alpha遮罩通常为黑色以实现透明效果——而黑色遮罩区域恰好应是高反光区域。为避免仅为反转alpha遮罩而复制纹理文件,可使用此材质参数。
  • 起源2007 起源2007反恐精英:全球攻势 反恐精英:全球攻势中,模型的alpha通道不会反转,但笔刷材质的alpha通道反转!
  • 起源2013中,模型的alpha通道仅在$phong禁用时反转!
  • 求生之路2中若存在$envmap则自动启用。不透明区域反光,透明区域哑光。设为true(en)可反转$basetexture的alpha通道行为。当材质无需透明效果时,允许$bumpmap(en)拥有独立的$phong(en)遮罩。
Icon-Bug.png错误:  [todo tested in ?]


$normalmapalphaenvmapmask

Icon-Bug.png错误:
Note.png注意:$phong$selfillumfresnel(en)共同作用时使用$normalmapalphaenvmapmask有特殊限制,请查阅$phong条目获取详情。



$selfillum_envmapmask_alpha
$envmapmaskintintmasktexture

在3ds Max中将高光层级合并至法线贴图Alpha通道

要将高光层级贴图合并到法线贴图的Alpha通道,可创建复合贴图节点:法线贴图置于图层1,高光贴图置于遮罩1。右键点击复合贴图,选择"渲染贴图"并将新图像保存为文件(保存时需保持Gamma值为1.0,并选择32位/像素)。

Wall Worm 2.72+中的[Alpha Spec工具](http://dev.wallworm.com/topic/34/alpha_spec.html)可自动完成此流程。

另请参阅