0

I have a scene with multiple light nodes. Normally my game runs fine at 60fps on a late 2016 Macbook Pro. (The game is for mac, not iOS). When a light node is added the frame rate drops, and once there are 4-5 nodes it's extremely slow and laggy. I'm creating them like this:

let light: SKLightNode = SKLightNode()
light.falloff = 4.5
addChild(light)

I know that the lighting effects need a lot of rendering power, but I'm surprised at how fast they cause issues.

Any ideas on how I can improve performance?

CodyMace
  • 646
  • 1
  • 8
  • 19

1 Answers1

0

SKLightNodes are very performance intensive, especially on older devices.

For example if you use 2 LightNodes in 1 SKScene on an iPhone 5 the frame rate drops to like 20FPS and makes the game basically unplayable.

I recently made a game with 4 lights in a scene and everything was fine on a iPhone 7, but on an older device it was unusable.

So IMO you should not use more than 1 SKLightNode per Sprite/Scene, maybe 2 max otherwise performance will be very bad. I am not sure how the performance is on macOS but the way you described it using 4-5 lights is way too much. So there is not too much you can do to improve performance.

SKLightNode performance issues

The WWDC session video What's New in SpriteKit mentions that you might get less than 60 FPS if you have more than one light on the same sprite.

Hope this helps

Community
  • 1
  • 1
crashoverride777
  • 10,581
  • 2
  • 32
  • 56
  • Hmm, ok, thanks. I might just need to do some trickery for a work around because I really need those lights. I'll probably do something like make the background black, because adding the light effects to that node seem to cause the most slowdown. – CodyMace Feb 20 '17 at 18:44
  • Yeah I had to do the same with my games. They still dont run great on old devices. Just make sure you test well. Happy coding – crashoverride777 Feb 20 '17 at 19:06