CIGaussianFilter is not centering effect

45 Views Asked by At

On iOS, I want to apply a CIGaussianFilter on an SKShapeNode which is a simple rectangle, however the blurred image doesn't remain centered.

override func didMove(to view: SKView) {
        
    barra = SKShapeNode(rectOf: CGSize(width: 300, height: 100))
    barra.fillColor = .white
    addChild(barra)
}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    let blur = CIFilter(name:"CIGaussianBlur",parameters: ["inputRadius": 20.0])
    effectsNode = SKEffectNode()
    effectsNode.filter = blur
    effectsNode.blendMode = .alpha
    effectsNode.shouldCenterFilter = true
    effectsNode.shouldEnableEffects = true
    effectsNode.shouldRasterize = false


    effectsNode.addChild(barra)
    addChild(effectsNode)
}

But the more the shape is blurred, the more it will get to the upper-left part of the screen. How can I avoid this and keep the image centered ? enter image description here

0

There are 0 best solutions below