SKLightNode 性能问题 [英] SKLightNode performance issues

查看:17
本文介绍了SKLightNode 性能问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在 SpriteKit(iOS8 中的新功能)中试验 SKLightNode,即使在一个非常简单的测试用例中,我的性能也很糟糕.例如,在 纯色 SKSpriteNode 上使用 单一光源,我在 上获得 13.2 FPS第三代 iPad.如果我添加第二个光源,它会下降到糟糕的 7.7 FPS.

I've been experimenting with SKLightNode in SpriteKit (new in iOS8) and, even in a really simple test case, I've been getting terrible performance. For instance, with a single light source on a solid color SKSpriteNode I get 13.2 FPS on a 3rd generation iPad. If I add a second light source, it drops to an abysmal 7.7 FPS.

WWDC 会议视频 SpriteKit 中的新功能 提到,如果您在同一个 sprite 上使用多个灯,您可能会获得低于 60 FPS,但我什至无法获得 60 FPS.这里是相关部分.

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, but I can't even get 60 FPS with one. Here's the relevant section.

这是我在 swift 中的测试场景(它从一个光源开始,可以通过点击添加更多):

Here's my test scene in swift (it starts with one light source and more can be added by tapping):

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)
        }
    }

}

以下是它在我的第三代 iPad 上运行的一些屏幕截图:

Here are some screen shots of it running on my 3rd gen iPad:

以下是使用单个光源运行时单击分析"按钮后性能选项卡的外观:

And here's what the performance tab looks like after clicking the "Analyze" button when it's running with a single light source:

这显然是受 GPU 限制的,但我想弄清楚的是,我是否只是在做一些可怕的错误,或者这只是测试版的一个问题,(希望)会在发布时得到解决.我目前正在使用 Xcode6-Beta5.

It's obviously GPU bound, but what I'm trying to figure out is if I'm just doing something horribly wrong, or if this is just an issue with the beta that will (hopefully) be cleared up by release time. I'm currently using Xcode6-Beta5.

更新

我将我的 iPhone 5S 升级到 iOS8 并在那里尝试了同样的事情,它在 60FPS 和 8 个光源下运行得非常好.所以,我想这只是第三代 iPad 的 GPU 无法胜任任务的问题.我会在下一个测试版发布后重试,看看是否有任何变化,以防万一.

I upgraded my iPhone 5S to iOS8 and tried the same thing there and it ran perfectly fine at 60FPS with 8 light sources. So, I guess this is just an issue with the 3rd generation iPad's GPU just not being up to the task. I'll try again after the next beta is released and see if anything changes, just in case.

推荐答案

这最终只是第三代 iPad 上的 GPU 无法完成使用 SKLightNode 的任务.我现在使用当时最新版本的 Xcode(iOS 8.1 的版本 6.1 (6A1052d))在 iOS 8 和 iOS 8.1 上进行了测试,结果相同.我的测试代码在具有 8 个光源的 iPhone 5s 上以 60FPS 的速度运行,因此代码本身似乎不是问题.

This ended up just being an issue with the GPU on the 3rd gen iPad not being up to the task to using SKLightNodes. I've now tested on iOS 8 and iOS 8.1 using the latest version of Xcode at the time (Version 6.1 (6A1052d) for iOS 8.1), with the same results. My test code runs at 60FPS on a iPhone 5s with 8 light sources, so the code itself doesn't seem to be the issue.

这篇关于SKLightNode 性能问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆