Particle issue only with high number of particles


I was playing around with TransformFeedback and wrote a very simple physics simulation for now, but I noticed that with a high particle count (100k) sometimes particles would get stuck, but since my physics code is so simple I don’t see how that is possible.

The project is here:

The feedback vertex shader doing the “physics” is this:

var vertexFeedbackShader = `
attribute vec4 aPosition;
varying vec4 out_aPosition;

attribute vec3 aVelocity;
varying vec3 out_aVelocity;

// parameters controlling simulation
uniform float u_timestep;
uniform vec3 u_gravity;

void main(void) {
    vec3 vel = aVelocity * 0.9 + u_gravity * u_timestep;
    vec3 pos = + vel * u_timestep;

    if(pos.y < 0.0){
        vel.y *= -0.4;
        pos.y = 0.0;

    // write out updated particle
    out_aPosition = vec4(pos, 1.0);
    out_aVelocity = vel;

Am I hitting some sort of buffer limit here?

@mvaligursky any idea?

If your math depends on dt, then could be an issue due to first frame dt being a zero?

1 Like

This happily works with 200k
I just changed it (right there in the code editor) to 1M and still no problem.

1 Like