microsoft/scenepic

Support for rendering large point clouds

Closed this issue · 3 comments

Hi,

This seems like a great visualization tool for 3D problems! It would be nice to have some support for rendering large colored and lit point clouds. I tried adding spheres to a scene (one per point) but this slowed down very quickly for even a moderately large number of spheres (~10-50k). It would be nice to have support for rendering very large point clouds!

We absolutely support this! We have some examples in the tutorial for point clouds:

C++ tutorial:

void point_clouds_1()
{
std::cout << "== Point Clouds 1 ==" << std::endl;
// Create a scene
sp::Scene scene;
// Create a mesh that we'll turn in to a point-cloud using enable_instancing()
auto mesh = scene.create_mesh();
mesh->shared_color(sp::Color(0, 1, 0));
mesh->add_cube();
mesh->apply_transform(sp::Transforms::scale(0.01f));
sp::VectorBuffer positions = sp::random<sp::VectorBuffer>(10000, 3, 0, 1);
positions = (2 * positions).array() - 1;
mesh->enable_instancing(positions);
// Create Canvas and Frame, and add Mesh to Frame
auto canvas = scene.create_canvas_3d("", 300, 300);
canvas->shading(sp::Shading(sp::Colors::White));
auto frame = canvas->create_frame();
frame->add_mesh(mesh);
scene.save_as_html("point_clouds_1.html", "Point Clouds 1");
}

Python tutorial (also in the Jupyter notebook of course):

scene = sp.Scene()
mesh = scene.create_mesh(shared_color=sp.Color(0, 1, 0))
mesh.add_cube()
mesh.apply_transform(sp.Transforms.Scale(0.01))
mesh.enable_instancing(positions=2 * np.random.rand(10000, 3) - 1)
canvas = scene.create_canvas_3d(
width=300, height=300, shading=sp.Shading(bg_color=sp.Colors.White))
frame = canvas.create_frame()
frame.add_mesh(mesh)

The key thing is to use the enable_instancing function on the mesh. It should be able to support as much as your graphics card can handle. Please let me know if this resolves your issue.

Thanks! This does work for me. I somehow missed the tutorial. I couldn't find a link in the main documentation. It would be really great to have a more fleshed out tutorial in the main documentation, but I'm sure this will happen eventually. Thanks for the cool library!

Great feedback! We'll work on making this more front and center in our documentation, as it is a very common use case. Thanks!