Possibly related: Optimizing SceneKit performance with high-res textures
I am mapping a SKScene
onto a board geometry to create a board game. The scene needs to be relatively large (2048x1024) so that I can zoom in on the action and still have pretty details. Now, to solve this common problem I already know about two approaches:
- Use lower resolution textures when zooming out (i.e. mipmapping) -
That's not an issue,
SceneKit
does it for me. - Tile the scene for close-ups and only display those tiles that are on screen.
Now the second point gets me thinking. How can I tile up a SKScene and map them to different locations on the geometry? Is there another way to make this work?
Screenshots
This is the geometry with a static image (2048x1024) as texture:
This is the geometry with a SKScene
(2048x1024) as texture:
The scene does not contain any physics bodies, just about 40 SKSpriteNodes
that do nothing. I need it to be able to change the colors of territories, maybe add some additional overlays etc. Would there be a way to do that with SceneKit
, entirely? Maybe create a geometry for each territory?
Implemented Answers
I have now tried to achieve the same scene using SceneKit
only. Each territory is a quad, using textures with pre-rendered borders included. Different blend modes help the underlaying paper texture to come forward. Unfortunately, the performance hit is roughly the same - My conclusion is that it's not SpriteKit
after all that hogs resources, but the node count in combination with high-res textures (which are sadly needed to keep borders crisp if you're not using paths).
Are the SKSpriteNodes your territories? That is, one SKSpriteNode per territory? From the huge performance hit you saw when going from a static image to SKScene, it sounds like SpriteKit is what's killing you.
It would be interesting to try using SCNShape geometries, one per territory, instead of using a SpriteKit-derived texture, perhaps adding a levelOfDetail or two to each territory node. I don't see offhand how to get the same darker-toned boundary effect you're using. But you could do some interesting effects with SCNShape, for instance animating a change to the extrusion depth for a given territory.