Particle mixing fragments but no background

I have the following process:

- draw background - draw objects and blend with background (1)GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA - draw particle effect with blending (2)GL10.GL_SRC_ALPHA, GL10.GL_ONE in order to highlight overlapping particles 

The problem is when I draw a particle, they additionally mix with the background and become very bright.

I just need to mix the particles with (2) and all together to mix with the background using (1).

Broken solutions:

  • The effect of drawing a texture and applying it works fine ... but very slowly.
  • Drawing the particle effect first, and not the background, it looks fine ... but I can't draw the scene object, and not because they should be between bg and the effect.

Here is a screen to show the difference. On the desired desired result, the left particles are mixed with the background.

img:

enter image description here

I would be grateful for any help ...

Recent updates: I managed to get the color that I want ... but ... (It seems that this will not move me anywhere) I provided the background with alpha = 0 and used the blend Function function from GL11Ext: glBlendFuncSeparate (GL10.GL_SRC_ALPHA, GL10. GL_DST_ALPHA, GL10.GL_ONE, GL10.GL_ONE);

GL10.GL_SRC_ALPHA, GL10.GL_DST_ALPHA - colors mix only if they have alpha (now no bg)

GL10.GL_ONE, GL10.GL_ONE - for maximum values ​​for all recorded particles for additive mixing modeling

enter image description here

It works fine, as you can see ... except for the black fill area, where the particle image has alpha 0 .. and what's bad is that the resulting image has black that has alpha 1, so I can’t do it in any way replace ...

EDIT_2 A common problem in simple words: I need to draw a red (0xff0000) glowing (additive blending effect). On a black background this is normal, but if I took green (0x00ff00), than the color of the result would be close to 0xffff00

Any ideas?

+7
source share
3 answers

GL10.GL_SRC_ALPHA, GL10.GL_ONE to highlight overlapping particles.

There is no other way than additive mixing to avoid the need for sorting particles. If you still want to adhere to this to avoid overlapping particles, I suggest that you embed the bleeding control in the rendering so that you can reduce the rigidity of the processed particles or reduce the brightness of the particle texture.

+2
source

You can use glAlphaFunc (GL_GREATER, 0) to deflect alpha = 0 fragments from particles. Remember glEnable (GL_ALPHA_TEST) first, though.

+1
source

Will there be rendering for a separate frame buffer? Do you add an additive mixture of all your particles to a full transparent frame buffer, and then perform a normal alpha mixture of that frame.

0
source

All Articles