Creating a Material:zh-cn

From Valve Developer Community
Revision as of 22:57, 7 January 2019 by GlrWere (talk | contribs)
Jump to: navigation, search
English Français Русский 日本語 한국어

本简体中文页面【正在】由 Gloria 汉化。




不同类型的物体有不同标准的分辨率(例如人物模型的纹理分辨率非常高)。如果感到困惑,可以使用GCFScapesource materials.gcf 中提取纹理,看看Valve是怎么做的。

Note.png 注意: 纹理源文件应当使用无损格式保存,例如TGA,以避免图片质量的损失。


为了给起源引擎使用,纹理必须先转换为 Valve Texture Format 格式。Valve提供的工具是VTEX。它是个命令行工具,使用起来相当不便,因此推荐使用第三方工具VTFEdit:它提供了图形用户界面,能让你无需重新编译就能修改纹理属性,支持大多数图片格式,也不需要每个纹理都创建一遍脚本文件。当然有些情况下还是不得不用回VTEX工具...但也仅限于那部分情况。此外,在使用带透明通道的纹理时,它会建议你先转为TIFF格式保存,因为PNG的透明度容易导致问题。


如何将自定义图片导入VTFEdit:菜单 File > Import 或者快捷键 Ctrl+I,选择图片后将会弹出“导入”对话框:




Normal format/普通模式
Alpha format/透明通道模式
Texture type/纹理类型
在导入了多张图片时使用,具体类型取决于它是(animation frames(动画帧)/cubemap faces(立方体贴图表面)/depth slices(深度切片))。




Tip.png 小技巧: 在3D世界中使用的纹理才需要mipmap。为了节约内存,只是用在2D界面的图片不应有mipmap。


Normal map settings

These (mis-labelled) settings allow you to automatically generate a bump map from your input image. You'll want to do this properly with an image editor for the material you ship, but the automated option is there if you want quick results or a base to work from.

Configuring and saving

When you hit OK the input file is converted (there may be quite a lengthy pause for large images) and the output VTF appears. Now all that is left is configuring the texture with the options in the checkbox list on the left-hand side of the screen. See Valve Texture Format#Image_flags for descriptions of each.

Finally, save the file somewhere under your game or mod's \materials folder.

Creating a material

Source doesn't access textures directly. Everything goes through a material.

Materials are script files that can be created in any text editor, but it's recommended that you use Notepad++ in conjunction with the community-made syntax highlighting rules. For your material to be detected, you must save it under your game or mod's \materials folder with the extension .vmt.

Note.png Note: If you are creating materials and textures exclusively for a map for an existing mod, consider using BSPZIP\Packbsp\Pakrat\Compile Pal to package the material and texture files within the map file itself. This will avoid them ever becoming lost.


A material file looks like this:

	<parameter> <value>
	$basetexture coast\shingle_01
	$surfaceprop gravel

There are many shaders to choose from, but most materials will use either LightmappedGeneric (brushes) or VertexLitGeneric (models). The third most common shader is UnlitGeneric, which is used for UI materials and the occasional tool texture.


For a list of all documented shader parameters, see Category:List of Shader Parameters.

With a shader chosen you're onto parameters (also called commands). There are hundreds of options for what to put in a material so this article will only cover the most common, which are accepted by more or less all shaders. They are:

Tip.png Tip: If you ever need to use a space or tab character in a parameter value, you must wrap the whole value with "quote marks". You'll often see absolutely everything wrapped like this - save yourself some typing, as that's unnecessary.

See also