SceneKit SCNProgram for a Billboard Shader in Metal

318 Views Asked by At

I'm looking for an example of a billboard texture shader that I can use with SceneKit.

I have a landscape of tiny red dots that I need to render. The dots all need to face the camera head-on.

Using SceneKit, I've managed to render the landscape's geometry and I've made a pattern texture for the dots. This looks roughly like the desired output, however, the dots shouldn't be skewed along the contours of the landscape they should all look face onto the camera and be a perfect circle when viewed from any angle.

At the moment they look like this... Red dots

But the effect should be along the lines of this... Balls facing camera

I've reached out to Apple and they have suggested writing a billboard shader in Metal and plugging that into my SceneKit code as an SCNProgram.

That's a daunting task though so if anyone's done anything similar before it would be very helpful to see the code.

1

There are 1 best solutions below

2
On

It's not clear to me how your currently solution works. Do you have a single geometry or one for each dot? Fort billboard you would need one geometry per dot.

Here are possible solutions:

  1. Manually orientate the nodes
  2. Use a SCNBillboardConstraint
  3. This looks a lot like a point cloud, see SCNGeometryPrimitiveTypePoint and Rendering Point Clouds