> ## Documentation Index
> Fetch the complete documentation index at: https://dripart-docs-lora-training-1772768349.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GLSLShader - ComfyUI Built-in Node Documentation

> Complete documentation for the GLSLShader node in ComfyUI. Learn its inputs, outputs, parameters and usage.

> 本文档由 AI 生成。如果您发现任何错误或有改进建议，欢迎贡献！ [在 GitHub 上编辑](https://github.com/Comfy-Org/embedded-docs/blob/main/comfyui_embedded_docs/docs/GLSLShader/zh.md)

GLSL Shader 节点将自定义的 GLSL ES 片段着色器代码应用于输入图像。它允许您编写可以处理多个图像并接受统一参数（浮点数和整数）以创建复杂视觉效果的着色器程序。输出尺寸可以由第一个输入图像决定，也可以手动设置。

## 输入参数

| 参数                | 数据类型   | 必填 | 范围                             | 描述                                                                |
| ----------------- | ------ | -- | ------------------------------ | ----------------------------------------------------------------- |
| `fragment_shader` | STRING | 是  | 不适用                            | GLSL 片段着色器源代码（兼容 GLSL ES 3.00 / WebGL 2.0）。默认值：一个输出第一个输入图像的基本着色器。 |
| `size_mode`       | COMBO  | 是  | `"from_input"`<br />`"custom"` | 输出尺寸模式：'from\_input' 使用第一个输入图像的尺寸，'custom' 允许手动设置尺寸。              |
| `width`           | INT    | 否  | 1 到 16384                      | 当 `size_mode` 设置为 `"custom"` 时，输出图像的宽度。默认值：512。                   |
| `height`          | INT    | 否  | 1 到 16384                      | 当 `size_mode` 设置为 `"custom"` 时，输出图像的高度。默认值：512。                   |
| `images`          | IMAGE  | 是  | 1 到 8 张图像                      | 由着色器处理的输入图像。在着色器代码中，图像以 `u_image0` 到 `u_image7`（sampler2D）的形式提供。  |
| `floats`          | FLOAT  | 否  | 0 到 8 个浮点数                     | 着色器使用的浮点型统一值。在着色器代码中，浮点数以 `u_float0` 到 `u_float7` 的形式提供。默认值：0.0。  |
| `ints`            | INT    | 否  | 0 到 8 个整数                      | 着色器使用的整型统一值。在着色器代码中，整数以 `u_int0` 到 `u_int7` 的形式提供。默认值：0。          |

**注意：**

* 仅当 `size_mode` 设置为 `"custom"` 时，`width` 和 `height` 参数才是必需的且可见。
* 至少需要一个输入图像。
* 着色器代码始终可以访问一个包含输出尺寸的 `u_resolution`（vec2）统一变量。
* 最多可以提供 8 个输入图像、8 个浮点型统一变量和 8 个整型统一变量。

## 输出参数

| 输出名称     | 数据类型  | 描述                                                                   |
| -------- | ----- | -------------------------------------------------------------------- |
| `IMAGE0` | IMAGE | 着色器输出的第一个图像。在着色器代码中通过 `layout(location = 0) out vec4 fragColor0` 提供。 |
| `IMAGE1` | IMAGE | 着色器输出的第二个图像。在着色器代码中通过 `layout(location = 1) out vec4 fragColor1` 提供。 |
| `IMAGE2` | IMAGE | 着色器输出的第三个图像。在着色器代码中通过 `layout(location = 2) out vec4 fragColor2` 提供。 |
| `IMAGE3` | IMAGE | 着色器输出的第四个图像。在着色器代码中通过 `layout(location = 3) out vec4 fragColor3` 提供。 |
