Additive Blend

Started by
7 comments, last by Skeleton_V@T 18 years, 3 months ago
I was looking how to do an additive blend in OpenGL. I was trying to wrap my head around glBlendFunc(), which I still don't really understand. I came across a function called glBlendEquationEXT(). How can I perform additive blending? Can anyone give a simple example of a BlendFunc in action on one source pixel and one destination pixel? Is there any good documentation for the extension functions (the Blue Book doesn't seem to have them) ?
Advertisement
Did you try glBlendFunc (GL_SRC_ALPHA, GL_ONE) ?.
You may take a look at MSDN for details.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
Thank you for the reply,
I will give it a try.

So if we have these pixels RGBA
0.3 0.3 0.3 1.0
0.5 0.0 0.0 1.0

The result put into the equation
(Rs Sr + Rd Dr, Gs Sg + Gd Dg, Bs Sb + Bd Db, As Sa + Ad Da)
R= 0.3(1.0) + 0.5(1.0)
G= 0.3(1.0) + 0.0(1.0)
B= 0.3(1.0) + 0.0(1.0)
A= 1.0(1.0) + 1.0(1.0)
Yes, but before clamping to [0, 1] it is compared to the maximum possible color component value (k(R) = 2^m(R) - 1). Where m(R) is the number of bit planes in Red component, same goes to G, B and A. As the expression only increase the destination color but not exceed k(R), it performs addictive blending.

I have to admit sometime I just combine random values since I don't even know how I want the colors to be blended [wink].

In case you haven't noticed, NeHe's Lesson 09 provides a quite brilliant particle system.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
I think I'm getting it. I forgot about that maximum K value, which allows for a 16bit or 32bit alpha, and makes sure the color doesn't get too big after it is added. (edit: also allows for larger bit depth in color)

So is a 16bit or 32bit alpha possible and wouldn't it kill performance because now the pixel size isn't 32bits?

Also, is there documentation for the OpenGL extension functions?
Quote:Original post by Boder
So is a 16bit or 32bit alpha possible and wouldn't it kill performance because now the pixel size isn't 32bits?


It is possible but I think it doesn't make much sense as the maximum color depth visually visible on desktop PC is 32 bit. So 8 bit alpha value is usually prefered. I haven't used 16 or 32 bit alpha values myself though.

Quote:Also, is there documentation for the OpenGL extension functions?


You may find infos on official extension at SGI OpenGL's extension registry.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
I'm a bit disappointed by that reference. It has a bunch of information I don't need.

So to get the latest OpenGL reference and Programmer's Manual I have to buy the books?
I think what you need is 'glBlendEquationEXT(GL_MAX_EXT);'.
(If I understand the term 'additive blend' correctly...)
I use it to mix lights, so that when I combine red, green and blue lights, for example, I get a white light.
In other words, I may say they're comprehensive indeed.
The documentations are roughly organized as:

  1. Name
  2. Name Strings
  3. Dependencies
  4. Overview - I think this part is a little overwhelming, but it is necessary
  5. Issues - This part is sometime helpful
  6. New Procedures and Functions - You may jump straight to this part for functions syntax
  7. New Tokens - This lists the new #defines and constant
  8. Additions to X of the OpenGL A.B.C Specification - This part is sometime helpful
  9. Errors
  10. New States


You may find new functions syntax in #6 and jump straight to #8, 9 for specifications.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--

This topic is closed to new replies.

Advertisement