> For the complete documentation index, see [llms.txt](https://noskill.gitbook.io/titanfall2/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://noskill.gitbook.io/titanfall2/chinese/information/textures/valve-texture-format-vtf/creating-a-material.md).

# 创建材质

本教程将会教你从头开始一步一步地创建一个全新的[材质](https://app.gitbook.com/@noskill/s/titanfall2/~/drafts/-Ma932GRGVfjjlaaoa1C/v/chinese/information/textures/valve-material-type-vmt/@merged)，并创建材质的[纹理文件](https://app.gitbook.com/@noskill/s/titanfall2/~/drafts/-Ma932GRGVfjjlaaoa1C/v/chinese/information/textures/valve-texture-format-vtf/@merged)。

## 创建一个材质

任何图像文件都可以作为纹理，只要它的尺寸(高度和宽度)都是2的幂：2，4，8，16，32，64，128，256，512，1024，2048等等。要决定新建纹理的参数设置，请先检查在游戏中正在使用的对应纹理。更高的分辨率的纹理会降低性能，但当你近距离观察时，显示的图像会更清晰。

不同类型的对象拥有不同的标准分辨率（例如：角色模型的标准分辨率就非常高）。如果你不清楚的话请用 [GCFScape](https://developer.valvesoftware.com/wiki/GCFScape) 查看 `source materials.gcf`中v社的标准设置![](https://developer.valvesoftware.com/w/images/c/cc/Note.png)&#x20;

{% hint style="info" %}
**注解：**&#x7EB9;理源文件应该保存为（例如[TGA](/titanfall2/chinese/information/file-format/truevision-graphics-adapter-tga.md)预编译）这种无损格式以防不必要的纹理质量损失
{% endhint %}

## **转换纹理**

纹理必须转换为[Valve Texture Format (VTF)](/titanfall2/chinese/information/textures/valve-texture-format-vtf.md)格式才能让起源引擎使用。v设提供了[VTEX](https://developer.valvesoftware.com/wiki/Vtex)作为转换工具。这是一个有很多限制的命令行工具，所以第三方工具VTFEdit是更好的选择： 它提供了一个图形用户界面，允许使用者直接更改纹理的属性而无需从头重新编译它，并兼容各种图像格式，还可以直接每个纹理创建脚本文件。当然，在一些情况下你还是需要使用VTEX的，但只有很少一部分（比如说一些动态纹理和[spritesheet技术](https://app.gitbook.com/@noskill/s/titanfall2/~/drafts/-Ma932GRGVfjjlaaoa1C/v/chinese/information/textures/valve-texture-format-vtf/animated-particles/@drafts)）。

此外，如果您有需要使用透明度的纹理，建议您在导入到VTFEdit之前保存为TIFF格式，因为PNG的透明度往往容易出现一些问题（有一些VTF插件可以让您直接从Photoshop、GIMP和Paint.net保存为vtf格式，但是本教程并不会介绍它们，因为不是每个人能够使用这些工具）。

要在VTFEdit中导入纹理， 请选择 `File > Import` 或者使用Ctrl+I快捷键。然后，选择你需要的图像，导入选项窗口就会弹出：

![](/files/-M2DA9NXeMTjkrVyTtCE)

### 通用设定

以下的这三个参数最为重要：

* 法线格式
  * 如果纹理是不透明的，请使用颜色/压缩（color/compression）格式。
* Alpha格式
  * 如果纹理有alpha通道，应该使用颜色/压缩（color/compression）格式。
* 纹理类型

  * 导入多个图像意味着这些图像将会作为动画/[立方体贴图面](https://app.gitbook.com/@noskill/s/titanfall2/v/chinese/information/textures/cube-mapping/@drafts)/深度切片来使用。

  如果你正在制作一个简单的世界纹理，你不需要改变任何上述参数。 但是，如果你在制作一个有着细微斜面细节的纹理，你需要选择一个[非有损压缩格式](https://noskill.gitbook.io/titanfall2/v/chinese/information/textures/valve-texture-format-vtf#choosing-an-image-format)。

### Mipmap设置

[Mipmaps](/titanfall2/chinese/information/textures/mip-mapping.md)是纹理的低分辨率版本，当纹理表面远离相机时引擎会进行切换以节省资源。它们极大地减少了纹理所需调用的数量，提高了性能和图像质量。纹理 [LOD](https://en.wikipedia.org/wiki/Level_of_detail)需要Mips才能工作。

{% hint style="info" %}
&#x20;**提示：**&#x5728;3D世界出现的纹理需要拥有[mipmaps](/titanfall2/chinese/information/textures/mip-mapping.md)。为了节约内存，在2D世界中使用的纹理尽量不要使用[mipmaps](https://app.gitbook.com/@noskill/s/titanfall2/~/drafts/-Ma9BRdwf8qrjFOuXmGJ/v/chinese/information/textures/mip-mapping/@drafts)。
{% endhint %}

下列图片展示了各种在 [VTFEdit](/titanfall2/chinese/how-to-start-modding/modding-introduction/modding-tools.md#vtf-and-vmt)可以使用的[mipmap](/titanfall2/chinese/information/textures/mip-mapping.md)滤镜：

![锐化滤镜](/files/-M2DCmhSDns8-fVDneNd)

![Mip滤镜 #1](/files/-M2DCqYpjYJ6vn4t3epQ)

![Mip滤镜 #2](/files/-M2DCtOMecDxE_hXDV_U)

![Mip滤镜 #3](/files/-M2DCwXulBMHkvycgDWH)

![Mip滤镜 #4](/files/-M2DCzffZJbCZ0D4eeWX)

### 法线贴图设置

这些（mis-labelled） 设置允许你用你输入的图像自动生成一个[凹凸贴图](https://developer.valvesoftware.com/wiki/Bump_map)。你可能想用图像编辑功能来快速完成设计，但是自动生成选项只能生成一个非常基础的贴图。

## 配置&保存

当您点击OK时，输入的文件将会进行格式转换（越大的图像转换时间越长，需要使用者耐心等待大），转换完成后，对应的VTF将会出现。现在剩下要做的就是使用窗口左侧的复选框列表中的选项配置纹理。请参阅 [Valve Texture Format image\_flags](/titanfall2/chinese/information/textures/valve-texture-format-vtf.md#image-flags) 来获取进一步的信息。

最后，请把文件保存到你游戏或者mod下  `\materials` 文件夹的某一个位置。

## 创建一个材质（Materials）

起源引擎并不会直接访问纹理。所有的纹理都要通过一个[材质](https://noskill.gitbook.io/titanfall2/v/chinese/information/textures/valve-material-type-vmt)进行配置之后才会被调用。

[材料](https://app.gitbook.com/@noskill/s/titanfall2/~/drafts/-Ma9GJZ1h2Li9XAhpICO/v/chinese/information/textures/valve-material-type-vmt/@drafts)是可以在任何文本编辑器中创建的脚本文件，但建议您结合在[编辑软件](https://app.gitbook.com/@noskill/s/titanfall2/~/drafts/-Ma9GJZ1h2Li9XAhpICO/v/chinese/how-to-start-modding/modding-introduction/modding-tools#general/@drafts)页面中用[高亮语法规则](https://developer.valvesoftware.com/wiki/Notepad%2B%2B_VDF_languages)列出的软件之一进行编辑。为了让你的材质被检测到， **你必须把它以`.vmt`格式保存在你的游戏或mod下的** **`\materials` 文件夹中** .

{% hint style="info" %}
&#x20;**注解：**&#x5982;果你正在为一个现有的mod制作贴图材质或纹理，可以考虑使用[BSPZIP](https://developer.valvesoftware.com/wiki/BSPZIP)\\[Packbsp](https://developer.valvesoftware.com/wiki/Packbsp)\\[Pakrat](https://developer.valvesoftware.com/wiki/Pakrat)\\[Compile Pal](https://developer.valvesoftware.com/wiki/Compile_Pal) 等软件来将材质和纹理文件打包到贴图文件中。
{% endhint %}

### 语法

一个材质文件的语法格式应该看起来像这样：

```
<shader>
{
	<parameter> <value>
	...
}
```

```
LightmappedGeneric
{
	$basetexture coast\shingle_01
	$surfaceprop gravel
}
```

有很多的[着色器](https://developer.valvesoftware.com/wiki/Shader)可供选择，但是大多数的材质都会选择[`LightmappedGeneric`](https://developer.valvesoftware.com/wiki/LightmappedGeneric) ([笔刷](https://developer.valvesoftware.com/wiki/Brush))，[`VertexLitGeneric`](https://developer.valvesoftware.com/wiki/VertexLitGeneric) ([模型](https://developer.valvesoftware.com/wiki/Model))[`UnlitGeneric`](https://developer.valvesoftware.com/wiki/UnlitGeneric)（通常用于[UI](https://developer.valvesoftware.com/wiki/VGUI2)材料，偶尔用于[工具材料](https://developer.valvesoftware.com/wiki/Tool_texture)）三者之一。

### 参数

如果需要所有的着色器参数说明，请参照[分类：着色器参数列表](https://developer.valvesoftware.com/wiki/Category:List_of_Shader_Parameters)

选择一个着色器后，你将要调配参数(也称为命令)。材质参数有数百种选择，本文只讨论最常见的，或多或少被所有着色器所接受的的参数。它们是:

* [`$basetexture`](/titanfall2/chinese/information/textures/shader/usdbasetexture.md)
* [`$surfaceprop`](https://developer.valvesoftware.com/wiki/$surfaceprop)
* [`$envmap`](https://developer.valvesoftware.com/wiki/$envmap)
* [`$bumpmap`](/titanfall2/chinese/information/textures/bump-map/usdbumpmap.md)
* [`$detail`](https://developer.valvesoftware.com/wiki/$detail)
* [`$selfillum`](https://developer.valvesoftware.com/wiki/$selfillum)
* [`$model`](https://developer.valvesoftware.com/wiki/$model_\(VMT\))

{% hint style="info" %}
&#x20;**提示：**&#x5982;果需要在参数值中使用空格或制表符，则必须用"引号"将参数值括起来。您经常会看到所有的参数都是这样用引号括起来的，这样可以提高可读性—当然你可以选择不加，因为这不是必须的。
{% endhint %}

{% hint style="info" %}
&#x20;**提示：**&#x4F60;可以用控制台命令 `mat_reloadallmaterials` 来刷新材质在游戏中的预览，这会重加载游戏里的所有材质。这里建议使用这个命令来防止游戏被冻结和其他的一些奇怪现象发生： `mat_reloadmaterial "vmt_name without .vmt"`。

例子：`mat_reloadmaterial "monitor_screen"`。 Mat\_reloadtextures的语法与这个相同。
{% endhint %}

## 参考文献

{% hint style="info" %}
源文章链接：<https://developer.valvesoftware.com/wiki/Creating_a_Material>
{% endhint %}

{% hint style="info" %}
引用：<https://en.wikipedia.org/wiki/Level_of_detail>
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://noskill.gitbook.io/titanfall2/chinese/information/textures/valve-texture-format-vtf/creating-a-material.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
