• 10
• 9
• 13
• 10
• 18

blending particles with an alpha channel

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

Recommended Posts

I've created particle systems before, but this time I'm having some trouble. Even utilizing similar code. I've tried using color based blending with no transparency and alpha based blending with an image that utilizes an alpha channel. It seems that some of the particles blend fine, whilst others show the outline of the texture I'm using. Here is the screenshot: screenshot I've tried numerous glBlendFunc combinations... here are a few I've tried for the textures with an alpha channel.
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

For the screenshot, I'm using
glBlendFunc(GL_SRC_ALPHA, GL_ONE);

also, here is the particle texture I'm using, created with the Gimp: particle texture ^^ Probably won't show up because it's a white sphere on a translucent background. Any thoughts on why I'm getting these results?

Share on other sites
You draw the closer particle first, which will cause the ones behind to be clipped by the depth-buffer. You can avoid it either by sorting your particles by distance, and drawing them from further to closer, or by disabling the depth buffer to always draw the particles even if something else is drawn closer. Depending on your blend function and how your particles look like the simple solution of disabling depth testing can be acceptable (glDisable(GL_DEPTH_TEST)), but generally you want to sort the particles, since it can look different when a particle further away is drawn on top of a closer one.

Share on other sites
solved...
I forgot to disable GL_DEPTH_TEST

Thanks to anyone who looked anyway!