I've been working on a particle system using three.js that involves using regular JavaScript loops to change particle positions, but I've found that this method is quite slow.
Due to this performance issue, I've decided to delve into transferring the calculations to the GPU via shaders.
However, I've encountered an issue where I'm unable to get the positions to update properly. Each particle seems to remain at its initial position.
var vertexShader = [
'void main() {',
' vec3 newPosition = position.xyz;',
' newPosition.y += 10.0;',
' gl_PointSize = 1.00;',
' gl_Position = projectionMatrix * modelViewMatrix * vec4( newPosition, 1.0 );',
'}',
].join('\n');
My question is, why does
' newPosition.y += 10.0;',
not update the particle positions as expected?
Do I need to introduce some sort of time variable into the shader code, as I've noticed others doing this in their implementations? Any advice would be greatly appreciated.