views:

33

answers:

1

I'm trying to create a particular effect where I have a bunch of particles on the screen which leave trails that slowly fade. I was hoping that I could simply use glClear with a small alpha value to do this but that doesn't seem to be working. My second idea was to draw a black face on the front of the screen but this doesn't seem to be giving me the right effect, the particles are faded but the background doesn't really fade. My next idea is to render to a texture and fade that texture but that's a lot of extra work and I'm not sure if it will solve my problem. Can anyone think of a way to do this? Am I missing something?

Edit Also I'm having trouble finding information about rendering to a texture on android. If anyone has some links to articles that would be great.

A: 

Hi,

Assuming that your 'particles' ar just a bunch of textured sprites, you can simply add color data for each vertex of the sprite using glVertexPointer(). The color you set for the vertices will then be blended with the texture of the sprite. You can easily update these values to achieve a 'fading' effect.

E.g. if you set RGBA = (1,1,1,1) for each vertex, the sprite will appear as before (no translucency), set RGBA = (1,0,0,1) the sprite will appear red (no translucency), set RGBA = (0.5,0.5,0.5,0.5) the sprite will appear half translucent, etc. You will have to set the correct glBlendFunc() beforehand to get the desired behaviour!

Cheers, Aert.

Aert
That's what I'm doing. But what I want is to have the particles leave colored trails. Not clearing the color buffer achieves this but then I want the trails to fade out.
skorulis
Ah I see; Perhaps just spawn additional ones and fade them out then. I think that's how your everyday particle engine does it. Take a look at the particle engine source code of AndEngine (http://code.google.com/p/andengine/source/browse/src/org/anddev/andengine/entity/particle/ParticleSystem.java), that might give you an idea of how to do it.
Aert