I'm working on an android app using libgdx, and I'm trying to draw some type of wind particles that leave a trail behind, something similar to this: http://hint.fm/wind/.
I've managed to draw the particles, which are lines that connect the previous position to the newest. However, if I clean the screen every time, it will only draw the current positions, which will be similar to little dots moving, as expected.
What I want to do is to draw a trail behind those particles, that fades away. To do this, I tried creating a list of the previous particle positions and drawing them with a decreasing alpha, but there are to many particles to draw and it proved to be very slow. So I searched, and there is another way to achieve this, which is clearing a screen with some some transparency while I draw the new particles. My solution right now is using this: Unexpected results implementing simple motion blur in Libgdx, and while my desktop rendering works as expected, in the android there is this purple background formed by the white particles that I don't understand. How can I solve this?
This are the screenshots of the android and desktop respectively: https://i.stack.imgur.com/lxY46.jpg
Code:
Pixmap screenClearPixmap = new Pixmap(480, 548, Format.RGBA8888);
screenClearPixmap.setColor(Color.rgba8888(0f, 0f, 0f, 0.1f));
screenClearPixmap.fill();
screenClearTexture = new Texture(screenClearPixmap);
screenClearSprite = new Sprite(screenClearTexture);
screenClearSprite.setSize(480, 548);
screenClearPixmap.dispose();
public void render() {
batch.begin();
screenClearSprite.draw(batch);
batch.end();
animate();
}
public void animate() {
moveParticles();
drawParticles();
}
public void drawParticles() {
shapeRenderer.begin(ShapeType.Line);
shapeRenderer.setColor(Color.WHITE);
...
shapeRenderer.line((float) particle.getOldX(), (float) particle.getOldY(), (float) particle.getX(), (float) particle.getY());
Gdx.gl20.glLineWidth(Global.LINEWIDTH);
shapeRenderer.end();
}