2

I am trying to apply a CIFilter with SKEffectNode to a SKSpriteNode. Can't get this to work and not sure why. I got this working using a blur but cannot get the mono photo effect. Anyone have any insight? Thanks again.

//Mono Effect (not working)
    let filter = CIFilter(name: "CIPhotoEffectMono")
    filter?.setDefaults()
    effectsNode.filter = filter
    self.addChild(effectsNode)
    effectsNode.addChild(SKSpriteNode)

//Blur Effect (working)
    let filter = CIFilter(name: "CIGaussianBlur")
    let blurAmount = 4.0
    filter?.setValue(blurAmount, forKey: kCIInputRadiusKey)
    effectsNode.filter = filter
    effectsNode.blendMode = .alpha
    self.addChild(effectsNode)
    effectNode.addChild(SKSpriteNode)
Lyres
  • 343
  • 4
  • 14
  • I just tested your code and both filters worked as expected. – 0x141E Nov 04 '16 at 08:13
  • does this help: http://stackoverflow.com/questions/38395197/how-to-apply-ciphotoeffectmono-filter-on-image-in-ios – Confused Nov 04 '16 at 08:26
  • 1
    are you setting `shouldEnableEffects` to `true`? Also, provide an example that actually works, your code as of right now will not compile – Knight0fDragon Nov 04 '16 at 13:04
  • Okay so the first effect is working now. I don't know why it wasn't working for me before. And both effects compiled fine for me. So I guess my next question is do you know how to make an effect like this fade in. So it looks like an SKSpriteNode gradually fades to mono? Thanks! – Lyres Nov 07 '16 at 18:21
  • blend alphas between two image states (two different sprites, same content, different states), one that's coloured, one that's mono. – Confused Nov 12 '16 at 17:05
  • Theres a lot of moving sprites in the app, creating double the sprites to achieve this effect would be inefficient. Especially because I am using an emitter node that randomly emits nodes across the screen. – Lyres Nov 12 '16 at 18:59

0 Answers0