Create triangulated mesh instead of particles

I am new to Metal Kit and Computer Graphics in general.
I was playing around with this sample code:
https://developer.apple.com/documentation/arkit/visualizing_a_point_cloud_using_scene_depth

I want to re-write this app. I wish to render a triangle mesh / triangle strip with custom colors in place of the particles or dots rendered here in this app (on top of the rgb image captured per frame)

I would really appreciate it if someone can point me to the right direction. I know I need to probably re-write the shader file to draw triangles but I can not figure out how.

Any help is appreciated.

Thank you.
Answered by Graphics and Games Engineer in 659157022
As Adam mentioned this would not be a straightforward change to the sample. You would need to group the points provided by ARKit into sets of 3, each describing a vertex of a triangle. You would then render with Metal with a drawPrimitives or drawIndexedPrimitives call using a the MTLPrimitiveType.triangle type.

Since you're unfamiliar with Metal, there's a lot to learn here before you get to this. Metal is a fairly low level API allowing lots of flexibility but requiring a fair amount expertise to use properly. I would suggest starting with some of the Metal Sample code (starting with the Metal Fundamentals samples) to learn about the basics of Metal.

However, if you want the "easy" solution, RealityKit may provide a better alternative to do what you're asking.

I'm also a beginner, so I might be way off base here, but I think what you're talking about is extremely difficult. Consider that when rendering a point cloud, the points are independent from each other - if you want to render them as triangles, how would you identify which points should constitute each triangle? The ordering of the points would also matter. I don't think this is easy to do, especially if you're hoping to end up with something like a continuous surface.
Accepted Answer
As Adam mentioned this would not be a straightforward change to the sample. You would need to group the points provided by ARKit into sets of 3, each describing a vertex of a triangle. You would then render with Metal with a drawPrimitives or drawIndexedPrimitives call using a the MTLPrimitiveType.triangle type.

Since you're unfamiliar with Metal, there's a lot to learn here before you get to this. Metal is a fairly low level API allowing lots of flexibility but requiring a fair amount expertise to use properly. I would suggest starting with some of the Metal Sample code (starting with the Metal Fundamentals samples) to learn about the basics of Metal.

However, if you want the "easy" solution, RealityKit may provide a better alternative to do what you're asking.

Create triangulated mesh instead of particles
 
 
Q