{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "umbra",
  "type": "registry:ui",
  "title": "Umbra",
  "description": "A dark veil: black-on-black volumetric drape of domain-warped ridged fbm where only the fold crests catch a whisper of light and a deep violet undertone breathes at a tenth of a hertz — luminance hard-capped so overlay text always wins. Original OGL fragment shader, time-dithered, offscreen-paused, reduced-motion-safe.",
  "dependencies": [
    "ogl"
  ],
  "registryDependencies": [
    "https://crucibleui.com/r/ogl-canvas.json",
    "https://crucibleui.com/r/use-visibility-pause.json",
    "https://crucibleui.com/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/default/backgrounds/umbra/umbra.tsx",
      "type": "registry:ui",
      "target": "components/crucible/umbra.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\nimport { OglCanvas } from \"@/lib/ogl-canvas\";\n\nexport interface UmbraProps extends React.ComponentPropsWithoutRef<\"div\"> {\n  /**\n   * `[undertone, crestLight]`. The undertone is the deep hue that breathes in\n   * the folds (default black-violet); crestLight is the pale tint the fold\n   * crests catch. Both stay whisper-subtle under the luminance cap.\n   */\n  colors?: [string, string];\n  /** Animation speed multiplier. 1 = default drift + ~0.1 Hz breathing. */\n  speed?: number;\n  /** Field scale. 1 = default; higher packs more, smaller folds. */\n  scale?: number;\n  /** Domain-warp strength. 0 = straight ridges, 1 = default drape, up to 3. */\n  warp?: number;\n  /**\n   * Hard ceiling on output luminance (0–1). The veil soft-clips beneath this\n   * so overlay text always wins. Default 0.3 — raise with care.\n   */\n  luminanceCap?: number;\n  /** Freeze the animation at its current frame. */\n  paused?: boolean;\n}\n\nconst DEFAULT_COLORS: [string, string] = [\n  \"#1f1133\", // deep violet undertone — breathes in the folds\n  \"#c9bfe4\", // pale lavender-gray — what the crests catch\n];\n\n/** Hex → [r,g,b] in 0–1. Accepts #rgb / #rrggbb. */\nfunction hexToRgb(hex: string): [number, number, number] {\n  let h = hex.replace(\"#\", \"\").trim();\n  if (h.length === 3) {\n    h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];\n  }\n  const int = parseInt(h, 16);\n  if (Number.isNaN(int) || h.length !== 6) return [0.12, 0.07, 0.2];\n  return [((int >> 16) & 255) / 255, ((int >> 8) & 255) / 255, (int & 255) / 255];\n}\n\n/**\n * Original \"dark veil\" fragment shader: domain-warped ridged fbm rendered\n * near-threshold. The ridge transform folds value noise into sharp crests;\n * a low-frequency warp field drapes them into organic folds. Only the crests\n * catch light — everything else falls to true black — and a deep undertone\n * breathes through them at ~0.1 Hz. Output is soft-clipped under uCap so the\n * veil can never compete with overlay text, and time-varying hash dither\n * defeats the banding that would otherwise be fatal at these luminances.\n * GLSL ES 1.00 (WebGL1/2 compatible).\n */\nconst FRAGMENT = /* glsl */ `\nprecision highp float;\n\nvarying vec2 vUv;\n\nuniform float uTime;\nuniform vec2 uResolution;\nuniform vec2 uPointer; // managed by the harness; unused — the veil ignores the cursor\n\nuniform vec3 uUndertone; // deep violet — breathes in the folds\nuniform vec3 uCrest;     // pale light the crests catch\nuniform float uSpeed;\nuniform float uScale;\nuniform float uWarp;\nuniform float uCap;  // luminance ceiling\nuniform float uSeed; // per-instance offset — desynchronizes multiple veils\n\n// --- compact value noise (original) ---\nfloat hash21(vec2 p) {\n  p = fract(p * vec2(127.1, 311.7));\n  p += dot(p, p + 34.23);\n  return fract(p.x * p.y);\n}\n\nfloat vnoise(vec2 p) {\n  vec2 i = floor(p);\n  vec2 f = fract(p);\n  float a = hash21(i);\n  float b = hash21(i + vec2(1.0, 0.0));\n  float c = hash21(i + vec2(0.0, 1.0));\n  float d = hash21(i + vec2(1.0, 1.0));\n  vec2 u = f * f * (3.0 - 2.0 * f);\n  return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);\n}\n\n// Plain fbm drives the warp field (soft billows, no ridges needed there).\nfloat fbm(vec2 p) {\n  float v = 0.0;\n  float amp = 0.5;\n  mat2 m = mat2(1.6, 1.2, -1.2, 1.6);\n  for (int i = 0; i < 3; i++) {\n    v += amp * vnoise(p);\n    p = m * p;\n    amp *= 0.5;\n  }\n  return v;\n}\n\n// Ridge transform: folds noise so its midline becomes a sharp crest.\nfloat ridge(float n) {\n  return 1.0 - abs(2.0 * n - 1.0);\n}\n\n// Ridged multifractal: each octave's detail is gated by the crest below it,\n// so fine wrinkles live ON the folds instead of filling the hollows.\nfloat rfbm(vec2 p) {\n  float v = 0.0;\n  float amp = 0.5;\n  float carry = 1.0;\n  mat2 m = mat2(1.6, 1.2, -1.2, 1.6);\n  for (int i = 0; i < 4; i++) {\n    float r = ridge(vnoise(p));\n    r *= r; // sharpen the fold line\n    v += amp * r * (0.35 + 0.65 * carry);\n    carry = r;\n    p = m * p;\n    amp *= 0.5;\n  }\n  return v;\n}\n\nvoid main() {\n  vec2 uv = vUv;\n  float aspect = uResolution.x / max(uResolution.y, 1.0);\n\n  // Field clock: glacial by design — a drape settling, not a fluid churning.\n  float t = uTime * uSpeed * 0.035 + uSeed;\n\n  vec2 p = (uv - 0.5) * vec2(aspect, 1.0) * (2.4 * uScale)\n    + vec2(uSeed * 3.1, uSeed * -1.7);\n\n  // Low-frequency warp field: two decorrelated fbm channels on their own\n  // clocks bend the ridge domain into hanging, overlapping folds.\n  vec2 q = vec2(\n    fbm(p * 0.55 + t * vec2(0.7, 0.45)),\n    fbm(p * 0.55 + vec2(4.7, 2.3) - t * vec2(0.4, 0.65))\n  );\n  vec2 wp = p + uWarp * 3.4 * (q - 0.5);\n\n  float f = rfbm(wp + t * vec2(0.12, -0.08));\n\n  // ~0.1 Hz breath on the REAL clock (2*pi*0.1 = 0.6283), phase-split per\n  // instance so multiple veils on a page never inhale together.\n  float br = 0.5 + 0.5 * sin(uTime * uSpeed * 0.6283 + uSeed * 6.2832);\n\n  // Near-threshold crest window: only the fold tops catch light. Squared so\n  // the transition tail dies into true black instead of lingering as haze.\n  float crest = smoothstep(0.42, 0.85, f);\n  crest *= crest;\n\n  // Crest color drifts between undertone-violet and pale light with the\n  // breath — the undertone literally breathes IN the crests.\n  vec3 crestCol = mix(uUndertone * 1.8, uCrest, 0.30 + 0.35 * crest + 0.18 * br);\n  vec3 col = crestCol * crest * (0.72 + 0.35 * br);\n\n  // Barely-there ambient drape so the crests read as tops of a volume, not\n  // floating filaments. Sits a breath above true black, breathing too.\n  float body = smoothstep(0.10, 0.55, f);\n  col += uUndertone * body * (0.16 + 0.10 * br);\n\n  // Hard promise of the component: soft-clip asymptotically under uCap so\n  // no crest, at any knob setting, can climb above the luminance ceiling.\n  float cap = max(uCap, 0.001);\n  col = cap * (vec3(1.0) - exp(-col * 2.4 / cap));\n\n  // Faint vignette seats the veil behind content.\n  vec2 vg = (uv - 0.5) * vec2(aspect, 1.0);\n  col *= 1.0 - 0.35 * dot(vg, vg);\n\n  // Time-varying hash dither — mandatory. At these luminances, 8-bit banding\n  // is fatal; re-hashing per frame turns it into a filmic shimmer instead.\n  float grain = hash21(gl_FragCoord.xy + fract(uTime * 0.31 + uSeed) * 149.0) - 0.5;\n  col += grain * (2.0 / 255.0);\n\n  gl_FragColor = vec4(max(col, 0.0), 1.0);\n}\n`;\n\n/**\n * Umbra — a dark veil. Black-on-black volumetric drape: domain-warped ridged\n * fbm folds where only the crests catch a whisper of light and a deep violet\n * undertone breathes at ~0.1 Hz; everything else falls to true black. Output\n * luminance is hard-capped so overlay text always wins — the restraint is the\n * signature. Built on the `ogl-canvas` harness: GPU-light, offscreen-paused,\n * reduced-motion-safe. Position it inside any `relative` container; it fills\n * and sits behind content.\n */\nexport function Umbra({\n  colors = DEFAULT_COLORS,\n  speed = 1,\n  scale = 1,\n  warp = 1,\n  luminanceCap = 0.3,\n  paused = false,\n  className,\n  ...props\n}: UmbraProps) {\n  // Deterministic per-instance seed (SSR-safe — useId is stable across\n  // server and client) so multiple veils on one page desynchronize.\n  const id = React.useId();\n  const seed = React.useMemo(() => {\n    let h = 0;\n    for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) >>> 0;\n    return (h % 1024) / 1024;\n  }, [id]);\n\n  const uniforms = React.useMemo(\n    () => ({\n      uUndertone: { value: hexToRgb(colors[0]) },\n      uCrest: { value: hexToRgb(colors[1]) },\n      uSpeed: { value: Math.max(speed, 0) },\n      uScale: { value: Math.min(Math.max(scale, 0.2), 4) },\n      uWarp: { value: Math.min(Math.max(warp, 0), 3) },\n      uCap: { value: Math.min(Math.max(luminanceCap, 0.02), 1) },\n      uSeed: { value: seed * 37.0 },\n    }),\n    [colors, speed, scale, warp, luminanceCap, seed]\n  );\n\n  return (\n    <OglCanvas\n      aria-hidden\n      data-crucible=\"umbra\"\n      {...props}\n      className={cn(\"absolute inset-0 -z-10\", className)}\n      fragment={FRAGMENT}\n      uniforms={uniforms}\n      paused={paused}\n      reducedMotionTime={11}\n    />\n  );\n}\n"
    }
  ]
}