Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

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

1 Answer 1

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.

share|improve this answer
4  
@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. –  Nicol Bolas Jan 26 '13 at 12:42
2  
-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? –  ashes999 Jan 26 '13 at 12:45
3  
@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. –  Nicol Bolas Jan 26 '13 at 13:02
2  
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 –  Robert Rouhani Jan 26 '13 at 22:25
1  
@PandaPajama: By making them think about how to use the feature directly, rather than copying-and-pasting canned responses, you not only know that they understand it, you give them the tools to use it in novel and unique ways. –  Nicol Bolas Jan 26 '13 at 23:07
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.