Prism, a Metal shader for SwiftUI
SwiftUI Metal shader

Prism

A glass prism with a beam entering it and the spectrum fanning out of the far face. The rainbow is traced, not painted: the beam is refracted through the solid's real cross-section with Snell's law once per colour, so turning the prism, widening it, changing its facet count or raising the refraction index moves the fan exactly as glass would — including total internal reflection, and the forced internal bounces that turn a prism into a raindrop. Forty-eight knobs: the shape, the glass, the lamp, the spectrum, the paper it is drawn on, and five ways to make it drift.

SwiftUIReact NativeWeb

How it works

Prism is a real [[stitchable]] Metal shader, not a video or an image. It runs as a SwiftUI .colorEffect, so it paints any view you attach it to. You shape it with sliders in a live preview, then export the .metal file and the SwiftUI code that uses it, or the React Native and Web version. No MSL to write.

48 settings you can tune

  • Facets
  • Aspect
  • Depth
  • Size
  • Rotation
  • X
  • Y
  • Refraction
  • Dispersion
  • Roughness
  • Reflections
  • Tint
  • Density
  • Outline
  • Ink
  • Sparkle
  • Rays
  • Bounces
  • Beam angle
  • Beam height
  • Beam colour
  • Beam width
  • Inner ray
  • Inner haze
  • Exit glow
  • Spread min
  • Spread max
  • Length
  • Continuous
  • Edge ink
  • Grain
  • Red
  • Orange
  • Yellow
  • Green
  • Blue
  • Violet
  • Background
  • Glow
  • Falloff
  • Streaks
  • Paper grain
  • Dial
  • Idle sway
  • Dial spin
  • Streak drift
  • Light shimmer
  • Pulse

More SwiftUI shaders