feat(shader-transitions): optional shader field — CSS crossfade mixing in HyperShader
What
Makes the shader field in TransitionConfig optional. When omitted, HyperShader performs a smooth CSS opacity crossfade instead of a WebGL effect — using the existing applyFallbackTransition() path that was already there for texture-load failures.
Why
Previously, using HyperShader.init() locked the entire composition into WebGL-only transitions. Any transition that didn't need a shader effect (smooth cuts, crossfades between related beats) still required picking the least-intrusive shader (flash-through-white at 0.01s). This was an all-or-nothing constraint that produced unwanted white flashes in practice.
Now shader and CSS crossfade transitions can be mixed freely in the same composition:
var tl = HyperShader.init({
bgColor: "#000",
scenes: ["beat-1", "beat-2", "beat-3", "beat-4"],
transitions: [
{ time: 4.0, shader: "sdf-iris", duration: 0.7 }, // WebGL shader
{ time: 8.5, duration: 0.8 }, // no shader → CSS crossfade
{ time: 13.0, shader: "domain-warp", duration: 0.6 }, // WebGL shader
],
});
How
TransitionConfig.shaderchanged fromShaderName(required) toShaderName | undefined(optional)- In the program compilation loop: skip transitions with no shader
- In the transition setup loop:
isCssFallback = !t.shader— fallback transitions getprog: null,ready: true,fallback: true,dirty: false— no prewarming needed renderShadercall uses non-null assertion (state.prog!) — safe because the fallback path returns before this pointHfTransitionMeta.shaderin both the local interface andengine/src/types.tsmade optional to matchCachedTransition.progtype widened toWebGLProgram | null
Test plan
- [x] Built
packages/shader-transitions— clean TypeScript, no errors - [x] Tested with a 3-scene composition:
sdf-irisshader + CSS crossfade +domain-warpshader - [x] Rendered to MP4 — both transition types composite correctly
- [x] Verified CSS crossfade fallback uses
applyFallbackTransition()smooth opacity interpolation - [x] Player scrubber works correctly (using
HyperShader.init()withouttimeline:option)
fix the failed ci checks btw