5
\$\begingroup\$

In general, I know of five ways to make use of blending functions (these are for OpenGL, but replace glBlendFunc() with SetRenderState(D3DRS_SRCBLEND) and SetRenderState(D3DRS_DESTBLEND) for DirectX):

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA): Alpha blending (not premultiplied)

glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA): Alpha blending (premultiplied)

glBlendFunc(GL_ONE, GL_ONE): Additive blending

glBlendFunc(GL_ZERO, GL_SRC_COLOR): Multiplicative blending

glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR): 2x Multiplicative blending (somewhat obscure)

But there are so many other values you can use when setting your blending function, and not only I've never seen them in use, but also have no idea what they could be used for. In particular, I don't see what GL_DST_ALPHA could be used for.

What the rest of the blending functions used for?

\$\endgroup\$
3
  • 4
    \$\begingroup\$ I have nothing to add to Nicol Bolas’s answer, but see this answer for yet another example. \$\endgroup\$ Jan 26, 2013 at 11:59
  • \$\begingroup\$ Do you mind editing your question to be more generic and adding the xna tag? XNA's has similar blending options too. \$\endgroup\$
    – ashes999
    Jan 26, 2013 at 12:44
  • 1
    \$\begingroup\$ @Sam inverting is a nice trick. \$\endgroup\$ Jan 26, 2013 at 13:00

1 Answer 1

5
\$\begingroup\$

You have to stop thinking of blend equations (and any graphics mechanism or tool) as "what it looks like." Blend equations are not "additive", "multiplicative" or anything of the sort. The blend equations do math; that's all they do.

The question is how you use that math to achieve a desired visual effect. The limits are your imagination. If you can't see how these could be used, then it's a problem with your vision, not the tool.

Destination alpha, for example, can be used for various effects. Certain objects in a scene can lay down alpha, and later, you can use this alpha in a blend equation as a key to whether you show some overlaying effect. Thus, this overlay is visible only on certain objects, and only to various degrees based on that alpha.

\$\endgroup\$
11
  • 1
    \$\begingroup\$ "additive" and "multiplicative" are just names that describe a mathematical process. If I draw something, and on top I draw something else with glBlendFunc(GL_ONE, GL_ONE), I'm doing something called "Additive blending", you can call it whatever you want, or don't call it anything if you're so inclined. I know I can do whatever I want with my blending functions and my shaders, and just want to know if there are other named techniques that can be done by just changing the blending function. I'm really sorry you took the question so personally. \$\endgroup\$ Jan 26, 2013 at 12:38
  • 4
    \$\begingroup\$ @PandaPajama: I didn't take anything "personally"; I'm pointing out that you need to stop relying on crutches like "named techniques" and look at the tool as a tool, not as a set of canned techniques. \$\endgroup\$ Jan 26, 2013 at 12:42
  • 3
    \$\begingroup\$ -1 this is a good beginner's question and the answer is basically "get lost, it's math." That's obvious, but what's the use of these modes? \$\endgroup\$
    – ashes999
    Jan 26, 2013 at 12:45
  • 3
    \$\begingroup\$ @ashes999: "the answer is basically "get lost, it's math."" No, the answer is, "it's math; stop thinking in terms of canned techniques." That's a far more valuable lesson than memorizing and regurgitating someone else's thoughts and ideas. The use of these modes is whatever you can find a use for them. That's how a graphics programmer thinks. \$\endgroup\$ Jan 26, 2013 at 13:02
  • 2
    \$\begingroup\$ That's not it at all. You're trying to map a really large set of functions onto a really small set of named functions that are commonly used for image manipulation. You should be thinking about it as a function of two variables, just as we're taught about addition as a function of two variables instead of something to memorize. We're taught how to add and can then do addition on all numbers. Instead of giving a set of values a name, try thinking about it as color = src * A + dst * B, so that you aren't stumped with a new set of values, just as you aren't stumped when you see 393448 + 98943 \$\endgroup\$ Jan 26, 2013 at 22:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .