Still can't get fire effect as good as I want...

Member
Posts: 321
Joined: 2004.10
Post: #1
People have been very kind in answering my questions regarding blending,
but I'm still not quite there. So in desperation, I tried brute force. I went
through all the source and destination blend constants. Like so:

Code:
double opacity = 1.0 - ( (double) f->getAge() / (double) f->getLifeSpan() );        
glColor4d(1.0, 1.0, 1.0, opacity);
      
glBlendFunc( source[src].blend, destination[dst].blend );
glBegin(GL_QUADS);
{              
    glTexCoord2f(0.0f, 0.0f); glVertex3f(-sideSize,-sideSize,  0.1f);
    glTexCoord2f(1.0f, 0.0f); glVertex3f( sideSize,-sideSize,  0.1f);
    glTexCoord2f(1.0f, 1.0f); glVertex3f( sideSize, sideSize,  0.1f);
    glTexCoord2f(0.0f, 1.0f); glVertex3f(-sideSize, sideSize,  0.1f);      
}
glEnd();

People have mentioned additive blending and modulation, but
the strange thing is that of all the combinations, only these three were acceptable:

1) (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

2) (GL_SRC_ALPHA, GL_ONE_MINUS_CONSTANT_COLOR)

3) (GL_SRC_ALPHA, GL_ONE_MINUS_CONSTANT_ALPHA)

My particles consist of three 16x16 texel RGBA image. One is red, the other is orange, and the third is yellow. Each image looks like a paint ball has been shot at a white square of paper. The white that is not covered by the paint is alpha and this is transparent. I continuously randomly pick 1-3 and throw the corresponding particle out the emiter.

Number 1) is not really blending. When I zoom in I see each particle simply covering up the ones behind. Number 2) and 3) look great. They really seem
to be blending; both even have a white hot center. However both of them suffer
from the phenomenon of when they are placed on a white background, the fire disappears. I even tried setting the white background to alpha = 0 and alpha = 1 thinking this might help. Nope.

Is my approach sound? Should I be using instead a grayscale image and paint the grey image via glColor()?

Thanks.
Quote this message in a reply
Moderator
Posts: 133
Joined: 2008.05
Post: #2
Try the combination GL_SRC_ALPHA, GL_ONE. And I would suggest using a white(grayscale) image so you can modulate a color on top of it for greater color range.
Quote this message in a reply
Member
Posts: 320
Joined: 2003.06
Post: #3
If you have a white background, and then use an additive blend mode you get closer to white, which of course will result in just plain white.
One way to fix this is to put a smoke particle emitter behind or with the additive particles. Smoke can be almost the same as your additive particles, but with black or close to it coloring, and a normal blend mode.

Chopper, iSight Screensavers, DuckDuckDuck: http://majicjungle.com
Quote this message in a reply
Member
Posts: 26
Joined: 2006.09
Post: #4
Fire probably works better with 'Screen' blending mode, it is practically the opposite of the Multiply. If Multiply is c = a*b, then Screen is c = 1-((1-a)*(1-b)). In case of the Multiply blend the more white something is the less it affects the colors on screen, and with Screen the more black something is the less it affects.

Multiply blend mode is:
glBlendFunc(GL_DST_COLOR, GL_ZERO);
c' = src*dst + dst*0

Screen blend mode is:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
c' = src*1 + dst*(1-src)

Another way would be to use the alpha channel of the texture to dim the background before you do the blending and prepare the texture so that it would work with additive blending (the more towards the black, the less it affects the stuff on screen). The image on the RGB channels can be totally different than the stuff on alpha channel (note that low alpha values will dim the background more). In this case the blend func would be:

glBlendFunc(GL_ONE, GL_SRC_ALPHA);
c' = src*1 + dst*src.a
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Temple Run Magnet Effect anmetv 2 1,514 Dec 1, 2013 05:24 PM
Last Post: JustinFic
  Using blending for a text fading effect. cjcaufield 2 4,423 Jun 30, 2010 08:21 PM
Last Post: cjcaufield
  Halo-Effect in 3D OpenGL ES Bersaelor 4 5,878 Dec 17, 2009 11:54 AM
Last Post: Mark Levin
  How to do a Quick, Dirty bloom effect FAST! Oddity007 12 8,135 May 9, 2009 09:42 AM
Last Post: aardvarc
  malloc particle effect (glDrawArray) Graphic Ace 1 3,160 Mar 15, 2009 03:13 PM
Last Post: maximile