I am rendering a point-cloud using Bevy, but currently spawning a icoshpere for each point, which gets quite slow with 775k points. What is the easiest way to use mesh instancing to reduce overhead?
This is the code for how I am doing it currently:
for point in &pointcloud_assets.get(&pointcloud.church).unwrap().points {
commands
.spawn_bundle(PbrBundle{
mesh: sphere.clone(),
material: material.clone(),
transform: Transform::from_translation(*point / 10.),
..Default::default()
});
}
I found this example: https://bevyengine.org/examples/shader/shader-instancing/ but it is called shader-instancing, and I am not sure if it is the same thing. It also seems quite complex, so I was wondering if there wasn't a simpler solution.
If you don't need it to run on a browser and you're ok with cubes then https://github.com/ForesightMiningSoftwareCorporation/bevy-aabb-instancing/ (maybe this can do non-rectangles too?). It works for me and is pretty speedy.
The other option you could try is https://github.com/Shfty/bevy_instancing which is a suggestion as to how bevy could choose to support instancing. I can't comment yet on whether it works on the browser.
At the moment those seem the only 3 options unless you want to code up a 4th. Watch this space: https://github.com/bevyengine/bevy/issues/89