我一直在SpriteKit中尝试使用SpriteKit(iOS8中的新版本),即使在一个非常简单的测试用例中,我也得到了糟糕的性能。例如,在SKSpriteNode上使用单光源,在第三代iPad上获得13.2 FPS。如果我添加一个第二光源,它会下降到一个糟糕的7.7FPS。
WWDC会话视频-- SpriteKit中的新内容--提到,如果你在同一个精灵上有一个以上的灯,你可能会得到少于60个FPS,但我甚至不能用一个得到60个FPS。这是相关的部分。
这里是我的快速测试场景(它从一个光源开始,通过点击可以添加更多的光源):
class GameScene: SKScene {
override func didMoveToView(view: SKView) {
let center = CGPointMake(size.width / 2.0, size.height / 2.0)
let background = SKSpriteNode(color: SKColor.lightGrayColor(), size: size)
background.position = center
background.lightingBitMask = 1
addChild(background)
let light = SKLightNode()
light.position = center
light.falloff = 1.0
light.lightColor = SKColor(hue: 0.62 , saturation: 0.89, brightness: 1.0, alpha: 0.4)
light.shadowColor = SKColor.blackColor().colorWithAlphaComponent(0.4)
addChild(light)
}
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
for touch: AnyObject in touches {
let location = touch.locationInNode(self)
let light = SKLightNode()
light.position = location
light.falloff = 1.0
light.lightColor = SKColor(hue: 0.62 , saturation: 0.89, brightness: 1.0, alpha: 0.4)
light.shadowColor = SKColor.blackColor().colorWithAlphaComponent(0.4)
addChild(light)
}
}
}下面是在我的第3代iPad上运行的一些屏幕截图:


下面是性能选项卡在使用单个光源运行时单击“分析”按钮后的样子:

这显然是GPU绑定,但我想弄清楚的是,我只是做了一些可怕的错误,或者这只是一个问题的测试版,将(希望)在发布时间被清除。我目前正在使用Xcode6-Beta5。
更新
我升级了我的iPhone 5S到iOS8,并尝试了同样的东西在那里,它运行非常好,60 iOS8与8个光源。所以,我想这只是第三代iPad的GPU无法完成任务的一个问题。我将在下一个测试版发布后再试一次,看看是否有任何变化,以防万一。
发布于 2014-11-12 01:48:25
在第三代iPad上,这只是GPU的一个问题,无法完成使用SKLightNode的任务。我现在已经在iOS 8和iOS 8.1上测试了最新版本的Xcode (版本6.1 (6A1052d),用于iOS 8.1),结果是相同的。我的测试代码在带有8个光源的iPhone 5s上运行60 test,因此代码本身似乎不是问题所在。
https://stackoverflow.com/questions/25320450
复制相似问题