Pixelate transition in SpriteKit using CIFilter

Working from Apple documentation I wanted to apply the CIPixellate filter to a SpriteKit Node and found that SKEffectNode grants access to CoreGraphic's filters and could be a good bridge.

I can get the image to pixelate, but I am looking for a smooth transition between the two stages and believe that I am having trouble with the "simd_smoothstep" function:

let pixelateNode: SKEffectNode = SKEffectNode()
let testSprite = SKSpriteNode(imageNamed: "testSprite")
let filter = CIFilter(name: "CIPixellate")!

let inputScale = simd_smoothstep(1, 0, abs(0.9))

let filter = CIFilter(name:"CIPixellate", parameters: [kCIInputImageKey: testSprite, kCIInputScaleKey: inputScale])

pixelateNode.filter = filter
pixelateNode.shouldEnableEffects = true
addChild(pixelateNode)

pixelateNode.addChild(testSprite)

ref: https://developer.apple.com/documentation/coreimage/customizing_image_transitions

Replies

This post can be removed as it has been reposted in the SpriteKit forum.