An interactive pincushion distortion effect on iOS, built with SwiftUI.
distortion-demo.mov
This was heavily inspired by Janum Trivedi's Magnification Loupe. I used it as a reference for the Metal shader, as well as the spring animations using Wave.
The pincushion distortion is created by calculating the zoom offset for each pixel using it's distance from the center of the distortion and a damped sine wave function.