SKLightNode性能问题 [英] SKLightNode performance issues

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

问题描述

我一直在SpriteKit中尝试 SKLightNode (iOS8中的新功能),即使是在一个非常简单的测试案例中,我的表现也很糟糕。例如,在纯色 SKSpriteNode 上使用单光源,我得到 13.2 FPS 第3代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中的新功能提到如果你在同一个精灵上有多个光源,你可能会得到低于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天全站免登陆