Generating triangle mesh in cuda using nanovdb

227 views
Skip to first unread message

mi...@crabcat.com

unread,
Jan 31, 2022, 10:31:47 PM1/31/22
to OpenVDB Forum
Hi all,

Firstly: congrats to everyone involved in the creation of nanovdb.  It is a great tool and very exciting for us to get our hands on.  Thanks!

Our default way of viewing our grids is as raw triangle mesh visualisations where a voxel is displayed as a cube.  This is because it is how our users are used to viewing their data in other tools (mining industry).  We couldn't find any examples of generating triangle mesh data using nanovdb (maybe because cuda isn't ideal to generate this kind of data?) so we decided to try creating our own prototype.

I'm keen to hear about any examples or any experience that anyone else has had generating triangle meshes.

Our first issue was that nanovdb doesn't appear to offer any tools for node iteration (e.g. to call a kernel per node). To deal with this we generate an array of bounding boxes which contains a box for each lower internal node and just hand that along with the device grid into each kernel.  In each kernel we typically iterate the voxels using the CoordBBox iterator. Does this sound OK? 

We've tried two approaches:
1. Allocate a 'meshlet' to accommodate the maximum num triangles expected for each lower node.  Run kernel for each lower node to iterate the voxels and generate triangles.
2. Two pass.  Call the kernel for each lower node first to count the triangles and vertices required.  Second call actually generates the triangle mesh.  

The first approach allocates far too much memory and requires a compaction kernel to reduce the meshlets into a single triangle/index space. Some of our datasets can't be displayed.

The second approach literally calls our code twice and so some of our larger datasets can take 600ms (RTX2060, 80M voxels) instead of maybe 400ms.  

Our existing openvdb code for generating these meshes is much more complex so I haven't been able to truly compare apples with apples yet but my gut feel is that it is several times faster (compared to my i9 14 core).

Anyone have any suggestions? 

Thanks,
Mike
Reply all
Reply to author
Forward
0 new messages