Objective-C Question

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

I am using this code for my blur, but it doesn't seem to work. Or it kinda works. I can only see a grey coloured background instead of the blurred scene. (First picture, I have captured it using a screenshot, but that captures it like its working great, weird.) And when i swipe down, it blurs the scene normally.

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.

I have found different solutions for this, but those were only static. I want this type of blur, it doesn't even drop any fps. Is there a way to get this working?

Answer

Since

  1. The blur effect is provided by a Core Image Filter.
  2. Every Core Image Filter can be used with a SKEffectNode
  3. SKScene is an SKEffectNode

then...

class GameScene: SKScene {

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

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

    }
}

enter image description here