Blurs, glows & screens

Effects that read the layer inside them (the child) as a texture and rebuild it: blurs, glows, sharpening, pixelation, shadows, retro screens, glitches, fluted glass, page peels and mirror floors. A pointwise effect edits the child's color at one pixel; the words here are gather effects, which sample the child at other pixels too, so they can smear, spread and displace it. Every word here goes in a filter definition's effect: field, or spreads into a definition when it needs its own pass over the child first.

Finished effects are one call: gaussianBlur, motionBlur, bloom, pixelate, sharpen, scatter, bokehDefocus. Stacked looks are assembled with gatherStack from a sampling stage (how the child is first read: rgbSplit, chromaSmearTaps, crispTap, childTap) and ordered overlay stages that edit the result (scanlines, adjust, rimLit, shadowComposite). When several stages need the same geometry, build a frame once (sphereFrame, glitchFrame, fluteFrame, peelFrame) and hand it to each of them.

Blurs that need a separate pass (gaussianBlur, channelBlur, progressiveBlur, tiltShift, bloom, bokehDefocus) return both halves at once. Spread them into a definition that declares species: 'custom', requiresRTT: true and requiresChild: true instead of using effect:.

import {effects} from 'shaders/std'

Reach for it when

When you needUse
a soft, even blurgaussianBlur
a directional streak, a spin, or a zoom blurmotionBlur with blurPath
a blur that fades in across the canvasprogressiveBlur
a band in focus with blurred edgestiltShift
a glow around bright partsbloom
a lens blur with shaped highlight discsbokehDefocus
a chromatic fringe from blurring channels apartchannelBlur
grainy diffusion rather than a smooth blurscatter
crisper detailsharpen
a pixel grid, with gaps or rounded cellspixelate
a soft shadow behind the childchildTap + shadowOffset, silhouetteCoverage, shadowComposite
an old CRT monitorrgbSplit + adjust, scanlines, phosphorMask, vignetteOverlay, opaque
a worn VHS tapechromaSmearTaps with tapeWarp, then beatPulse
digital glitch burstsglitchFrame + glitchRgbSplit, colorBarFills, distortedScanlines
the child bulging on a spheresphereFrame + crispTap, rimLit
reeded or fluted glass over the childfluteFrame + refractedTaps, fluteHighlight
a page curling up from a cornerpeelFrame + peelCompose with the four peel shades
a mirror floor with a fading, softening reflectionmirrorAcrossRow, depthRampBlur, planarReflection
film halation or phosphor bloom over a graded colorscreenedBloom
a projector-gate wobbleframeSway

Example

import {defineShader, p, effects, transformColor, transformBoolean} from 'shaders/std'

const {gatherStack, childTap, shadowOffset, silhouetteCoverage, shadowComposite} = effects.blurs

// A soft drop shadow: read the child's silhouette offset in a compass direction, blur it,
// tint it, and place it behind the child.
export const SoftShadow = defineShader({
  name: 'SoftShadow',
  props: {
    color: {default: '#000000', transform: transformColor},
    distance: {default: 0.1},
    angle: {default: 135},
    blur: {default: 5},
    intensity: {default: 0.5},
    cutout: {default: false, transform: transformBoolean, compileTime: true},
  },
  effect: gatherStack(childTap(), [
    shadowComposite({
      coverage: silhouetteCoverage({
        at: shadowOffset({angle: p('angle'), distance: p('distance')}),
        blur: p('blur'),
      }),
      color: p('color'),
      intensity: p('intensity'),
      cutout: p('cutout'),
    }),
  ]),
})

Types

TypeWhat it is
BlurPathSpecThe path a motion blur smears along: its kind plus the prop that anchors it.
ComputeBackedEffectThe two halves a heavy blur adds to a definition: a pass that blurs the child ahead of time, and the fragment that reads it.
GatherFrameA geometry that several stages of one effect share: a warped coordinate, a surface normal, a coverage mask.
OverlayStageOne editing stage of a stacked effect: takes the color so far and returns the edited color.
PeelShadeOne shading term of a page peel: a number per pixel read against the peel frame.
SampleStageThe first stage of a stacked effect: reads the child as a texture and returns the starting color at this pixel.

Words