开发者

Alpha Enabled vs Blending Enabled

While trying to figure out terminology for rendering, I ca开发者_高级运维me down to this problem as I could not see the difference.

What is the difference between "Alpha Enabled" and "Blending Enabled"?


What is the difference between "Alpha Enabled" and "Blending Enabled"?

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:

if(myOutputColor.a < 0.5) discard;

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.


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.


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).


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.

15.010 What is the difference between transparent, translucent, and blended primitives?

A transparent physical material shows objects behind it as unobscured and doesn't reflect light off its surface. Clear glass is a nearly transparent material. Although glass allows most light to pass through unobscured, in reality it also reflects some light. A perfectly transparent material is completely invisible.

A translucent physical material shows objects behind it, but those objects are obscured by the translucent material. In addition, a translucent material reflects some of the light that hits it, making the material visible. Physical examples of translucent materials include sheer cloth, thin plastic, and smoked glass.

Transparent and translucent are often used synonymously. Materials that are neither transparent nor translucent are opaque.

Blending is OpenGL's mechanism for combining color already in the framebuffer with the color of the incoming primitive. The result of this combination is then stored back in the framebuffer. Blending is frequently used to simulate translucent physical materials. One example is rendering the smoked glass windshield of a car. The driver and interior are still visible, but they are obscured by the dark color of the smoked glass.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜