I would like to create a shader that simulates gravity between 2 particles. For this, each particle must know the position of the other particles, update its position accordingly, and therefore "share" its new position with the other particles.
If I understand correctly, when I do:
material = new THREE.ShaderMaterial({
depthWrite: false,
blending: AdditiveBlending,
vertexColors: true,
vertexShader: galaxyVortexShader,
fragmentShader: galaxyFragmentShader,
uniforms: {
uTime: {value: 0},
uSize: { value: 10 * renderer.getPixelRatio()},
uPositions: { value: positionsVec3}
}
});
I create a shader for each particle ? The problem is that I send the position of all the particles once in "uPositions", but if each particle has its own shader, how can they update their position in the uPositions array to share it to other particles ?