# Alpha 合成

**Alpha 合成**（alpha compositing）是将携带 Alpha 通道的图像合并为单幅图像的一组算术规则；Alpha 通道是一种逐像素值，记录每个像素被覆盖的程度。标准代数由托马斯·波特（Thomas Porter）和汤姆·达夫（Tom Duff）在 1984 年 SIGGRAPH 论文《合成数字图像》（*Compositing Digital Images*）中定义；该文引入十二种合成运算符，其中 source-over（源覆盖），通常简称“over”，是大多数图形系统默认使用的运算符。<sup>[1](https://keithp.com/~keithp/porterduff/p253-porter.pdf)</sup><sup> • </sup><sup>[2](https://www.w3.org/TR/compositing-1/)</sup>

| 关键事实 | 详情 |
|---|---|
| 起源 | 波特与达夫，《合成数字图像》，ACM SIGGRAPH Computer Graphics 18 (3)，第 253–259 页，1984 年 1 月发表<sup>[3](https://cir.nii.ac.jp/crid/1360855569279003392)</sup> |
| 运算符 | 十二种基本 Porter–Duff 运算符，覆盖源与目标覆盖度的所有组合；W3C 列出了 clear、copy、destination、source-over、destination-over、source-in、destination-in、source-out、destination-out、source-atop、destination-atop 和 XOR，外加 lighter 加法运算符<sup>[2](https://www.w3.org/TR/compositing-1/)</sup> |
| 默认运算符 | 简单 Alpha 合成，即早期 SVG 和 CSS 所用者，使用 Porter–Duff source-over 运算符将每个元素与其背景合并<sup>[2](https://www.w3.org/TR/compositing-1/)</sup> |
| over 方程（直通 Alpha） | result = RGB × alpha + background × (1 − alpha)<sup>[4](https://docs.transducemedia.com/reference/alpha-channels/)</sup> |
| over 方程（预乘） | result = RGB_stored + background × (1 − alpha)，无需单独的相乘步骤<sup>[4](https://docs.transducemedia.com/reference/alpha-channels/)</sup> |
| 硬件支持 | OpenGL 通过 `glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)` 暴露 over 运算，并通过 `glEnable(GL_BLEND)` 启用混合<sup>[5](https://www.opengl.org/archives/resources/code/samples/sig99/advanced99/notes/node203.html)</sup> |
| 行业惯例 | 在视觉特效（VFX）管线中，预乘 Alpha 是 RGBA OpenEXR 文件的“惯例”，也是 SMPTE ST 2065-4 下 ACES 容器 RGBA 图像的默认假设<sup>[4](https://docs.transducemedia.com/reference/alpha-channels/)</sup> |

## Porter–Duff 模型

波特和达夫供职于卢卡斯影业（Lucasfilm）的计算机图形项目，他们的论文处理了一个实际制作问题：大多数计算机图形画面都是一次性计算完成的，由渲染程序处理所有重叠计算，但有些应用需要将元素分别渲染，然后再以抗锯齿结果累积成完整图像。论文主张采用四通道画面，证明遮罩分量——即 Alpha 通道——可以像颜色通道一样计算，并给出了任意合成元素的算术。<sup>[1](https://keithp.com/~keithp/porterduff/p253-porter.pdf)</sup>

该模型根据哪些形状对该像素有贡献，将每个像素划分为四个子像素区域：仅源、仅目标、两者、两者皆无。这里的目标指背景，即已经累积在下方的图像。每种运算符规定每个区域中发生什么，所有运算符合起来覆盖这四个区域的所有实际组合。<sup>[2](https://www.w3.org/TR/compositing-1/)</sup>

每种运算符都用两个分数项 Fa 和 Fb 表示，它们说明源和目标可对最终像素贡献的比例。对于 source-over，Fa = 1、Fb = 1 − αs，于是得到覆盖度方程：

\[ \alpha_o = \alpha_s \cdot 1 + \alpha_b \cdot (1 - \alpha_s) \]

和颜色方程：

\[ c_o = \alpha_s \cdot C_s + \alpha_b \cdot C_b \cdot (1 - \alpha_s) \]

其中 αs 和 αb 是源与背景的 Alpha 值，Cs 和 Cb 是它们的颜色。<sup>[2](https://www.w3.org/TR/compositing-1/)</sup> 其他运算符行为不同：source-in 只在源与目标重叠处保留源（Fa = αb，Fb = 0），destination-over 将背景置于源之上，XOR 只保留恰好由两个形状之一覆盖像素的部分。<sup>[2](https://www.w3.org/TR/compositing-1/)</sup> 后来《计算机图形技术杂志》（*Journal of Computer Graphics Techniques*）上的一篇综述统计出十三种 Porter–Duff 运算符，即十二种基本运算符加上 W3C 规范在基本十二种之外列出的 lighter 加法运算符。<sup>[6](https://jcgt.org/published/0004/02/03/paper-lowres.pdf)</sup><sup> • </sup><sup>[2](https://www.w3.org/TR/compositing-1/)</sup>

该论文自发表以来被广泛引用；一个引文分析网站记录到它有 875 条索引引用。<sup>[7](https://www.rankless.org/hit-papers/10.1145/800031.808606)</sup> 文献数据库对其 DOI 说法不一：dblp 为会议版本列出 10.1145/800031.808606，而 CiNii 列出 10.1145/964965.808606。<sup>[8](https://dblp.org/rec/conf/siggraph/PorterD84.html)</sup><sup> • </sup><sup>[3](https://cir.nii.ac.jp/crid/1360855569279003392)</sup>

## 直通 Alpha 与预乘 Alpha

RGBA 图像必须回答一个无法从像素值本身看出的问题：存储的 RGB 是图像的真实颜色、与覆盖度无关，还是已经按 Alpha 缩放过了？这就是两种存储约定。<sup>[4](https://docs.transducemedia.com/reference/alpha-channels/)</sup>

**直通 Alpha**（straight alpha），也称非关联 Alpha 或非预乘 Alpha，在每个像素存储完整颜色，而 Alpha 作为单独的覆盖度数据随行。要合成到背景上，需要显式混合：result = RGB × alpha + background × (1 − alpha)。在这种表示中，RGB 与 Alpha 相互独立：要让物体淡出，降低 Alpha 而保持 RGB 不变。<sup>[4](https://docs.transducemedia.com/reference/alpha-channels/)</sup><sup> • </sup><sup>[9](https://learn.microsoft.com/en-us/windows/apps/develop/win2d/premultiplied-alpha)</sup>

**预乘 Alpha**（premultiplied alpha），也称关联 Alpha，存储的 RGB 已经乘过自身的 Alpha，即 RGB_stored = RGB_true × alpha。在 Alpha = 0 的像素，存储数据中颜色始终为黑，而且表示完全透明只有一个值。over 运算简化为 result = RGB_stored + background × (1 − alpha)，没有单独的相乘步骤。<sup>[4](https://docs.transducemedia.com/reference/alpha-channels/)</sup><sup> • </sup><sup>[9](https://learn.microsoft.com/en-us/windows/apps/develop/win2d/premultiplied-alpha)</sup> 举一个具体例子：一个 50% Alpha 的红色像素，在 8 位预乘形式中存储为 R[127]、G[0]、B[0]、A[127]。<sup>[10](https://www.cgdirector.com/premultiplied-alpha-vs-straight-alpha/)</sup>

这种选择在图像被滤波时最为重要。对直通 Alpha 图像进行模糊、缩放或 mipmap 时，完全透明像素的“不可见”RGB 会在边界处渗入可见的相邻像素，产生暗色或彩色光晕，即所谓边缘镶边（edge fringing），因为滤波器无从知道那些 RGB 值无关紧要。预乘数据避免了这种失效模式，因为透明像素处的颜色已经是零。<sup>[4](https://docs.transducemedia.com/reference/alpha-channels/)</sup> 微软（Microsoft）的 Win2D 文档指出，图形渲染使用预乘 Alpha，因为在滤波图像或合成图层时，它比直通 Alpha 给出更好的结果；Win2D 在 API 表面上接受直通 Alpha，但在内部渲染时会转换为预乘。<sup>[9](https://learn.microsoft.com/en-us/windows/apps/develop/win2d/premultiplied-alpha)</sup>

阿尔维·雷·史密斯（Alvy Ray Smith）是计算机图形学研究者，曾参与早期合成系统；他在自己的图形备忘录中证明，非预乘 Alpha 的表述在 over 下不封闭——over 是通常定义下的基本合成运算符——这种形式化表述的意思是，合成两幅直通 Alpha 图像时，若没有额外转换，结果不会留在直通 Alpha 表示之内。<sup>[11](https://www.alvyray.com/Memos/MemosCG.htm)</sup>

## 图形 API 中的实现

OpenGL 通过其混合阶段实现 Alpha 合成，该阶段将片元着色器输出的颜色与帧缓冲中已有的颜色合并。经典的 over 运算用 `glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)` 指定，并用 `glEnable(GL_BLEND)` 启用。<sup>[5](https://www.opengl.org/archives/resources/code/samples/sig99/advanced99/notes/node203.html)</sup> OpenGL 不要求实现支持目标 Alpha 缓冲，即帧缓冲自身中用于存储 Alpha 的缓冲区。<sup>[12](https://www.opengl.org/archives/resources/code/samples/advanced/advanced97/notes/node53.html)</sup> Vulkan 在管线的 `VkPipelineColorBlendAttachmentState` 中按颜色附件定义混合，并为 RGB 和 Alpha 分别设置源因子、目标因子和运算。<sup>[13](https://docs.vulkan.org/spec/latest/chapters/framebuffer.html)</sup>

在合成与编辑应用中，两种 Alpha 约定并存，且必须正确声明。Adobe 的 Premiere Pro 和 After Effects 能识别直通与预乘两种通道，但在包含多个 Alpha 通道的文件中只识别第一个 Alpha 通道。<sup>[14](https://helpx.adobe.com/premiere/desktop/add-video-effects/work-with-composites/compositing-overview.html)</sup> 以错误的解释方式导入图像会产生可见伪影，最常见的是边缘镶边，因为软件要么乘了两次，要么根本没有乘。<sup>[10](https://www.cgdirector.com/premultiplied-alpha-vs-straight-alpha/)</sup>

## Web 标准中的扩展

W3C《合成与混合第 1 级》（Compositing and Blending Level 1）规范描述了早期版本的 SVG 和 CSS 如何使用简单 Alpha 合成：每个元素渲染到自己的缓冲区中，再使用 source-over 与背景合并，这里只有单一运算符和单一混合模式。当前规范扩展了这一模型，加入更多 Porter–Duff 运算符、控制形状重叠处颜色如何混合的高级混合模式，以及合成组。它定义了 CSS 属性 `mix-blend-mode`、`isolation` 和 `background-blend-mode`，并扩展了 canvas 的 `globalCompositeOperation` 属性。<sup>[2](https://www.w3.org/TR/compositing-1/)</sup> 可分离混合模式包括 normal、multiply、screen、overlay、darken、lighten、color-dodge、color-burn、hard-light、soft-light、difference 和 exclusion，另有四种基于色相、饱和度、颜色和明度的不可分离模式。<sup>[2](https://www.w3.org/TR/compositing-1/)</sup>

## References

1. [Thomas Porter and Tom Duff (1984). Compositing Digital Images, Computer Graphics 18(3), 253–259 (PDF)](https://keithp.com/~keithp/porterduff/p253-porter.pdf)
2. [W3C, Compositing and Blending Level 1, Candidate Recommendation Draft, 21 March 2024](https://www.w3.org/TR/compositing-1/)
3. [CiNii Research record: Compositing digital images, Porter and Duff, 1984](https://cir.nii.ac.jp/crid/1360855569279003392)
4. [Transduce Documentation, Alpha Channels](https://docs.transducemedia.com/reference/alpha-channels/)
5. [OpenGL SIGGRAPH 99 course notes, 12.2 Alpha Blending](https://www.opengl.org/archives/resources/code/samples/sig99/advanced99/notes/node203.html)
6. [Interpreting Alpha, Journal of Computer Graphics Techniques 4(2)](https://jcgt.org/published/0004/02/03/paper-lowres.pdf)
7. [Rankless citation record for Compositing digital images](https://www.rankless.org/hit-papers/10.1145/800031.808606)
8. [dblp: Compositing digital images, SIGGRAPH 1984](https://dblp.org/rec/conf/siggraph/PorterD84.html)
9. [Microsoft Learn, Premultiplied alpha (Win2D)](https://learn.microsoft.com/en-us/windows/apps/develop/win2d/premultiplied-alpha)
10. [CG Director, Straight Alpha vs Premultiplied Alpha](https://www.cgdirector.com/premultiplied-alpha-vs-straight-alpha/)
11. [Alvy Ray Smith, Computer Graphics Memos](https://www.alvyray.com/Memos/MemosCG.htm)
12. [OpenGL advanced course notes, 8.4 Blending](https://www.opengl.org/archives/resources/code/samples/advanced/advanced97/notes/node53.html)
13. [Vulkan Specification, The Framebuffer](https://docs.vulkan.org/spec/latest/chapters/framebuffer.html)
14. [Adobe, Compositing overview in Premiere and After Effects](https://helpx.adobe.com/premiere/desktop/add-video-effects/work-with-composites/compositing-overview.html)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 21, 2026 · Edited: Oct 15, 2026; Oct 21, 2026 · Last review: Oct 21, 2026*

Topic: 体育、游戏与休闲 › 电子游戏与数字游戏 › 游戏产业 › Development and technology › Graphics and rendering technology

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/alpha-compositing

English original: https://www.edgepedia.org/alpha-compositing
