18

I am trying to implement animation in a still image in a user-guided direction, something like this:

Original image

original image

Expected result

expected result

For this, I have tried the CIBumpDistortionLinear CIFilter. It is animating, but the animation is not exactly like that.

let bumpDistortionLinearParams: [String: AnyObject] = [
    kCIInputImageKey: coreImage!,
    "inputCenter" : CIVector(string: coordStr),
    "inputRadius": 300.0 as AnyObject,
    "inputAngle" : 90.0 as AnyObject,
    "inputScale" : 0.1 as AnyObject
]

let bumpDistortionLinear = CIFilter(name: "CIBumpDistortionLinear", parameters: bumpDistortionLinearParams)
A J
  • 605
  • 4
  • 16
MobileGeek
  • 2,462
  • 1
  • 26
  • 46
  • Is this possible with MetalKit via creating shader on image? Is this resolved for you? – A J Jul 03 '19 at 13:21
  • It is possible with Metal Kit. I am looking for similar effect with shader for which selected draw area will not animate (similar to masking in plotaverse). Any Idea? – A J Jul 25 '19 at 06:24

1 Answers1

1

You can use SpriteKit with SKTexture / SKTextureAtlas.
Small example:
https://www.raywenderlich.com/144-spritekit-animations-and-texture-atlases-in-swift

Update:
If you need dynamic animation, you can make solution base on Metal
Example:
https://github.com/KrisYu/Water
Metal tutorial:
http://metalkit.org/

Eysner
  • 584
  • 4
  • 15
  • I'll need to implement that dynamically on any user captured photo. Does SKTexture will help on it. if you think so, can you provide any example or code ref. – MobileGeek Jun 20 '19 at 09:05
  • @Arvind If you need dynamic animation, you can use Metal. It maybe help: https://github.com/KrisYu/Water SKTexture can’t do this (or I don’t known how) – Eysner Jun 20 '19 at 11:17
  • @Eysner: I am looking for similar animation on different images. That is not exactly the water effect. The animation will be in user guided direction. You can try on https://plotaverse.com for better understanding. – A J Jun 21 '19 at 06:27