> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/output-bindings.md).

# Emotion 输出绑定

Emotion 模块着色器属性输出绑定的参考，用于驱动脸红、泪光或汗光等效果。

输出绑定是 Emotion 管线中的可选附加阶段，用于处理面部本身之外的效果。面部表情不是通过绑定编写的——它是通过共享面部合成器自动写入的。本页涵盖 `MaterialPropertyEmotionBinding`，即配置文件作者定义的唯一输出绑定，用于诸如腮红、泪光闪烁或汗光之类的着色器效果。

### 面部表情如何到达脸部

Emotion 通过共享面部合成器而不是通过直接编写的绑定来写入面部输出。表情配方只编译一次，针对角色的骨骼绑定进行解析，并与 LipSync 和微表情生命层一起提交到合成器的情绪层。参见 [面部组合](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/facial-composition.md) 了解合成器的图层模型、混合模式以及 LipSync 优先于 Emotion 的优先级规则。

### MaterialPropertyEmotionBinding

`MaterialPropertyEmotionBinding` 根据组合后的情绪分数驱动任意着色器浮点属性——腮红、泪光闪烁、汗光，或任何其他自定义着色器效果——而 SDK 中没有内置的着色器知识。它在 **材质效果** 字段在 `ConvaiEmotionProfile`中编写，作为 `MaterialPropertyEmotionSlot` 条目的列表。

#### MaterialPropertyEmotionSlot 字段

| 字段             | 类型      | 默认    | 说明                                          |
| -------------- | ------- | ----- | ------------------------------------------- |
| `emotionLabel` | `字符串`   | —     | 驱动此效果的规范分类标签（例如 `"anger"`).                 |
| `propertyName` | `字符串`   | —     | 着色器公开的浮点属性名（例如 `"_EmotionBlush"`）。留空可跳过此插槽。 |
| `minValue`     | `float` | **0** | 在组合强度为零时写入的属性值。                             |
| `maxValue`     | `float` | **1** | 在组合强度为满值（1.0）时写入的属性值。                       |

#### 它如何解析并写入

* 目标渲染器的解析方式与面部表情输出相同：角色的面部网格，如果失败则回退到 `SkinnedMeshRenderer` 角色根节点下的扫描。
* 写入通过逐渲染器的 `MaterialPropertyBlock` （get-modify-set，获取-修改-设置）流程进行，因此共享材质资源永远不会被修改，并且同一渲染器上其他系统自己的 property-block 写入会被保留。
* **取最大值合并规则。** 当两个或更多插槽针对同一渲染器上的同一属性时——例如同时有 `愤怒` 和一个 `embarrassment`标签的自定义条目驱动 `_EmotionBlush` ——会在每一帧比较它们组合后的强度，强度最高的插槽的 `[minValue, maxValue]` 范围获胜，与编写顺序无关。
* **解绑时恢复原值。** 禁用控制器或切换配置文件时，会将每个被触及的属性写回其插槽的 `minValue` ，而不是让最后的情绪值卡住不变。
* 即使解析出的面部网格的材质没有实际声明所编写的属性，也不会阻止写入——不受支持的 `MaterialPropertyBlock` 浮点写入只是无效，不会报错，而且同一角色不同网格之间的着色器差异是正常的。
* 一个唯一编写输出只是材质属性插槽的配置文件仍然算作有活动输出；它不会触发第 [情绪故障排查](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/troubleshooting-and-diagnostics.md).

{% hint style="warning" %}
中说明的“未解析到面部输出”的诊断警告。 `如果在任何目标材质上都找不到已编写的属性名，则该绑定会记录一条警告：` \[MaterialPropertyEmotionBinding] '\<name>' 已编写材质属性插槽，但在任何目标材质上都未找到已编写的着色器属性（\<names>）。请验证属性名（例如 "\_EmotionBlush"）是否与角色分配的材质所公开的属性匹配。
{% endhint %}

#### 示例

```csharp
// 在配置文件上编写的材质绑定插槽：
// { emotionLabel: "anger", propertyName: "_EmotionBlush", minValue: 0, maxValue: 0.6 }
// { emotionLabel: "fear",  propertyName: "_EmotionSweat", minValue: 0, maxValue: 1 }
```

### 共享示例分类法和配置文件资源

Emotion 模块在 `SamplesShared/Profiles/Embodiment/Modules/Emotion/`: `ConvaiSamplesShared_EmotionTaxonomy.asset`下提供共享示例资源，以及四个命名的人格配置文件资源—— `温暖`, `沉稳`, `活力充沛`, `内敛`.

1. 将角色的 **Taxonomy** 字段指向 `SamplesShared/Profiles/Embodiment/Modules/Emotion/ConvaiSamplesShared_EmotionTaxonomy.asset`.
2. 将其 **Profile** 字段指向最适合该角色的四个命名人格资源中的任意一个，或者使用 [角色类型预设](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/emotion-profile.md#character-type-presets).
3. 如果角色没有分类法也仍可运行，但所有读取该分类法的情绪下拉框都会为空——这看起来像 Inspector 损坏，而不是缺少引用，因此请显式检查，而不要等控制台警告。
4. 这些共享资源位于包内。若要直接编辑其中任意一个，请先将其复制到你自己的 `Assets/` 文件夹中——在包内进行的编辑不会在包更新后保留。

### 下一步

{% content-ref url="/pages/5a9247365092d958f2d539ae98bdfe69f72df091" %}
[Emotion 配置文件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/emotion-profile.md)
{% endcontent-ref %}

{% content-ref url="/pages/ae138cae5e0a278bc48c79d0ca79ef2ef46609d4" %}
[面部组合](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/facial-composition.md)
{% endcontent-ref %}


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/embodiment/emotion/output-bindings.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
