启用 Alpha 与启用混合
在尝试找出渲染术语时,我遇到了这个问题,因为我看不出其中的区别。
“启用 Alpha”和“启用混合”之间有什么区别?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
在尝试找出渲染术语时,我遇到了这个问题,因为我看不出其中的区别。
“启用 Alpha”和“启用混合”之间有什么区别?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(4)
该问题假设这些术语具有唯一的命名约定。就我而言,我从未听说过“alpha 启用”这个术语,而且我从事图形和 OpenGL 工作已有 10 多年了。你在哪里找到这个词的?
OpenGL 确实定义了术语“混合”。
混合是渲染管道,其中来自每个片段操作的输出(又名:片段着色器。或者,如果您喜欢这类东西,固定功能纹理环境pipeline)与目标图像中当前的值相结合,以计算写入目标的最终颜色。
上面的链接应该可以满足您解释这些东西如何工作的需要。混合通常用于使对象显得透明,但这并不是它的唯一用途。
现在,也许“alpha 启用”意味着 alpha 测试。这是一个较旧的功能(在 GL 3.0 中已弃用并在 GL 3.1 中删除。您可以使用兼容性上下文 来获取它),其中颜色由片段着色器或固定功能管道编写的代码已针对预设值进行了 alpha 测试。如果测试失败,则该片段将被剔除:不写入帧缓冲区。常见的测试是“片段α>0.5”;因此,对于 alpha 值较低的颜色,片段根本不会被写入。
GL 3.1 及更高版本中删除了 alpha 测试,因为您可以使用着色器逻辑获得相同的效果:
相同的效果;您甚至可以将“0.5”设为着色器用户传入的统一值。并且您有一种真正的方法来定义 alpha 测试如何与多个片段着色器输出交互。
The question assumes that these terms have a unique naming convention. I, for one, have never heard of the term "alpha enabled", and I've been dealing with graphics and OpenGL for well over 10 years. Where did you find this term?
OpenGL does define the term "blending."
Blending is the stage of the rendering pipeline, where the outputs from the per-fragment operations (aka: the fragment shader. Or, if you're into that sort of thing, the fixed-function texture environment pipeline) are combined with the value currently in the destination image(s) to compute the final color that is written to the destination.
The links above should serve your needs for explaining how these things work. Blending is often used to make objects appear transparent, but that is not its only use.
Now, perhaps "alpha enabled" means alpha testing. This is an older bit of functionality (deprecated in GL 3.0 and removed in GL 3.1. You can use a compatibility context to get it though), where the color written by the fragment shader or fixed-function pipeline had it's alpha tested against a preset value. If the test failed, then the fragment was culled: not written to the framebuffer. A common test was "fragment alpha > 0.5"; so for colors that had low values of alpha, the fragments wouldn't be written at all.
The alpha test was removed from GL 3.1 and above because you can get the same effect with shader logic:
Same effect; you can even make the "0.5" a uniform value passed in by the user of the shader. And you have a real way of defining how the alpha test interacts with multiple fragment shader outputs.
OpenGL 手册页是极好的资源。 glEnable 的页面显示:
Alpha 测试:如果启用,请进行 alpha 测试。请参阅 glAlphaFunc。
混合:如果启用,则将计算出的片段颜色值与颜色缓冲区中的值混合。请参阅 glBlendFunc。
The OpenGL man pages are an excellent resource. The page for glEnable says:
Alpha Testing: If enabled, do alpha testing. See glAlphaFunc.
Blending: If enabled, blend the computed fragment color values with the values in the color buffers. See glBlendFunc.
如果没有更多背景,我无法非常具体,但我会尝试。
Alpha 表示透明度/不透明度,通常在纹理/颜色(Alpha 通道)的上下文中。混合意味着您以某种方式组合多个颜色源。
混合可以而且经常包含 Alpha(“Alpha 混合”可能是 3D 图形中与传统透明度最接近的模拟,因为它只是使用 Alpha 通道作为不透明度级别来在对象与其背后的场景之间进行混合),但是混合也可以通过其他方式完成。其中包括加法和调制混合,它们会产生类似的效果(“透明度”,对象与其后面的场景混合),但您不是使用 Alpha 通道,而是相加或相乘(或其他一些更复杂的效果)
操作)在渲染对象时将颜色组合在一起。
Alpha 还可用于在渲染对象时完全拒绝片段(如果 Alpha 低于设定阈值,则丢弃该片段)。
因此,在这种情况下,我怀疑您使用的任何内容都可以区分 alpha 拒绝和各种混合模式(可能包括 alpha 混合)。
I can't be very specific without more context, but I'll try.
Alpha means transparency/opacity, generally in the context of a texture/color (alpha channel). Blending means you're combining several color sources in some manner.
Blending can and often does include alpha ("alpha blending" would probably be the closest analogue to traditional transparency in 3d graphics, since it's just using alpha channel as a level of opacity to blend between the object and the scene behind it), however blending can also be done in other ways. These include additive and modulative blending, which produce a similar effect ("transparency", the object is getting blended with the scene behind it), but instead of using an alpha channel, you're adding or multiplying (or some other, more complex
operation) the colors together when rendering the object.
Alpha can also be used to completely reject fragments when rendering an object (if alpha falls below a set threshold, then discard the fragment).
So in this case I'd suspect whatever you're using is differentiating between alpha rejection and various blending modes (which may include alpha blending).
最好能获得更多背景信息,例如 OpenGL 编程 - 不同标准、公司、软件和学科之间的术语可能会令人惊讶地不一致。
本文从 OpenGL 的角度进行处理,您可以在其中考虑 alpha做到透明。 Alpha 通常是指颜色 (ARGB) 或纹理(Alpha 通道)的透明度。不过,当涉及到 OpenGL 时,情况会更加微妙。
It would be nice to get a bit more context such as OpenGL programming - terminology can be surprisingly inconsistent across different standards, companies, software, and disciplines.
This article approaches it from an OpenGL perspective, where you can consider alpha to be transparency. Alpha generally refers the transparency of a color (ARGB) or texture (the alpha channel). This is a bit more nuanced when it comes to OpenGL though.