0
votes

I am implementing a paint program in SpriteKit and I am super impressed by the simplicity of implementation SprikeKit enables. Very cool indeed!

Each brush stroke is implemented as a SKSpriteNode with attached SKShader. Everything works as I expect.

Issue: Currently I am steadily growing the SKScene graph as brush strokes are appended. This is not a scalable solution as resource consumption mushrooms and framerate slows to a crawl. So, what I want to do "bake" the SKScene graph after brush stroke is painted.

I tried setting myScene.shouldRasterize = YES on my SKScene instance but it appeared to have no effect. How do I "bake" rendering results in SpriteKit? Do I have to roll my own?

Thanks,
Doug

2

2 Answers

1
votes

The only was I can think of to do this is to call textureFromNode on your SKView passing in the SKNode that you want to "bake". Then take that texture, apply it to a SKSpriteNode, and remove the SKNode(s) that you just "baked" in to the texture.

1
votes

Wanted to add a comment but reputation won't allow me. Just would like to add that you can rasterize group of sprites by using SKEffectNode. Just add any sprite to this node then use the same shouldRasterize property. You can even apply CoreImage filters to it such as Gaussian Blurs.

The downside is obviously performance when created the rasterized node.