Cloning nodes and performance, geometry, and performance; IOS Scenekit

1.5k views Asked by At

I'm writing a app using Scenekit where the client wishes to push the limits of animation in IOS. This particular app has requirements where I"m pushing out to the screen over 1,500 redraws. Even with this many redraws, I've locked down the FPS to 60, which is great, but when I add all elements the client wants, the redraws are pushed to 7,500 redraws (and yes, this isn't a mistake or a joke, this is the redraw number even though it's almost 50-80 times more than most redraw times I've seen with scenekit). At this level of redrawing, the screen contains 1.7 million vertices, and around 800k polygons. This is a a lot of stuff, and it's really too much stuff for this app to be useful to anyone because now my FPS drops to 15-30FPS which is expected from drawing over 3K geometry elements on screen. What I've done so far:

  1. I clone all nodes, cloning allows me to push the limits of Scenekit. I was able to fit on screen over 1.5k constant CAAnimations with over 1.8K unique geometries placed in different locations across the screen.

  2. I've forced all windows, views, and screens in app to be opaque by looping through all windows and setting their opaque property to yes.

Question is this, I can deal with the performance issues, but I'm having a problem with the node cloning. Well, the node cloning works, but the problem is that each geometry that is pushed to the screen must have a different size and it seems like there is no way to change the geometry of each separate clone. I know that I can change the geometry of a "copied" node (SCNNode *node = [masterNode copy];), and I know I can change the materials property of a cloned node, but is there a way to change the geometry of the cloned node? Apple doesn't give any insight about the geometry being changed, but they do talk about changing the materials. Am I to assume that I can't change the size of the geometry of the clone? I can change the transform, pivot, rotation, animation, position, etc, of the clone, but the size of the geometry won't change. For my purposes, I just need the "height" variable of a cylinder to be changeable, I have everything else in good order, AND, there's no other way to push over 2k redraws to a screen without node cloning, I've tried it without cloning and FPS drops to less than 10 with just 300 redraws when declaring each geometry and node with geometry as it's own unique variable.

Lastly, given this same scenario, how much of a performance increase should I expect by moving from Scenekit to Metal. I'm not worried about the math, the level of detail, the time consuming operations of setting up the rendering pipeline or whatever else might come my way, I'm merely trying to find the BEST solution for my problem here, and I've not used Metal yet because I'm not sure I'd get different results given how many polygons, vertices, and redraws are required. Thanks.

1

There are 1 answers

6
IvanAtBest On BEST ANSWER

is there a way to change the geometry of the cloned node

I believe you can change the baked geometry itself, but not the parametric one (not the SCNCylinder). So you can (to change the height):

  • Scale the node
  • Change the Transformation Matrix (so scaling too, just a different way to)
  • Add a Geometry Shader modifier that moves the points up/down on the axis you want

Changing the actual geometry kind of defeats the whole purpose of cloning, so I don't think there is a way around that.

Lastly, given this same scenario, how much of a performance increase should I expect by moving from Scenekit to Metal.

A lot. Around 30% from what I've seen, but again it will depend on your setup. Metal comes with iOS 9, and you won't have to do anything to get it for your scene, so just update one of your devices and try it there, to see if it helps!

Out of curiosity: why do you need so much cylinders? Could you not cheat the way they are rendered?