Jump to content
  • Advertisement
Sign in to follow this  
Boder

OpenGL Additive Blend

This topic is 4673 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!