I am in the process of building a particle system which at the moment is capable of calculating movements based on transform feedback method. Could anyone give some ideas on how to create a trail effect using the history of the positions?
I have 2 VAOs and 2VBOs. The VBOs contain the current and previous position values.
If I want to keep track of say 10 previous positions to create the trail effect, would I declare another VBO with 10 times the size of the VBO that contains all current positions? Or should the initial 2 VBOs be created with 10 times the size of the initial particle count? While updating the destination VBO, how would I only update the new values and push back the older positions further down the buffer? I would really appreciate it if you could give me some tips of solving this issue. Thanks and regards
The following thread talks about the same issue, but I am not sure how the indices are being saved and used to retrieve value from the buffer.
Here is a snippet of my code:
int trailLength = 10;
particles.assign(trailLength*NUM_PARTICLES, SingleParticle()); // this is the vector of particles containing the init pos
mParticleBuffer[mSourceIndex] = gl::Vbo::create(GL_ARRAY_BUFFER, particles.size() * sizeof(SingleParticle),
mParticleBuffer[mDestinationIndex] = gl::Vbo::create(GL_ARRAY_BUFFER, particles.size() * sizeof(SingleParticle),
// Bind the source data (Attributes refer to specific buffers).
// Bind destination as buffer base.
gl::bindBufferBase(GL_TRANSFORM_FEEDBACK_BUFFER, 0, mParticleBuffer[mDestinationIndex]);
// Draw source into destination, performing our vertex transformations.
gl::drawArrays(GL_POINTS, 0, trailLength * NUM_PARTICLES);