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

Zh/$envmap: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
No edit summary
No edit summary
 
(40 intermediate revisions by 10 users not shown)
Line 1: Line 1:
[[File:Specular.jpg|thumb|250px|Specular reflections.]]
{{LanguageBar}}
{{For|the set of material parameters used to mask specular reflections via textures|[[$envmapmask]]}}
{{This is a|shader parameter|name=$envmap|engine=source}}
[[File:Specular.jpg|thumb|250px|镜面反射]]


'''<code>$envmap</code>''' [[VMT]]可以在光滑的表面产生[[wikipedia:specular reflection|镜面反射]]镜面反射由“环境反射”(特别是(反射球)[[cubemap]])生成;反射将由最近的[[env_cubemap]]实体决定. 反射不是动态的!
'''<code>$envmap</code>''' 是一个所有起源引擎游戏都可以使用的{{L|Material|材质}}{{L|Shader|着色器}}参数。可以在光滑的表面产生[[wikipedia:specular reflection|镜面反射]]。镜面反射是通过定义一张「环境反射图」(具体而言是{{L|cubemap|反射球}})来实现的;反射通常由最近的{{ent|env_cubemap}}实体决定。反射不是动态的。


另一种引擎支持的反射为 [[$phong|漫反射]] 。
起源引擎所支持的另一种反射为{{L|$phong|冯氏反射}}.


==语法==
== 语法 ==
<pre>
$envmap env_cubemap
</pre>


$envmap env_cubemap
「env_cubemap」最为常用。当地图编译时,它将通知{{L|VBSP}}选择最近的{{ent|env_cubemap}}实体。你也可以使用一个手动创建的静态反射图像充当反射。


"env_cubemap"是一个常用的实体,当地图编译时,他将提示[[VBSP]]选择最近的[[env_cubemap]].它也可以使用一个已被手动渲染好的静态反射图像.
{{note|大多数反射材质在作为覆盖或印花材质时将不会呈现反射。原因不明。}}


{{note|大多数反射材质作为屏幕覆盖材质或海报喷漆时将无法反射.原因不明。}}
== 创建一个自定义静态反射材质 ==


==创建一个自定义的静态反射材质==
有些情况下会用到自定义的反射材质,一些V社的模型中也有所使用。


Creating a custom cubemap texture might be required for some circumstances and is used occasionally in some Valve models.
=== 在VTFLib中的使用方法 ===


=== In VTFLib===
为了使反射球运行,你需要六个面的独立的纹理,且方向要正确,才能在起源引擎中正常显示。所以有些面要进行顺/逆时针旋转。在定向前每个面都要进行水平镜像。


For this to work you will need to have the 6 sides of the cubemap saved as individual textures in the correct orientation for it to appear correctly in the Source Engine. So some faces might need to be rotated either clockwise or counter clockwise. Each face will need to be mirrored horizontally before orientation.
{{note|{{Game link|Alien Swarm}}之前的游戏需要7个面才能使反射球运行。第七个面是一张圆形的纹理,用于<code>$envmapsphere</code>参数。}}


'''这里是所需要的方向'''


'''Here is a map of the orientation required'''
{{BoxOut|float=right|width=22em|1=<strong style="font-size:1.2em;color:#fff;">注释</strong>


{{BoxOut|float=right|width=22em|
* FT=正面
1=<strong style="font-size:1.2em;color:#fff;">Explained</strong>
* BK=背面
 
* RT=
* FT=Front
* LF-
* BK=Back
* UP=
*RT=Right
* DN=
* LF-Left
* UP=UP
* DN=Down
----
----
* CW = Clockwise
* CW = 顺时针
* CCW = Counter Clockwise
* CCW = 逆时针
----
----
* 00_00_00 eg. (customcubemap_00_00_00.tga)
* 00_00_00 示范. (customcubemap_00_00_00.tga)
* 00_01_00 eg. (customcubemap_00_01_00.tga)
* 00_01_00 示范. (customcubemap_00_01_00.tga)
* 00_02_00 eg. (customcubemap_00_02_00.tga)
* 00_02_00 示范. (customcubemap_00_02_00.tga)
}}
}}
https://dl.dropbox.com/u/10798900/Pictures/tut/orientation_convention_source.png


[[File:Cubemap_T_assembly_guide.png|thumb]]


Once you have all the image sides ready you can just import them all into VTFEdit and select "Environmetal Map"
一旦你准备好了所有方向的图片,你便可以将他们放入VTFEDIT中,并选择"Environmetal Map"


https://dl.dropbox.com/u/10798900/Pictures/tut/cubemap_tut1.jpg
[[File:Cubemap_tut1_cra0.png|thumb]]


Then just save it all as a .vtf file and use it in your VMT like so
然后将他们保存为VTF格式,并在你的VMT文件中输入以下内容:


<source>
<pre>
"$Envmap"            "models/cra0kalo/ct_swat/eyeglint_cubemap"    // Reflection environment map static
"$Envmap"            "models/cra0kalo/ct_swat/eyeglint_cubemap"    // Reflection environment map static
</source>
</pre>


=== In VTEX===
=== 在VTEX中的使用方法 ===


VTEX will automatically mirror and orient your faces, you need only to provide correctly named textures. Name each file something like envmap001a*.tga, where * is put '''BK, FT, LF, RT, UP, or DN'''. If you took a cubemap screenshot in-game, this step will already by done, but to make them work properly with Vtex.exe you must use HDRShop (but before you need to change textures format to BMP, because HDRShop can only work with that kind of format) and then covert them to PFM files format.
{{L|Vtex (Source 1)|Vtex}}会自动反射并纠正贴图面的方向,你只需要提供正确的材质名称。每个文件名大概像这样:envmap001a*.tga, 你应将*替换为 '''BK, FT, LF, RT, UP, DN'''。如果你在游戏中截取到了反射截图,那么本步骤就完成了,但为了使他们能在Vtex上正常工作,你必须使用HDRshop(但在此之前你应该将材质格式转换为BMP,因为HDRshop只能识别这种格式)并将他们转换为PFM格式。


{{todo|What axis does each direction relate to?}}
{{todo|(回忆)每个方向对应的轴线是什么?}}


http://i.imgur.com/pa7lnGk.jpg
http://i.imgur.com/pa7lnGk.jpg


Create a text file the same name as your textures (e.g. envmap001a.txt). If building for HDR write in the following, otherwise leave it blank:
创建一个和你的材质名相同的文本(示范:envmap001a.txt)。若你要渲染HDR,请输入以下内容,否则请留空:


<code>'''pfm 1'''<br /></code>
<code>'''pfm 1'''<br /></code>
Line 68: Line 72:
<code>'''nocompress 1'''<br /></code>
<code>'''nocompress 1'''<br /></code>


Put these files into materialsrc and then just drag-n-drop .txt file into vtex.exe and you should end up with a working cubemap! HDR envmaps will be named like envmap001a.hdr.vtf, and only need to exist to work.
将这些文件放入materialsrc(文件夹)并拖拽TXT文件到vtex.exe中,然后你便能得到一个正常工作的反射贴图。HDR环境贴图的名字将会像envmap001a.hdr.vtf这样, 并依赖其工作。


== Additional Parameters ==
== 参数与效果 ==


; <code>$envmapmask <texture></code>
{{MatParamDef|$envmapmask|纹理|见{{ent|$envmapmask}}。一个决定每个{{L|texel|纹理元素}}反射率的{{L|VTF}}纹理。}}
: See <code>[[$envmapmask]]</code>. A [[VTF]] file that determines per-[[texel]] reflection intensity.
{{MatParamDef|$envmaptint|RGB矩阵|控制反射率的{{L|RGB|红、绿、蓝}}通道。任何正数皆可使用。默认值为 <code>"[1 1 1]"</code>,即100%强度。}}
; <code>$envmaptint "[<red [[float]]> <green float> <blue float>]"</code>
{{note|''必须''使用引号,因为值中含有空格。}}
: Controls the intensity of the reflection's [[RGB|red, green and blue]] color channels. Any positive number can be used. Default is <code>"[1 1 1]"</code>, which means 100% intensity. {{note|You ''must'' use quotemarks, as there are space characters within the value.}} {{tip|This command is often used to dim the brightness of a specular reflection without the overhead of an <code>$envmapmask</code>.}}
{{tip|这条命令常被用于降低镜面反射的亮度而无需修改<code>$envmapmask</code>}}
; <code>$envmapcontrast <[[normal]]></code>
{{MatParamDef|$envmapcontrast|单位浮点|控制反射的[[Wikipedia:Contrast (vision)|对比度]]。0为自然对比度,1是完全平方的对比度(即颜色×颜色)。}}
: Controls the [[Wikipedia:Contrast (vision)|contrast]] of the reflection. 0 is natural contrast, while 1 is the full squaring of the color (i.e. color*color).
{{tip|使用高对比度能减少相对黑暗的区域,并增加「热点」。}}
: {{tip|Use higher contrasts to diminish relatively darker areas and increase "hot spots".}}{{note|Will not work when [[Phong]] is enabled.}}
{{note|使用{{L|Phong|冯氏}}的时候本命令无效。}}
; <code>$envmapsaturation <normal></code>
{{MatParamDef|$envmapsaturation|单位浮点|控制反射的饱和度。0为灰阶,1是自然饱和度。}}
: Controls the colour saturation of the reflection. 0 is greyscale, while 1 is natural saturation.{{note|Will not work when [[Phong]] is enabled.}}
{{note|对模型使用{{L|Phong|冯氏}}的时候本命令无效。}}
; <code>$envmapframe <[[int]]></code>
{{MatParamDef|$envmapframe|整数|动态反射的起始帧。}}
: The frame to start an animated cubemap on.
{{MatParamDef|$envmapmode|整数|MATERIAL_VAR_ENVMAPMODE = (1 << 25)|deprecated=1}}
; <code>$envmapmode <int?></code>
{{MatParamDef|$basetexturenoenvmap|and=$basetexture2noenvmap|布尔值|用于双{{L|albedo|漫反射图}}的材质,使其中一个不反射。参见{{ent|$basetexture}}和{{ent|$basetexture2}}</code>。|dx9=1}}
: Depreciated  MATERIAL_VAR_ENVMAPMODE = (1 << 25), // OBSOLETE
{{MatParamDef|$envmapoptional|选项|选择进行渲染的最老的{{L|DirectX Version|DirectX版本}}。选项有:
; <code>$basetexturenoenvmap <[[bool]]></code>
*<code>80</code> (DirectX 8)
; <code>$basetexture2noenvmap <bool></code>
*<code>81</code> (DirectX 8.1)
: Probably used for materials with two [[albedo]]s, to make one or the other matte. Require DirectX 9; see also <code>[[$basetexture]]</code> and <code>[[$basetexture2]]</code>.
*<code>90</code> (DirectX 9)
;<code>$envmapoptional <choices></code>
*<code>95</code> (DirectX 9使用Shader Model 3)}}
: Sets the oldest DirectX version that should draw the reflection. Choose from:
{{MatParamDef|$envmapsphere|布尔值|决定一个材质的反射是否为反射球(spheremap)而不是反射方块(cubemap)。设置为1则使用反射球。{{As}}以后无效。|deprecated=1}}
:*<code>80</code> (DirectX 8)
{{MatParamDef|$fresnelreflection|浮点|添加菲涅尔效应。0为关闭,1为全开。高于1.0的值会使效果倍增。|since=EP1|dx9=1}}
:*<code>81</code> (DirectX 8.1)
{{note|只能用于<code>LightmappedGeneric</code><code>WorldVertexTransition</code>。}}
:*<code>90</code> (DirectX 9)
{{MatParamDef|$envmapfresnel|浮点|同<code>$fresnelreflection</code>,用于<code>VertexLitGeneric</code>。|since=EP2|dx9=1}}
:*<code>95</code> (DirectX 9 with Shader Model 3)
{{MatParamDef|$envmaplightscale|浮点|允许表面的光影贴图被用作反射的附加遮罩。0-1的数值决定了遮罩程度; 高于1的值也可以,但似乎会造成相反的影响。|since=CSGO}}  
; <code>$envmapsphere <bool></code>
{{MatParamDef|$envmapanisotropy|布尔值|扭曲反射,把顶部「推」向下。|since=CSGO}}  
: Determines whether the material's envmap should be a spheremap (deprecated) instead of a cubemap. Set this to 1 to use a spheremap.
{{MatParamDef|$envmapanisotropyscale|单位浮点|扭曲反射的量。|since=CSGO}}  
; <code>$envmapfresnel <float></code> ([[Left 4 Dead 2]] and [[Source Filmmaker]] only)
: Adds a fresnel effect to the reflection. Surfaces facing the viewer are less reflective than surfaces facing sideways. Dependent on [[Phong]] fresnel ranges. Effect becomes multiplied with values higher than 1.0.
{{todo|Confirm other engine branches for envmapfresnel.}}
; <code>$envmapanisotropy <bool></code> {{CSGO add}}
; <code>$envmapanisotropyscale <float></code> {{CSGO add}}
: Warps the reflection, "pushing" the top downward.
; <code>$envmaplightmapscale</code> {{CSGO add}}
: Allows the surface's lightmap to be used as an additional mask on the reflections. A value between 0 and 1 determines the degree to which it is masked; values above 1 are permitted but seem to start actually inverting the effect.


== Console commands ==
== 控制台命令 ==


;<code>[[buildcubemaps]]</code>
<code>{{L|buildcubemaps}}</code>
:Generates cubemaps for use in materials. If this isn't run, objects will reflect the skybox (OB) or have an invalid reflection, white in Ep1 and pink checkerboards in MP.
:为材质创建反射。如何不运行这一命令,则会直接反射天空或显示错误材质,在EP1中为白色,在多人游戏中为紫黑格子。
;<code>r_showenvcubemap <[[bool]]></code>
<code>r_showenvcubemap <布尔值></code>
:Debug command to display cubemaps on all dynamic objects at full intensity. It was used to create the image at the start of this article.
:一个展示所有动态物体在高强度反射下的状态的命令。本文开头的图片就是使用这一命令得到的。


== See Also ==
== 参见 ==


* [[$envmapmask]] (specular mask)
* {{L|$envmapmask}}(镜面反射遮罩)
* [[$phong]] (for diffuse reflection)
* {{L|$phong}}(漫反射)
* [[Cubemap]]
* {{L|Cubemap}}


[[Category:List of Shader Parameters|E]]
{{ACategory|Shader parameters|e}}
[[Category:VMT Reflections]]
{{ACategory|VMT Reflections}}

Latest revision as of 12:16, 23 August 2025

English (en)Русский (ru)中文 (zh)Translate (Translate)
关于 the set of material parameters used to mask specular reflections via textures, 见 $envmapmask.

$envmap是一个材质(en)着色器(en)参数,可在所有的 起源 起源 游戏中使用。

镜面反射

$envmap 是一个所有起源引擎游戏都可以使用的材质(en)着色器(en)参数。可以在光滑的表面产生镜面反射。镜面反射是通过定义一张「环境反射图」(具体而言是反射球(en))来实现的;反射通常由最近的env_cubemap实体决定。反射不是动态的。

起源引擎所支持的另一种反射为冯氏反射(en).

语法

$envmap env_cubemap

「env_cubemap」最为常用。当地图编译时,它将通知VBSP(en)选择最近的env_cubemap实体。你也可以使用一个手动创建的静态反射图像充当反射。

Note.png注意:大多数反射材质在作为覆盖或印花材质时将不会呈现反射。原因不明。

创建一个自定义静态反射材质

有些情况下会用到自定义的反射材质,一些V社的模型中也有所使用。

在VTFLib中的使用方法

为了使反射球运行,你需要六个面的独立的纹理,且方向要正确,才能在起源引擎中正常显示。所以有些面要进行顺/逆时针旋转。在定向前每个面都要进行水平镜像。

Note.png注意:异形丛生 Alien Swarm 之前的游戏需要7个面才能使反射球运行。第七个面是一张圆形的纹理,用于$envmapsphere参数。

这里是所需要的方向

注释

  • FT=正面
  • BK=背面
  • RT=右
  • LF-左
  • UP=上
  • DN=下

  • CW = 顺时针
  • CCW = 逆时针

  • 00_00_00 示范. (customcubemap_00_00_00.tga)
  • 00_01_00 示范. (customcubemap_00_01_00.tga)
  • 00_02_00 示范. (customcubemap_00_02_00.tga)
Cubemap T assembly guide.png

一旦你准备好了所有方向的图片,你便可以将他们放入VTFEDIT中,并选择"Environmetal Map"

Cubemap tut1 cra0.png

然后将他们保存为VTF格式,并在你的VMT文件中输入以下内容:

"$Envmap"             "models/cra0kalo/ct_swat/eyeglint_cubemap"    // Reflection environment map static

在VTEX中的使用方法

Vtex(en)会自动反射并纠正贴图面的方向,你只需要提供正确的材质名称。每个文件名大概像这样:envmap001a*.tga, 你应将*替换为 BK, FT, LF, RT, UP, 或 DN。如果你在游戏中截取到了反射截图,那么本步骤就完成了,但为了使他们能在Vtex上正常工作,你必须使用HDRshop(但在此之前你应该将材质格式转换为BMP,因为HDRshop只能识别这种格式)并将他们转换为PFM格式。

待完善: (回忆)每个方向对应的轴线是什么?

http://i.imgur.com/pa7lnGk.jpg

创建一个和你的材质名相同的文本(示范:envmap001a.txt)。若你要渲染HDR,请输入以下内容,否则请留空:

pfm 1
pfmscale 1
nocompress 1

将这些文件放入materialsrc(文件夹)并拖拽TXT文件到vtex.exe中,然后你便能得到一个正常工作的反射贴图。HDR环境贴图的名字将会像envmap001a.hdr.vtf这样, 并依赖其工作。

参数与效果

$envmapmask。一个决定每个纹理元素(en)反射率的VTF(en)纹理。
控制反射率的红、绿、蓝(en)通道。任何正数皆可使用。默认值为 "[1 1 1]",即100%强度。
Note.png注意:必须使用引号,因为值中含有空格。
Tip.png提示:这条命令常被用于降低镜面反射的亮度而无需修改$envmapmask
控制反射的对比度。0为自然对比度,1是完全平方的对比度(即颜色×颜色)。
Tip.png提示:使用高对比度能减少相对黑暗的区域,并增加「热点」。
Note.png注意:使用冯氏(en)的时候本命令无效。
控制反射的饱和度。0为灰阶,1是自然饱和度。
Note.png注意:对模型使用冯氏(en)的时候本命令无效。
动态反射的起始帧。
待完善: This material shader parameter has not been described.
用于双漫反射图(en)的材质,使其中一个不反射。参见$basetexture$basetexture2
选择进行渲染的最老的DirectX版本(en)。选项有:
  • 80 (DirectX 8)
  • 81 (DirectX 8.1)
  • 90 (DirectX 9)
  • 95 (DirectX 9使用Shader Model 3)
决定一个材质的反射是否为反射球(spheremap)而不是反射方块(cubemap)。设置为1则使用反射球。异形丛生以后无效。
$fresnelreflection(en) <浮点(en)> (DX9 SM2) (存在于自 EP1 以来)
添加菲涅尔效应。0为关闭,1为全开。高于1.0的值会使效果倍增。
Note.png注意:只能用于LightmappedGenericWorldVertexTransition
$envmapfresnel(en) <浮点(en)> (DX9 SM2) (存在于自 EP2 以来)
$fresnelreflection,用于VertexLitGeneric
$envmaplightscale(en) <浮点(en)> (存在于自 CSGO 以来)
允许表面的光影贴图被用作反射的附加遮罩。0-1的数值决定了遮罩程度; 高于1的值也可以,但似乎会造成相反的影响。
$envmapanisotropy(en) <布尔值(en)> (存在于自 CSGO 以来)
扭曲反射,把顶部「推」向下。
$envmapanisotropyscale(en) <单位浮点(en)> (存在于自 CSGO 以来)
扭曲反射的量。

控制台命令

buildcubemaps(en)

为材质创建反射。如何不运行这一命令,则会直接反射天空或显示错误材质,在EP1中为白色,在多人游戏中为紫黑格子。

r_showenvcubemap <布尔值>

一个展示所有动态物体在高强度反射下的状态的命令。本文开头的图片就是使用这一命令得到的。

参见