Hello, everyone!
I've been working a simple game, and right now I'm stuck with a blending problem while experimenting with particles (I am still learning to code OpenGL and stuff).
What I am trying to achieve seems very simple to me, though I don't know whether I am doing it the right way.
I am trying to draw several particles, where each particle is a simple textured quad of two triangles.
Here's the texture, I am using (it is the standard square 'hotspot' with alpha (png with transparency), a radial gradient from non-transparent center to transparent edges):
[attachment=28358:explosion-black.png]
My actual color of the blurred circle is white, I just modified the image so that everyone could see it here on white background in this post.
Each quad-particle exists on the same plane (has same Z coordinate with others), I suppose this is somehow relevant to my problem.
Now, I want to draw a stream of those particles with color tinted to my desired color (or animated, whatever). Say, I want multiple particles with a blurred texture with green tint, so I need my own color (green) over that blurred texture's alpha, and that, overall over background mixed with other particles' colors.
So I am using the standard combination of glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and I have blending enabled.
Whenever I draw a single particle everything seems to be ok. I have a green particle with blurred edges over my background without any artifacts.
But when I draw multiple particles in a stream, they somehow 'overlap' (I don't know the actual term), and this is the result I am getting:
[attachment=28360:Screen Shot 2015-07-31 at 23.18.46.png]
So instead of mixing the alpha of the texture with color of other particles and background color, there are edges of the quads visible in the stream.
In my fragment shader i define fragmentColor = myColor * texture (tex, texcoord), and I am using it with the mentioned blending function...
The question is: how do I make the quads lay one next to the other with 'mixing neighbouring colors' but without 'overdrawing those white texture edges'? Thanks in advance, sorry for my english.