PDA

View Full Version : Particle system blending



Watcher
04-26-2003, 11:17 AM
I'm fairly new to OpenGL, and I'm in the process of making a simple particle system. Everything was going well until I changed my background color. On a black background, the particles blend together fine and display correctly. On any other color background, the background color starts to blend with the particles and once I switch to a white background it blends my particle system out of sight. I've tried several different blending modes to no avail -- either the background interferes with the particle or the particles don't blend and appear very blocky. I thought that GL_DST_ALPHA might be able to fix the problem -- just set the background alpha to 0 and it won't blend, but unfortunately Windows' ****ty implementation doesn't support it so I can't test it out.

Is there any way to exclude the background color when blending? With my luck, its going to involve something like low level manipulation of the color buffer :P

shinpaughp
04-26-2003, 06:37 PM
If you have a semi-decent GPU it should support greater than OpenGL v1.1 (MS implementation). You may just need to download and #include "glext.h". A link can be found here (http://www.opengl.org/developers/faqs/technical/extensions.htm#exte0090) .

But, a good blend func to use is glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and may do the trick.

Watcher
04-26-2003, 07:25 PM
I tried alpha, 1 - alpha blending, but since it blends the polygons with the same mode it darkens the particle system drastically. The file you linked me to works though for the most part. I can get the particle system to show up properly against anything except a white background (even a white polygon). Kind of strange, but I'm just happy that it works now. Thanks bro.

shinpaughp
04-26-2003, 09:37 PM
Also, try these 1 at a time of course.

glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
glBlendFunc(GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR

One of them may do the trick.