Modified so it only sends to GPU the position data for a single vertex. The key function is on VertexBuffer, .updateDirectly(tempVectorArray, pcs.counter*3,false);
To answer my questions above:
I hope “pcs.computeParticleColor = false;” disables color transfer, but not sure if uv data is transferred. Maybe “pcs.computeParticleTexture” controls uv VerticesData transfers?
This is correct. computeParticleTexture controls the update of the UvKind VertexBuffer.
I also hope that “pcs.setParticles(pcs.counter,pcs.counter)” only transfers the single position (12 bytes) at the index pcs.counter.
This is incorrect. PointsCloudSystem.setParticles() only calls .updateParticles within the range specified, but afterwards send the entire updated buffer to the GPU.
I think I can reduce the CPU space of colors by using the same Babylon color object, but I presume it is expanded into an ArrayBuffer in prep for transfer to GPU.
This is correct.
It would be great if I could specify a single Color4 for all particles, but I’m doubtful that has been implemented (as my use case is fairly niche).
I couldn’t find where this is implemented. The full ColorsKind VertexBuffer is created, though “pcs.computeParticleColor = false;” does prevent updates to the GPU buffer.
I was able to implement the update fairly straightforwardly by retaining the PositionKind VertexBuffer and calling .updateDirectly() on it. This means the CloudPoint array is not involved at all after first creation. Basically, I use PointsCloudSystem to create the mesh and use the material/shader of that created mesh. After creating the mesh, I bypass the PointsCloudSystem object and update the mesh’s PositionKind VertexBuffer directly. This also bypasses all the per-vertex rotation calculations in PointsCloudSystem. setParticles().
This works well for me (even though I don’t know how to verify the performance optimization). I’m not sure generalizing the optimization I’ve done would be beneficial because usually user code is modifying a CloudPoint object, which then would need copying into VertexBuffers then sent to the GPU (using “mesh.updateVerticesData()” on lines 914-922).
However, it looks like the VertexBuffers needed are retained in an array or map on the mesh object and thus can be retreived quickly if neede for a call to .updateDirectly(). This appears to be a possible future optimization for PointsCloudSystem.
Edit: see this thread for more info on partially updating VertexBuffer.