Skip to content

Shaders & Backgrounds

Velocity ships a Shader Lab: 88 self-contained, brand-aware animated shaders you can browse, cherry-pick, drop behind any section, or export to TouchDesigner.

  • 79 WebGL fragment shaders (zero dependencies — WebGL is native, no Three.js)
  • 6 ASCII text-mode effects
  • 3 brand shader-park effects

Browse them live at /components under Shader Lab — one page per shader with its variants, e.g. /components/shader-pc-vortex-arms-0/.

ShaderBackground.astro is the drop-in: it wraps any content in a live shader with a theme-aware legibility scrim so text stays readable over the motion.

---
import ShaderBackground from '../components/brand/ShaderBackground.astro';
---
<ShaderBackground shader="pc-vortex-arms" preset="hero">
<h1>Code meets design.</h1>
<a href="/get-started/" class="btn btn-primary">Start a project</a>
</ShaderBackground>

Each preset bundles sensible opacity / palette / speed / scrim for a placement. Override any individually via props.

PresetOpacityScrimUse for
hero0.9bottomFull-bleed hero backdrop (100svh)
section0.4veilAmbient texture behind body copy
card0.85noneDecorative card surface (dark palette)
subtle0.22noneBarely-there motion behind flat content

Props: shader, type (webgl|ascii|brand, default webgl), variant, preset, opacity, palette (auto|light|dark), speed, scrim (none|veil|bottom|top|full), rounded, minHeight, class.

Pack shaders use a prefixed key; base shaders are bare:

<ShaderBackground shader="pc-vortex-arms" preset="section" /> <!-- pack: prefixed -->
<ShaderBackground shader="mesh-gradient" preset="subtle" /> <!-- base: bare -->

The key is the slug segment on each Shader-Lab page — /components/shader-<key>-0/. Wrong key → the component renders nothing and warns in the console.

The underlying ShaderBg engine creates its WebGL context only when the element nears the viewport and destroys it when it scrolls away (via WEBGL_lose_context), so a page can host several without exhausting the browser’s context cap. It clamps DPR, caps total pixels, renders a single static frame under prefers-reduced-motion, and falls back to a soft brand gradient if WebGL or shader compilation fails — a background never renders blank-broken.

Every WebGL shader can leave the web and become a TouchDesigner node.

On any Shader-Lab page, the “.tox / TD” button (top-right of the canvas) downloads aidxn-<key>.frag: the shader converted to GLSL TOP conventions (out fragColor + TDOutputSwizzle, u_resolutionuTDOutputInfo, u_time/u_mouse/u_dark as uniforms) with paste-and-go notes in the header. Drop it into a GLSL TOP, add the listed uniforms, save the COMP as .tox.

All shaders — real .tox (in TouchDesigner)

Section titled “All shaders — real .tox (in TouchDesigner)”

A genuine binary .tox can only be written by TouchDesigner itself, so Velocity emits a Python script instead. Fetch it from the running site:

Terminal window
curl -s http://localhost:4321/tox-kit.py > generate_tox.py

Run it inside TouchDesigner (Text DAT → Run Script, or the Textport). For each of the 79 shaders it builds a Base COMP — Text DAT + GLSL TOP + In/Out TOPs

  • a Controls parameter page (Zoom / Intensity / Hue / Dark / Speed) bound to the uniforms — i.e. a simple in/out connectable node with adjustments inside, and COMP.save()s each as a genuine aidxn-<key>.tox. Full notes ship in tox-export/README.md.
  • The custom shader engine: src/components/brand/ShaderBg.tsx
  • Shader definitions: src/lib/shaderLibrary.ts + src/lib/shaderPack*.ts
  • The component gallery: /components