如何在 Sprite-Kit 中制作原生(实时)模糊?

How to make native (realtime) blur in Sprite-Kit?

我正在使用此代码进行模糊处理,但它似乎不起作用。或者它有点管用。我只能看到灰色背景,而不是模糊的场景。 (第一张照片,我用屏幕截图捕捉了它,但捕捉它就像它工作得很好,很奇怪。)当我向下滑动时,它通常会模糊场景。

UIBlurEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIVisualEffectView *blurEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
[blurEffectView setFrame:self.view.bounds];
[self.view addSubview:blurEffectView];

The screenshot captures it normally but i can only see grey background.

Here when i swipe down, it works like charm.

我为此找到了不同的解决方案,但那些只是静态的。我想要这种类型的模糊,它甚至不会降低任何 fps。有没有办法让这个工作?

  1. 模糊 效果由 Core Image Filter 提供。
  2. 每个 Core Image Filter 都可以与 SKEffectNode
  3. 一起使用
  4. SKScene 是一个 SKEffectNode

然后...

class GameScene: SKScene {

    override func didMove(to view: SKView) {
        super.didMove(to:view)

        self.filter = CIFilter(name: "CIGaussianBlur", withInputParameters: ["inputRadius": 10])
        self.shouldEnableEffects = true

    }
}