{
 "id": "ntsc-composite-vhs-crt-signal-emulation",
 "title": "Physically Modeled NTSC Composite / VHS Tape & CRT Electron-Beam Emulation",
 "aliases": [
  "NTSC/VHS signal emulation",
  "composite video shader",
  "CRT electron-beam post-processing"
 ],
 "domain": "post",
 "subdomain": "analog signal emulation",
 "stage": "post",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cpu"
 ],
 "year_introduced": 2023,
 "inputs": [
  "ldr-image"
 ],
 "outputs": [
  "ldr-image"
 ],
 "style": "stylized",
 "dynamic": "dynamic",
 "summary": "Simulates the full analog NTSC/VHS broadcast and tape pipeline—YIQ subcarrier modulation, bandwidth limiting, head-switching phase skew, and notch-filter demodulation—followed by a Gaussian CRT electron beam, phosphor mask, and halation.",
 "how_it_works": "Naive retro shaders fake VHS by adding static scanlines and RGB channel offsets, missing the coupled artifacts of real analog video. Signal-accurate emulation instead operates at the native composite resolution (typically 240 active scanlines per field, sampled at 4× the NTSC color subcarrier frequency) in four physical stages.\n\nFirst, the gamma-encoded picture converts to **YIQ** color space; the `I` and `Q` chroma channels are low-pass filtered, quadrature-modulated onto the color subcarrier, and summed with luma `Y` into a single 1D composite waveform per scanline. Tape snow, tracking jitter, and **head-switching horizontal skew** perturb that composite waveform directly—so shifting a line also shifts its subcarrier phase, naturally producing authentic hue warps. Next, an NTSC **notch or comb demodulator** separates luma and chroma; residual cross-talk creates real dot crawl and rainbow shimmering on sharp high-frequency edges. A **VHS tape pass** further band-limits luma (with edge-sharpening ringing) and heavily smears chroma horizontally and vertically.\n\nFinally, a **CRT display stage** linearizes the decoded signal, rasterizes each scanline as a brightness-modulated Gaussian electron beam with RGB deconvergence, applies an aperture-grille or shadow-mask phosphor pattern, and adds low-resolution phosphor bloom and glass halation.",
 "when_to_use": "Choose it when you want genuinely authentic camcorder, VHS tape, or broadcast CRT imagery where rainbows, dot crawl, ringing, hue-shifted tracking errors, and blooming scanlines emerge from actual signal physics.\n\nPrefer [film-emulation](film-emulation) when aiming for photochemical celluloid cinema rather than magnetic-tape television. Prefer [chromatic-aberration](chromatic-aberration) and [film-grain-synthesis](film-grain-synthesis) when you only want subtle optical lens defects without lowering spatial resolution. Prefer [pixel-art-3d-rendering](pixel-art-3d-rendering) when crisp low-res pixels should remain sharp rather than analog-blurred.",
 "cost": {
  "class": "cheap",
  "notes": "The composite encode, decode, and VHS filter passes run at tiny signal resolution (around 760×240 or 910×240), making them very cheap on GPU; only the final CRT scanline, mask, and halation pass runs at full display resolution."
 },
 "failure_modes": [
  "Moiré interference patterns when an aperture-grille or shadow-mask phosphor grid is rendered on low-DPI or non-integer-scaled displays",
  "Severe loss of UI text legibility due to authentic VHS chroma subsampling and 240p horizontal bandwidth limits",
  "Temporal flicker or excessive eye strain if interlaced field alternation and tracking jitter are left unattenuated",
  "Over-darkened output if phosphor mask attenuation is not balanced with brightness compensation and halation"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "gh:ntsc-rs/ntsc-rs",
   "type": "code",
   "title": "ntsc-rs/ntsc-rs",
   "description": "Free, open-source VHS effect. Standalone application + plugin (After Effects, Premiere, and OpenFX).",
   "authors": [
    "ntsc-rs"
   ],
   "year": 2023,
   "venue": "GitHub",
   "url": "https://github.com/ntsc-rs/ntsc-rs",
   "ids": {
    "repo": "ntsc-rs/ntsc-rs"
   },
   "license": "NOASSERTION",
   "extra": {
    "stars": 2758,
    "stars_checked": "2026-11-30",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-10-15T01:45:48Z",
    "language": "Rust",
    "homepage": "https://ntsc.rs",
    "license_name": "Other"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ntsc-rs/ntsc-rs",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ntsc-rs/ntsc-rs",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ntsc-rs/ntsc-rs",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ntsc-rs/ntsc-rs",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ntsc-rs/ntsc-rs",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/ntsc-rs/ntsc-rs",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": null,
   "__bib": "ntscrs2023ntsc"
  },
  {
   "role": "implementation",
   "key": "gh:spite/codevember-2026",
   "type": "code",
   "title": "spite/codevember-2026",
   "description": "",
   "authors": [
    "spite"
   ],
   "year": 2026,
   "venue": "GitHub",
   "url": "https://github.com/spite/codevember-2026",
   "ids": {
    "repo": "spite/codevember-2026"
   },
   "license": "MIT",
   "extra": {
    "stars": 45,
    "stars_checked": "2026-11-30",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-30T15:47:17Z",
    "language": "JavaScript",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/spite/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/spite/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/spite/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/spite/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/spite/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/spite/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": null,
   "__bib": "spite2026spite"
  },
  {
   "role": "implementation",
   "key": "gh:libretro/slang-shaders",
   "type": "code",
   "title": "libretro/slang-shaders",
   "description": "",
   "authors": [
    "libretro"
   ],
   "year": 2016,
   "venue": "GitHub",
   "url": "https://github.com/libretro/slang-shaders",
   "ids": {
    "repo": "libretro/slang-shaders"
   },
   "license": null,
   "extra": {
    "stars": 488,
    "stars_checked": "2026-11-30",
    "archived": false,
    "fork": true,
    "pushed_at": "2026-11-30T03:08:31Z",
    "language": "Slang",
    "homepage": null,
    "license_name": null
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/libretro/slang-shaders",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/libretro/slang-shaders",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/libretro/slang-shaders",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/libretro/slang-shaders",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/libretro/slang-shaders",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/libretro/slang-shaders",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": null,
   "__bib": "libretro2016libretro"
  }
 ],
 "presets": [
  {
   "id": "ntsc-composite-vhs-crt-signal-emulation-live",
   "title": "NTSC Composite / VHS & CRT Signal Emulation — clean digital RGB (left) vs YIQ subcarrier crosstalk, VHS skew & CRT phosphor beam (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_SUBCARRIER": 0.75,
    "P_VHS_WEAR": 0.55,
    "P_SCANLINES": 0.7,
    "P_SPLIT": 0.45
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_SUBCARRIER = 0.75; // P YIQ Chroma Crawl [0.0, 1.2, 0.05]\nconst float P_VHS_WEAR = 0.55; // P VHS Tape Noise [0.0, 1.2, 0.05]\nconst float P_SCANLINES = 0.70; // P CRT Beam & Mask [0.0, 1.0, 0.05]\nconst float P_SPLIT = 0.45; // P Clean RGB / NTSC [0.0, 1.0, 0.02]\n\nfloat hash11(float p) {\n  p = fract(p * 0.1031);\n  p *= p + 33.33;\n  p *= p + p;\n  return fract(p);\n}\n\n// Broadcast SMPTE test header + retro 1980s neon-horizon 3D chrome sphere scene\nvec3 renderSource(vec2 uv, float t) {\n  // Top SMPTE color bar strip (reveals YIQ chroma bleed & notch crosstalk unmistakably!)\n  if (uv.y > 0.76) {\n    float idx = floor(uv.x * 7.0);\n    if (idx < 0.5) return vec3(0.85, 0.85, 0.85);\n    if (idx < 1.5) return vec3(0.88, 0.84, 0.12);\n    if (idx < 2.5) return vec3(0.12, 0.84, 0.86);\n    if (idx < 3.5) return vec3(0.14, 0.82, 0.24);\n    if (idx < 4.5) return vec3(0.86, 0.16, 0.84);\n    if (idx < 5.5) return vec3(0.88, 0.14, 0.16);\n    return vec3(0.14, 0.24, 0.88);\n  }\n\n  vec2 p = (uv - vec2(0.5, 0.38)) * vec2(1.5, 1.0);\n  // Sunset sky + striped retro sun\n  vec3 col = mix(vec3(0.10, 0.04, 0.22), vec3(0.56, 0.14, 0.44), smoothstep(0.32, -0.04, p.y));\n  float sunD = length(p - vec2(0.0, 0.08));\n  if (sunD < 0.22) {\n    float cut = step(0.22, fract(p.y * 28.0 - t * 0.4)) + step(0.10, p.y);\n    vec3 sunC = mix(vec3(1.0, 0.22, 0.38), vec3(1.0, 0.86, 0.24), smoothstep(-0.10, 0.26, p.y));\n    col = mix(col, sunC, clamp(cut, 0.0, 1.0));\n  }\n\n  // Perspective synthwave grid floor\n  if (p.y < -0.04) {\n    float z = 0.26 / max(-p.y - 0.02, 0.015);\n    float gx = abs(fract(p.x * z * 1.4) - 0.5);\n    float gz = abs(fract(z * 1.1 - t * 1.2) - 0.5);\n    float line = smoothstep(0.055, 0.015, min(gx, gz));\n    col = mix(vec3(0.04, 0.02, 0.12), vec3(0.14, 0.92, 0.98), line * exp(-z * 0.11));\n  }\n\n  // Floating metallic chrome sphere in foreground\n  vec2 sp = p - vec2(0.22 * sin(t * 0.7), -0.02 + 0.04 * cos(t * 1.1));\n  float r = length(sp);\n  if (r < 0.16) {\n    float nz = sqrt(max(0.16 * 0.16 - r * r, 0.0));\n    vec3 n = normalize(vec3(sp, nz));\n    vec3 ref = reflect(vec3(0.0, 0.0, -1.0), n);\n    vec3 env = (ref.y > 0.0)\n      ? mix(vec3(0.95, 0.35, 0.55), vec3(0.18, 0.32, 0.76), ref.y)\n      : mix(vec3(0.08, 0.04, 0.18), vec3(0.16, 0.92, 0.95), smoothstep(0.45, 0.5, abs(sin(ref.x * 16.0))));\n    col = env + vec3(1.0, 0.96, 0.88) * pow(max(dot(ref, normalize(vec3(0.4, 0.6, 0.7))), 0.0), 24.0);\n  }\n  return col;\n}\n\nvec3 rgb2yiq(vec3 c) {\n  return vec3(\n    dot(c, vec3(0.299, 0.587, 0.114)),\n    dot(c, vec3(0.596, -0.274, -0.322)),\n    dot(c, vec3(0.211, -0.523, 0.312))\n  );\n}\n\nvec3 yiq2rgb(vec3 yiq) {\n  return vec3(\n    yiq.x + 0.956 * yiq.y + 0.621 * yiq.z,\n    yiq.x - 0.272 * yiq.y - 0.647 * yiq.z,\n    yiq.x - 1.106 * yiq.y + 1.703 * yiq.z\n  );\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = fragCoord / max(iResolution.xy, vec2(1.0));\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float subAmp = clamp(P_SUBCARRIER, 0.0, 1.3);\n  float wear = clamp(P_VHS_WEAR, 0.0, 1.3);\n  float scan = clamp(P_SCANLINES, 0.0, 1.0);\n\n  vec3 col = vec3(0.0);\n  if (uv.x < split) {\n    col = renderSource(uv, iTime);\n  } else {\n    // Subtle CRT glass barrel curvature\n    vec2 cc = uv * 2.0 - 1.0;\n    vec2 cuv = uv + cc * dot(cc, cc) * 0.032 * scan;\n\n    // VHS head-switching skew at bottom 6% of frame + per-scanline jitter\n    float lineId = floor(cuv.y * 240.0);\n    float headSwitch = smoothstep(0.075, 0.015, cuv.y) * (0.018 * sin(cuv.y * 190.0 + iTime * 22.0) + 0.012);\n    float lineJitter = (hash11(lineId + floor(iTime * 30.0) * 17.3) - 0.5) * 0.0045 * wear;\n    cuv.x += headSwitch * wear + lineJitter;\n\n    // Stage 1-3: Composite NTSC YIQ encoding -> narrowband chroma low-pass -> subcarrier crosstalk demodulation\n    float yAcc = 0.0;\n    float iAcc = 0.0;\n    float qAcc = 0.0;\n    float wY = 0.0;\n    float wC = 0.0;\n    float phase0 = cuv.x * 260.0 + lineId * 2.0944 + floor(iTime * 30.0) * 3.14159;\n\n    for (int k = -3; k <= 3; k++) {\n      float fk = float(k);\n      vec2 suv = clamp(cuv + vec2(fk * 0.0026, 0.0), 0.001, 0.999);\n      vec3 yiq = rgb2yiq(renderSource(suv, iTime));\n\n      // Modulate composite signal s(t) = Y + I cos(wt) + Q sin(wt)\n      float ph = phase0 + fk * 1.570796;\n      float comp = yiq.x + (yiq.y * cos(ph) + yiq.z * sin(ph)) * subAmp;\n\n      // High-freq luma leaks into chroma demodulator (dot crawl & rainbowing)\n      float wy = exp(-fk * fk * 0.42);\n      float wc = exp(-fk * fk * 0.14);\n      yAcc += (yiq.x + (comp - yiq.x) * 0.16 * subAmp) * wy;\n      iAcc += (yiq.y + (comp - yiq.x) * cos(ph) * 0.28 * subAmp) * wc;\n      qAcc += (yiq.z + (comp - yiq.x) * sin(ph) * 0.28 * subAmp) * wc;\n      wY += wy;\n      wC += wc;\n    }\n\n    vec3 yiqOut = vec3(yAcc / wY, iAcc / wC, qAcc / wC);\n    // VHS chroma delay & snow speckle on dropout lines\n    float dropout = step(0.992 - wear * 0.012, hash11(lineId * 1.7 + floor(iTime * 18.0) * 3.1));\n    yiqOut.x += dropout * (hash11(fragCoord.x + iTime * 90.0) - 0.2) * 0.45 * wear;\n    col = clamp(yiq2rgb(yiqOut), 0.0, 1.4);\n\n    // Stage 4: Gaussian CRT electron-beam scanline profile + RGB aperture-grille phosphor mask + halation\n    float scanPhase = fract(cuv.y * 240.0) - 0.5;\n    float beamWidth = mix(0.24, 0.42, clamp(yiqOut.x, 0.0, 1.0));\n    float beam = exp(-(scanPhase * scanPhase) / max(beamWidth * beamWidth, 0.02));\n    col *= mix(1.0, 0.42 + 0.85 * beam, scan);\n\n    float pxMod = mod(floor(fragCoord.x), 3.0);\n    vec3 grille = vec3(\n      pxMod < 0.5 ? 1.16 : 0.84,\n      (pxMod >= 0.5 && pxMod < 1.5) ? 1.16 : 0.84,\n      pxMod >= 1.5 ? 1.16 : 0.84\n    );\n    col *= mix(vec3(1.0), grille, scan * 0.55);\n\n    // Subtle glass phosphor bloom & vignette\n    col += col * col * 0.18 * scan;\n    float vig = 1.0 - dot(cc * 0.42, cc * 0.42) * scan;\n    col *= clamp(vig, 0.45, 1.0);\n  }\n\n  float sep = smoothstep(0.0035, 0.0008, abs(uv.x - split));\n  col = mix(col, vec3(0.95, 0.98, 1.0), sep);\n  fragColor = vec4(clamp(col, 0.0, 1.0), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "ntsc-composite-vhs-crt-signal-emulation",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T21:07:19.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.2674,
      "std": 0.2771,
      "min": 0.0129,
      "max": 1
     },
     "image": "/specimens/ntsc-composite-vhs-crt-signal-emulation-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "film-emulation",
  "chromatic-aberration",
  "film-grain-synthesis",
  "dual-filter-bloom",
  "pixel-art-3d-rendering"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "acoustic-raytraced-echolocation-point-cloud",
   "why": "Transforms sparse luminous echolocation point clouds into found-footage camcorder video with authentic VHS bleed and CRT halation."
  },
  {
   "id": "agx-tonemapping",
   "why": "Maps linear HDR scene light into display-referred gamma RGB prior to YIQ composite signal encoding."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-30T17:59:51.239Z",
  "draft": "data/drafts/post/ntsc-composite-vhs-crt-signal-emulation.json"
 },
 "solves": [
  "simple scanline overlay looks fake compared to a real crt television",
  "want authentic composite video chroma bleed rainbow artifacts and luma ringing",
  "emulate vhs tape tracking jitter head-switching noise and chroma lag",
  "simulate yiq subcarrier modulation and phosphor bloom in a post-process pass",
  "give retro 3d scenes genuine analog broadcast and home-video texture"
 ],
 "authority": "ntsc-rs, 2023",
 "url": "https://texelatlas.vercel.app/t/ntsc-composite-vhs-crt-signal-emulation/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true,
 "gpu_weight": {
  "weight_x": 8.22,
  "tier": "moderate",
  "p50_ms": 0.2704,
  "p95_ms": 0.2772,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 32,
  "preset_id": "ntsc-composite-vhs-crt-signal-emulation-live",
  "execution_fidelity": "faithful-pass",
  "fidelity_label": "Faithful Pass",
  "benchmark_eligible": true,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 6.61,
   "tier": "moderate",
   "p50_ms": 0.1051,
   "p95_ms": 0.1084,
   "speedup_x": 2.57,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 4.99,
   "tier": "light",
   "p50_ms": 0.1437,
   "p95_ms": 0.1451,
   "speedup_x": 1.88,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}