uniform float dt; uniform vec3 handPos[2]; uniform vec3 handVel[2]; struct particle_t { vec4 positionAndSize; vec4 velocity; vec4 padding2; // for LÖVR's limited ShaderBlock type :( vec4 padding3; // for LÖVR's limited ShaderBlock type :( }; layout(std430) buffer particleData { float reloadFlag; particle_t particles[]; }; vec3 wrap(vec3 v) { return mod(v, 2.0) - 1.0 + vec3(0.0, 1.0, 0.0); } layout(local_size_x = 128) in; void compute() { uint id = gl_GlobalInvocationID.x; vec3 vel = particles[id].velocity.xyz; vec3 pos = particles[id].positionAndSize.xyz; for (int i = 0; i < 2; i++) { float speed = clamp(length(handVel[i]), 0.0, 3.0); float dist = distance(handPos[i], pos); float factor = 1.0 - smoothstep(0.0, speed * 0.1, dist); vel = mix(vel, handVel[i], factor * 0.01); } particles[id].positionAndSize.xyz = wrap(pos + vel * dt); particles[id].velocity.xyz = vel - vel * length(vel) * dt; }