Chromatic Glass

Subtle chromatic-aberration glass layerEffect over any source view via a SwiftUI Metal stitchable shader — red/blue channels split toward the edges along the tilt direction, with a soft centre glow, for a premium glass-over-card feel

Free
Free with a ShipSwift account.

Copies a short instruction with your private download link. Paste it into your agent: it downloads the whole skill (the source code, the setup steps and the mistakes we already made for you) and builds the screen.

Works with

+70

What it does

A subtle chromatic-aberration "glass" pass applied to any view through SwiftUI's layerEffect Metal pipeline. The red and blue channels are sampled at opposing offsets that grow toward the edges (non-linear falloff) and follow the tilt vector; a soft centre brightness glow finishes the look. Unlike the foil family, this effect samples neighbouring pixels, so the renderer gives the layerEffect a maxSampleOffset budget — without it, edge pixels would clamp and the RGB fringing would be cut off.

Requires iOS 18+ / macOS 15+.

What you get

  • ✓313 lines of source code, ready to paste
  • ✓Attribution
  • ✓File Layout
  • ✓Source Code
  • ✓Usage
  • ✓Parameters
  • ✓Integration Checklist
  • ✓Notes / Gotchas
animationmetalshaderglasschromatic-aberrationlayerEffectcardSwiftUI

Usage

// Default — gentle RGB split, internal only
SWChromaticGlass {
    Image("photo").resizable().scaledToFill()
}
.frame(width: 250, height: 350)
.clipShape(RoundedRectangle(cornerRadius: 16))

// Tilt-driven, stronger separation
@State private var tilt: CGSize = .zero

SWChromaticGlass(tilt: tilt, separation: 0.6) { cardArtwork }
    .gesture(
        DragGesture()
            .onChanged { v in
                tilt = CGSize(width: v.translation.width / 100,
                              height: v.translation.height / 100)
            }
            .onEnded { _ in withAnimation(.spring) { tilt = .zero } }
    )

Parameters

ParameterTypeDefaultRangeNotes
tiltCGSize.zero~ -1…1 per axisLight/parallax direction, usually drag-driven
intensityFloat0.60…1Blend of the R/B split over the source
separationFloat0.40…1How far the R/B channels separate (at 1.0: ≈ 14 px at the edge midpoints, ≈ 22 px in the corners)
showsControlsBoolfalse—Demo-only gear ToolbarItem; requires an enclosing NavigationStack

Integration Checklist

  1. Copy SWChromaticGlass.swift and SWChromaticGlass.metal into your Xcode target, keeping the MIT attribution header on both files.
  2. Confirm the deployment target is iOS 18+ / macOS 15+.
  3. Wrap a card / photo in SWChromaticGlass { ... }; clip it to a RoundedRectangle.
  4. Keep the maxSampleOffset of CGSize(width: 28, height: 28) in the renderer — it must comfortably exceed the maximum pixel offset the shader reaches (≈ 22 px in the corners). See Gotchas.
  5. Drive tilt from a DragGesture so the fringing follows the card's rotation.

Notes / Gotchas

  • maxSampleOffset is load-bearing. Unlike the foil family, this effect samples neighbouring pixels (R/B channels at position ± offset). The offset is separation × (edgeFactor × 0.85 + 0.15) × 14 px, where edgeFactor = (2 × distance from centre)^1.5 is 1 at the edge midpoints and ≈ 1.68 in the corners — so at separation = 1 the shader reaches ≈ 14 px at the edges and ≈ 22 px in the corners; the renderer requests 28 px of headroom. If you drop it to .zero (as the foil family uses), the layer pre-clips its content and the RGB fringing is truncated at the edges. Do not copy .zero from the other skills here.
  • The 0.15 floor inside offsetAmount keeps a baseline split even at the centre, so the fringing reads across the whole photo rather than only at the corners.
  • The effect is deliberately subtle — it reads as glass-over-card, not a glitch. Raise separation and intensity together for a stronger split.
  • There is no TimelineView: the shader ignores its time argument, so the renderer passes 0 and the layer re-renders only when tilt, intensity or separation change — a still card costs nothing per frame.

More in Effects and animation

Metal shaders: fields of dots that roll like waves and flow into living patterns, all drawn on the GPU.
Metal dot fields
Free
Metal shaders: fields of dots that roll like waves and flow into living patterns, all drawn on the GPU.
A deep-space starfield in Metal: glowing nebulae drift past twinkling stars.
Deep-space starfield
Free
A deep-space starfield in Metal: glowing nebulae drift past twinkling stars.
Neon outlines that bloom from the center with prism-colored edges, rendered live in Metal.
Neon outlines
Free
Neon outlines that bloom from the center with prism-colored edges, rendered live in Metal.
Colored blobs that drift, melt into one another like liquid, and blend their colors as they merge.
Liquid metaballs
Free
Colored blobs that drift, melt into one another like liquid, and blend their colors as they merge.
A 3D network graph you can spin. Tap any node and its links light up, with the details below.
3D network graph
Free
A 3D network graph you can spin. Tap any node and its links light up, with the details below.
Items orbit into a dotted ring, and payment cards fan out of a wallet as the balance rolls in.
Orbit ring and wallet
Free
Items orbit into a dotted ring, and payment cards fan out of a wallet as the balance rolls in.
A field of bright colored dots that float and shimmer across the whole screen.
Floating color dots
Free
A field of bright colored dots that float and shimmer across the whole screen.
Stacked glass panels in mirrored layers, with neon gradients flowing through them.
Glass color panels
Free
Stacked glass panels in mirrored layers, with neon gradients flowing through them.
Drag the slider and scattered points of light pull together into a perfect 3D sphere.
Dot sphere
Free
Drag the slider and scattered points of light pull together into a perfect 3D sphere.
Living patterns: a mosaic of cells that keeps reshaping, then a hypnotic color swirl.
Cells and swirl
Free
Living patterns: a mosaic of cells that keeps reshaping, then a hypnotic color swirl.
Organic noise shaders: glowing veins that pulse through the dark, then bold color blobs in constant flow.
Noise veins and blobs
Free
Organic noise shaders: glowing veins that pulse through the dark, then bold color blobs in constant flow.