All open-source packages
UISwift

SwiftShaders

Metal shader effects for SwiftUI views: color, blur, distortion, ripples and transitions.

7StarsLatest Release: v2.0.0Updated: October 14, 2026
Platforms:iOS 17macOS 14

License: MIT

A dependency-free Swift package for iOS 17+ and macOS 14+. Each effect is one view modifier, fill or transition on top of SwiftUI's own colorEffect, distortionEffect and layerEffect, so it works on any view. Every public argument is checked before it reaches the GPU, and the effects are verified by tests that render views and compare pixels.

Features

  • 26 view modifiers, 3 fills and 5 transitions backed by 31 [[ stitchable ]] Metal functions
  • Argument checks: ranges are clamped, NaN switches an effect off, sample offsets are limited to the view's diagonal and gradient maps use at most 256 colors
  • Clean edges: effects that compare neighboring pixels read only inside the view, and color effects keep the antialiased alpha of text
  • ShaderTime (.animated, .animated(speed:), .fixed(_:)) for animated effects, which stop on their first frame when Reduce Motion is on
  • Tap-following ripples that leave the view's own gestures working
  • ShaderLibrary.swiftShaders to call the shader functions directly, and SwiftShaders.isMetalLibraryAvailable to check that the build tool compiled them
  • 77 Swift Testing tests run on macOS and an iPhone simulator; a library test compares the compiled function names with the names the Swift code calls
  • DocC catalog with three articles and the ShaderGallery example app for iOS and macOS

Quickstart

swift
1import SwiftShaders
2import SwiftUI
3 
4struct ContentView: View {
5 var body: some View {
6 Image(systemName: "mountain.2.fill")
7 .font(.system(size: 96))
8 .foregroundStyle(.blue)
9 .padding(40)
10 .background(.blue.opacity(0.15), in: .rect(cornerRadius: 24))
11 .halftone(dotSize: 6, ink: .blue, paper: .white)
12 }
13}

Installation

Xcode (File › Add Package Dependencies…)

text
1https://github.com/muhittincamdali/SwiftShaders.git

Swift Package Manager

swift
1.package(url: "https://github.com/muhittincamdali/SwiftShaders.git", from: "2.0.0")

Screenshots

Three copies of a landscape drawn in code: on the left the rows sway on a wave, in the middle a ripple spreads from the center, on the right a band of light sweeps across
The landscape with each color effect: original, sepia, duotone, gradient map, posterize, threshold, dither, vignette, scanlines, film grain and shimmer
The landscape with each layer effect: pixelate, halftone, sketch, emboss, sharpen, progressive blur, chromatic aberration, kaleidoscope and glitch
The landscape with each distortion: wave, water, swirl, bulge and loupe
Frames of the dissolve, pixelate, swirl, circle reveal and radial wipe transitions at 0, 25, 50 and 75 percent
The example app's Halftone screen with a dot size slider on an iPhone simulator

Timeline

  1. Repository opened with three effects; v1.0.0 tagged on the first commit and expanded the same week

  2. Shader sources removed; the package was reduced to placeholder code

  3. Rebuild started: placeholder sources, templates and old tests removed

  4. v2.0.0: rewritten from scratch on SwiftUI's shader modifiers, with 31 Metal functions, pixel tests, DocC and an example app

Links

Related Article

Read the article