3

I have a Metal-backed SceneKit project where I'd like to draw a curve that is modified on the CPU every frame. This seems like it should be a simple task; one that I've done in OpenGL many times.

Something like:

array_of_points[0].x = 25
array_of_points[0].y = 35
upload_array_to_gpu()
render_frame()

It seems that modifying the SCNGeometrySource of an SCNNode is not possible. Recreating and setting the node.geometry works but the position lags / jitters compared to other nodes in the scene. Recreating the entire node each frame also lags.

One possible avenue might be a geometry shader modifier, but I'd still have to somehow pass in my cpu-computed curve positions.

Another option is to use metal APIs directly. Though this approach seems like it will require lots more code, and I couldn't find too much info about mixing SceneKit with Metal.

I also tried setting the preferredRenderingAPI to OpenGL, but it doesn't change the renderingAPI.

Guig
  • 9,891
  • 7
  • 64
  • 126
Morty
  • 1,436
  • 14
  • 12
  • The answer https://stackoverflow.com/questions/30888445/scenekit-shader-modifiers-with-glsl-arrays shows a way to pass CPU floats to a SceneKit shader modifier. Does that approach work for you? – Hal Mueller Jun 20 '17 at 21:19
  • Thanks Hal, ya this approach does work; it just seems a bit odd to send in my vertices this way and essentially ignore the original model vertices. I had some luck mixing metal code that I will try and post soon. – Morty Jun 21 '17 at 14:45

0 Answers0