Files
heygen-com--hyperframes/docs/packages/shader-transitions.mdx
T
wehub-resource-sync 85453da49f
regression / regression-shards (style-16-prod style-9-prod style-17-prod iframe-render-compat variables-prod mp4-h265-sdr, shard-4) (push) Has been cancelled
regression / regression-shards (style-4-prod style-11-prod style-2-prod animejs-adapter typegpu-adapter parallel-capture-regression, shard-5) (push) Has been cancelled
regression / regression-shards (style-7-prod style-8-prod style-10-prod css-spinner-render-compat webm-transparency mp4-h264-sdr webm-vp9, shard-3) (push) Has been cancelled
regression / regression-shards (sub-composition-video style-18-prod raf-ball-render-compat font-variant-numeric sub-comp-t0 sub-comp-id-selector, shard-7) (push) Has been cancelled
Windows render verification / Detect changes (push) Has been cancelled
Windows render verification / Preflight (lint + format) (push) Has been cancelled
Windows render verification / Render on windows-latest (push) Has been cancelled
Windows render verification / Tests on windows-latest (push) Has been cancelled
CI / Detect changes (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Fallow audit (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Producer: integration tests (push) Has been cancelled
CI / Producer: unit tests (push) Has been cancelled
CI / File size check (push) Has been cancelled
CI / Test: skills (push) Has been cancelled
CI / Skills: manifest in sync (push) Has been cancelled
CI / CLI: npx shim (macos-latest) (push) Has been cancelled
CI / CLI: npx shim (ubuntu-latest) (push) Has been cancelled
CI / CLI: npx shim (windows-latest) (push) Has been cancelled
CI / SDK: unit + contract + smoke (push) Has been cancelled
CI / Test: runtime contract (push) Has been cancelled
CI / Studio: load smoke (push) Has been cancelled
CI / Smoke: global install (push) Has been cancelled
CI / CLI smoke (required) (push) Has been cancelled
CI / Semantic PR title (push) Has been cancelled
Player perf / Detect changes (push) Has been cancelled
Player perf / Preflight (lint + format) (push) Has been cancelled
Player perf / player-perf (push) Has been cancelled
Player perf / Perf: drift (push) Has been cancelled
Player perf / Perf: fps (push) Has been cancelled
Player perf / Perf: parity (push) Has been cancelled
Player perf / Perf: scrub (push) Has been cancelled
Player perf / Perf: load (push) Has been cancelled
preview-regression / Detect changes (push) Has been cancelled
preview-regression / Preflight (lint + format) (push) Has been cancelled
preview-regression / Preview parity (push) Has been cancelled
preview-regression / preview-regression (push) Has been cancelled
regression / regression (push) Has been cancelled
regression / Detect changes (push) Has been cancelled
regression / Preflight (lint + format) (push) Has been cancelled
regression / regression-shards (hdr-regression style-5-prod style-3-prod mov-prores, shard-1) (push) Has been cancelled
regression / regression-shards (overlay-montage-prod style-12-prod chat missing-host-comp-id png-sequence portrait-edge-bleed, shard-6) (push) Has been cancelled
regression / regression-shards (style-13-prod style-6-prod vignelli-stacking gsap-letters-render-compat audio-mux-parity, shard-8) (push) Has been cancelled
regression / regression-shards (style-15-prod hdr-hlg-regression style-1-prod many-cuts vfr-screen-recording render-symlinked-assets, shard-2) (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Docs / Validate docs (push) Has been cancelled
Sync skills to ClawHub / Publish changed skills (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:58:35 +08:00

144 lines
5.2 KiB
Plaintext

---
title: "@hyperframes/shader-transitions"
description: "WebGL shader transitions for HyperFrames scenes and compositions."
---
The shader transitions package adds GPU-accelerated scene-to-scene transitions to HyperFrames compositions. It captures scene samples, uploads them as WebGL textures, and drives fragment-shader compositing from a GSAP timeline.
```bash
npm install @hyperframes/shader-transitions
```
You can also load the browser global build directly:
```html
<script src="https://cdn.jsdelivr.net/npm/@hyperframes/shader-transitions/dist/index.global.js"></script>
```
## When to Use
**Use `@hyperframes/shader-transitions` when you need to:**
- Add shader-based scene transitions such as domain warp, whip pan, glitch, iris, light leak, or thermal distortion
- Attach GPU transitions to an existing GSAP timeline
- Build a transition picker or validation UI around the available shader registry
- Feature-detect native HTML-in-canvas capture support
- Use the producer's deterministic page-side compositor for render-mode captures
**Use a different package if you want to:**
- Render the finished composition to video - use the [CLI](/packages/cli) or [producer](/packages/producer)
- Edit composition structure programmatically - use [sdk](/packages/sdk)
- Build a visual editor surface - use [studio](/packages/studio)
## Package Exports
| Import | Description |
|--------|-------------|
| `init()` | Creates or augments a GSAP timeline with shader transitions |
| `SHADER_NAMES` | Array of supported shader names for validation and UI pickers |
| `isHtmlInCanvasCaptureSupported()` | Feature-detects Chrome's native HTML-in-canvas capture path |
| `installPageSideCompositor()` | Installs the render-mode compositor used by the producer path |
| `isPageSideCompositingSupported()` | Checks whether page-side shader compositing is available |
## Quick Start
```typescript
import { init } from "@hyperframes/shader-transitions";
const timeline = init({
bgColor: "#0a0a0a",
accentColor: "#ff6b2b",
scenes: ["scene-1", "scene-2", "scene-3"],
transitions: [
{ time: 3, shader: "domain-warp", duration: 0.8 },
{ time: 8, shader: "light-leak", duration: 0.7 },
],
});
window.__timelines ??= {};
window.__timelines.hero = timeline;
```
Pass an existing GSAP timeline when the composition already owns the animation sequence:
```typescript
const timeline = gsap.timeline({ paused: true });
timeline.from("#headline", { opacity: 0, y: 40, duration: 0.6 });
init({
bgColor: "#000000",
scenes: ["intro", "demo", "outro"],
transitions: [
{ time: 5, shader: "cinematic-zoom" },
{ time: 12, shader: "glitch", duration: 0.5 },
],
timeline,
});
```
If WebGL is unavailable, the package falls back to normal timeline playback without shader compositing.
## Available Shaders
| Shader | Description |
|--------|-------------|
| `domain-warp` | Organic noise-based warp with a glowing edge |
| `ridged-burn` | Ridged noise burn with sparks and heat glow |
| `whip-pan` | Horizontal motion blur simulating a fast camera pan |
| `sdf-iris` | Circular iris wipe with a glowing ring edge |
| `ripple-waves` | Concentric ripple distortion radiating from center |
| `gravitational-lens` | Warping gravity well with chromatic aberration |
| `cinematic-zoom` | Radial zoom blur with chromatic fringing |
| `chromatic-split` | RGB channel separation expanding from center |
| `glitch` | Digital glitch with block displacement and scanlines |
| `swirl-vortex` | Spiral rotation with noise-based warping |
| `thermal-distortion` | Heat shimmer rising from the bottom |
| `flash-through-white` | Flash to white, then reveal the next scene |
| `cross-warp-morph` | Noise-driven morph blending both scenes |
| `light-leak` | Warm cinematic light leak with lens flare |
Use `SHADER_NAMES` when you need a typed list:
```typescript
import { SHADER_NAMES } from "@hyperframes/shader-transitions";
```
## Configuration
```typescript
type TransitionConfig = {
time: number;
shader?: string;
duration?: number;
ease?: string;
};
type HyperShaderConfig = {
bgColor: string;
accentColor?: string;
scenes: string[];
transitions: TransitionConfig[];
timeline?: gsap.core.Timeline;
compositionId?: string;
previewCaptureFps?: number;
};
```
`shader` is optional. Omit it to use a CSS fallback transition at that point in the timeline.
## Preview and Render Behavior
Browser previews pre-capture transition samples and cache matching snapshots in IndexedDB. Cache keys include the composition ID, scene DOM/style signatures, timing, capture FPS, scale, and dimensions, so normal page refreshes can reuse samples while runtime edits invalidate only adjacent transition caches.
During producer renders, shader transitions use a deterministic page-side compositor instead of preview-time snapshot caching. That keeps frame capture seek-driven and avoids depending on wall-clock playback.
## Related Packages
<CardGroup cols={2}>
<Card title="@hyperframes/producer" icon="video" href="/packages/producer">
Renders compositions that include shader transitions.
</Card>
<Card title="Transition Catalog" icon="sparkles" href="/catalog/blocks/transitions-distortion">
Browse installable transition blocks built on the shader system.
</Card>
</CardGroup>