Hello,
I am simulating a cloth using a large particle system with WebGPU and its compute shaders.
How can I use 32 bits indices with Mesh.setIndexBuffer() instead of 16 bits ?
Relevant parts of the code:
const indices = new BABYLON.StorageBuffer(this.engine, indicesArray.length * 2, BABYLON.Constants.BUFFER_CREATIONFLAG_INDEX | BABYLON.Constants.BUFFER_CREATIONFLAG_WRITE);
indices.update(new Uint16Array(indicesArray));
mesh.setIndexBuffer(indices.getBuffer(), vertexCount, indicesArray.length); // mesh is broken if there is more than 65kB vertices.
Fixed it.
It seems (though I could not find any documentation about this) that setIndexBuffer expects 16 bits buffer if indicesArray.length<= 65535, 32 bits else.
So the solution is simple: