Zh/$envmap

From Valve Developer Community
< Zh
Revision as of 22:30, 12 September 2015 by Dy2084 (talk | contribs)
Jump to navigation Jump to search
Specular reflections.

$envmap VMT可以在光滑的表面产生镜面反射.镜面反射由"环境反射" (特别是(反射球));反射将由最近的env_cubemap实体决定.反射不是动态(实时)的!

另一种引擎支持的反射为漫反射.

语法/结构

$envmap env_cubemap

"env_cubemap"是一个常用的实体, 当地图编译时,它将通知VBSP选择最近的env_cubemap实体. 你也可以使用一个已被手动渲染好的静态反射图像充当 反射。

Note.png注意:大多数反射材质在作为屏幕覆盖材质或海报喷漆时将不会呈现反射。原因不明。

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

有些时候,在有的模型中或其他情况下都会用到自定义的反射材质,所以要学会如何创建一个自定义反射材质

在VTFLib中的使用方法

为了材质能正常工作,你需要六个面的个体材质,且方向要正确,才可正常在引擎中显示. 所以有些面要正/逆时针旋转. 在定向前每个面都要水平反射.


这里是所需要的方向

注释

  • 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)

http://i1.tietuku.com/8bdf7cc939de44cc.png


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

http://i1.tietuku.com/421b61f2f977ef35.jpg

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

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

在VTEX中的使用方法

VTEX将会自动反射并纠正贴图面的方向,你只需要提供正确的材质名. 每个文件名大概像这样: 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 <texture>
查阅 $envmapmask. 一个决定每个纹理元素反射率的VTF文件.
$envmaptint "[<red float> <green float> <blue float>]"
控制反射率的红,绿,蓝颜色波长.任何正数皆可被使用.默认数值为 "[1 1 1]",意思是100%强度.
Note.png注意:必须 use quotemarks, as there are space characters within the value.
Tip.png提示:This command is often used to dim the brightness of a specular reflection without the overhead of an $envmapmask.
$envmapcontrast <normal>
Controls the contrast of the reflection. 0 is natural contrast, while 1 is the full squaring of the color (i.e. color*color).
Tip.png提示:Use higher contrasts to diminish relatively darker areas and increase "hot spots".
Note.png注意:Will not work when Phong is enabled.
$envmapsaturation <normal>
Controls the colour saturation of the reflection. 0 is greyscale, while 1 is natural saturation.
Note.png注意:Will not work when Phong is enabled.
$envmapframe <int>
The frame to start an animated cubemap on.
$envmapmode <int?>
Depreciated MATERIAL_VAR_ENVMAPMODE = (1 << 25), // OBSOLETE
$basetexturenoenvmap <bool>
$basetexture2noenvmap <bool>
Probably used for materials with two albedos, to make one or the other matte. Require DirectX 9; see also $basetexture and $basetexture2.
$envmapoptional <choices>
Sets the oldest DirectX version that should draw the reflection. Choose from:
  • 80 (DirectX 8)
  • 81 (DirectX 8.1)
  • 90 (DirectX 9)
  • 95 (DirectX 9 with Shader Model 3)
$envmapsphere <bool>
Determines whether the material's envmap should be a spheremap (deprecated) instead of a cubemap. Set this to 1 to use a spheremap.
$envmapfresnel <float> (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.
待完善: Confirm other engine branches for envmapfresnel.
$envmapanisotropy <bool> Template:CSGO add
$envmapanisotropyscale <float> Template:CSGO add
Warps the reflection, "pushing" the top downward.
$envmaplightmapscale Template: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.

控制台命令

buildcubemaps
为材质创建反射.如何创建失败,则会直接反射天空或显示错误材质,错误在EP1中是白色的,在其他游戏为花格.
r_showenvcubemap <bool>
一个展示所有动态物体在高强度反射下的状态的命令。通常会在物体起点创造一个镜像(?对此句翻译尚有疑问)(It was used to create the image at the start of this article.)

相关信息