Jump to content

  • Log In with Google      Sign In   
  • Create Account


Additive blending. How to do it?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
9 replies to this topic

#1 ZadrraS   Members   -  Reputation: 157

Like
0Likes
Like

Posted 23 September 2005 - 10:00 PM

Hello. I would like to make a fire effect using my particle engine. Additive blending seems to be the perfect thing for me, but i have no idea how should i do it. I've tried searching for additive blending tutorials, but found nothing. So, could someone explain how to do it or point me in the right direction to learn about it? I'm using OpenGL btw.

Sponsor:

#2 hanstt   Members   -  Reputation: 259

Like
0Likes
Like

Posted 23 September 2005 - 10:27 PM

Lesson 8 at NeHe

#3 ZadrraS   Members   -  Reputation: 157

Like
0Likes
Like

Posted 24 September 2005 - 05:57 AM

I do know how to make things transparent, but making something transparent isn't all there is to additive blending, right?

#4 Cypher19   Members   -  Reputation: 768

Like
1Likes
Like

Posted 24 September 2005 - 06:04 AM

Additive blending is done very much in the same way as alpha blending. I haven't worked in OGL, but in D3D, you set the source blend to one and the dest blend to one* to get additive blending.


*i.e.
mD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
mD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_ONE);


#5 Kalidor   Members   -  Reputation: 1087

Like
0Likes
Like

Posted 24 September 2005 - 06:31 AM

As Cypher19 said, all you need to do is switch to a proper blend function. In OpenGL you do this...
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
This will make the blend equation
Co = 1*Cs + 1*Cd
where Co is the output color, Cs is the source color, and Cd is the destination color.

#6 ZadrraS   Members   -  Reputation: 157

Like
0Likes
Like

Posted 24 September 2005 - 06:41 AM

Ahh... It's that simple then :)
Rating++ for all of you.
And can i just use glBlendFunc(GL_SRC_ALPHA, GL_ONE); instead of glBlendFunc(GL_ONE, GL_ONE);? I seem to be getting the same results.


#7 Kalidor   Members   -  Reputation: 1087

Like
0Likes
Like

Posted 24 September 2005 - 07:00 AM

Quote:
Original post by ZadrraS
And can i just use glBlendFunc(GL_SRC_ALPHA, GL_ONE); instead of glBlendFunc(GL_ONE, GL_ONE);? I seem to be getting the same results.
Yep, that is still additive, but the blend equation then becomes
Co = As*Cs + 1*Cd
so that the source color is first scaled by source alpha, then added to destination color. So if your source alpha equals 1.0, it will be equivalent to glBlendFunc(GL_ONE, GL_ONE).

#8 SimmerD   Crossbones+   -  Reputation: 1098

Like
0Likes
Like

Posted 24 September 2005 - 05:45 PM

There are other additive type blend modes. One of my favorite is

srccolor * one + destcolor * invsrccolor.

This scales down the dest by 1-src, then adds in the src. This keeps things from oversaturating, and can give a foggy feel.

#9 ZadrraS   Members   -  Reputation: 157

Like
0Likes
Like

Posted 24 September 2005 - 07:24 PM

Is the invsrccolor - Inversed Source Color? What flag do I need to get it?

#10 superpig   Staff Emeritus   -  Reputation: 1825

Like
0Likes
Like

Posted 25 September 2005 - 02:46 AM

GL_ONE_MINUS_SRC_COLOR.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS