Using the following setting for the OpenGL particle effect:
SRC: GL_SRC_ALPHA
DST: GL_ONE
Creates an additive blend, which looks spectacular on a black background but terrible on brighter colours, as it begines to fade to white.
I then used alpha blending:
SRC: GL_SRC_ALPHA
DST: GL_ONE_MINUS_SRC_ALPHA
This allows other backgrounds to be used without affecting the color of the particles, but the particles themselves look dull compared to the additive blend. How can I achieve a good fire effect with alpha blending and particles?
Additive:
Alpha:
UPDATE:
Following David's advice below, I created a separate texture and then used additive blend on the particle effect before drawing onto the texture. The problem with that is that drawing on an alpha=0 texture resulted in just the coloured parts of the particle appearing in front of my world map, since normally you have a black background instead. The trick was to use two textures. I created a black texture and then drew the particles on it. Then I removed the alpha layer of the particles from this texture, effectively removing all the surrounding solid black and fading out the partially visible particles, while leaving the underlying black as you'd expect when making additive blend particles on a black background. In short, a gruelling process, but I got there eventually:
Here's the thread where I posted my process: http://www.cocos2d-iphone.org/forum/topic/28707?replies=8#post-141528
Video: http://www.youtube.com/watch?v=JptGbEO3b5E
Answer
I admit I'm not aware of any ideal solution to this problem, so I'll describe a workaround that you may or may not be comfortable with:
- Render all of the particles using additive blending to a separate texture (or render target) with its background cleared to transparent.
- Render that texture (or render target) on top of your scene using alpha blending.
I tried it in Photoshop and here's what I got - It's not perfect, but at least it preserves the original colors better:
Here's the original texture without doing additive blending on the particles:
No comments:
Post a Comment