I'm trying to optimize my SceneKit app by reducing draw calls. From the Apple Documentation, and many WWDC talks, combining many child nodes into a single node via flattenedClone() should reduce draw calls, but I am unable to reduce draw calls by utilizing this method.
I have attached a simple example SceneKit app that demonstrates how flattenedClone is not reducing draw calls.
When the app starts, 5 objects are displayed, and you can see 5 draw calls. (well, 6 actually if you interact with the camera).
Then, if you press the toggle button, the 5 nodes will be flattened into a single node. This still results in 5 draw calls!
This seems to completely contradict all sorts of documentation and talks around flattenedClone. Any ideas on what's happening?
You can run the simple app here, either in the simulator or iOS device: https://drive.google.com/open?id=1ZJQZAnHtOCeK_3WzbdD0vLLJ2kWTKao- Note that you need to wiggle the camera around to get the draw call statistics to update.
let nodes = SCNScene.init(named:
"nodes.scn")!.rootNode.childNode(withName: "parentNode", recursively: true)!;
//Unflattened version:
scene.rootNode.addChildNode(nodes)
//Flattened version:
let flattenedNode = nodes.flattenedClone()
scene.rootNode.addChildNode(flattenedNode)