music-video-gen/flow-state/src/scenes/shader/slow-orb.js
Dejvino 1ca9fa2f1f Let scenes layer on each other, and give the camera somewhere to look
Two devices that were built, wired up, and doing nothing.

OVERLAYS. buildStack gated layering on `surfaceOf(m) === 'composable'`, and
no scene in the library declared `surface` — so the only thing that could ever
sit on top was the one scene declaring `role: 'accent'`, and the overlay roster
excluded accents by construction. Empty intersection, every time: 0/144 stacks
carried an overlay. Every layered frame in every song was the same particle
field.

Labelled the library from the phase 12 coverage gate rather than by eye: the
37 scenes painting under 30% of the frame are composable. Particle Field loses
its privileged slot and becomes one of them, keeping only `background: false`,
which is the honest part — points in empty space cannot carry a section alone.
The reserved accent slot is gone; one roster, two passes at it. 1 distinct
overlay scene becomes 27, and the rate lands at 34% of stacks after trimming a
base chance that had been tuned while the branch was dead.

THE CAMERA. framing.shift moved the frame by a median of 0.029 of a half-frame
at a fresh random angle every shot, so successive offsets cancelled and the
median jump at a cut was 0.014. Present in every frame, visible in none.

look/Camera.js is the director's camera department: the story says tension,
order and which act a section is in, and this turns that into where the frame
looks and how it travels there. Each director names a camera. Jump distance
follows tension and act, speed follows energy, and the curve is one of four.
Cuts choose between reframing and matching, so two scenes can still read as one
place. Median offset 0.190, median reframe 0.135, and 94% of shots now move
during the shot rather than only at the cut.

Four new gates, each with a FLOOR — the device this replaces passed every
existing check while doing nothing, because the only bound was a ceiling.

Also lands the in-progress Epic 4 story layer it builds on: Story.js, phase 13,
and the direction statistic.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-19 06:48:13 +02:00

75 lines
3.0 KiB
JavaScript

// Minimal family: one soft body drifting through a mostly empty frame.
//
// The quietest scene in the library, and the one an ambient intro or a long
// breakdown should usually land on. Nothing here reacts sharply — the beat
// mapping is deliberately weak, because a scene whose job is stillness should
// not twitch.
export const slowOrb = {
name: 'Slow Orb',
family: 'minimal',
kind: 'fragment',
// Paints 11% of the frame — see checks/phase12 coverage.
surface: 'composable',
// Personality: see look/Personality.js.
// One soft body in an empty frame — the emptiest scene in the library, and
// the one where speckle is most visible for being least justified. It keeps
// its own `grain` param, which exists to stop large flat areas banding.
texture: 0,
consumes: ['cast', 'ink'],
traits: ['shape', 'camera', 'space', 'style'],
params: {
size: { type: 'float', range: [0.15, 0.8], default: 0.38, uniform: 'u_size', bias: 'energy' },
softness: { type: 'float', range: [0.2, 1.0], default: 0.7, uniform: 'u_softness' },
drift: { type: 'float', range: [0.01, 0.2], default: 0.05, uniform: 'u_drift', bias: 'motion', rate: true },
wobble: { type: 'float', range: [0, 0.5], default: 0.15, uniform: 'u_wobble' },
palette: { type: 'palette', count: 4 },
},
reactive: {
size: { feature: 'loudness', amount: 0.12, response: 'smooth' },
},
shader: `
vec4 scene(vec2 uv, vec2 p) {
float t = u_time * u_drift + u_seed;
// The orb drifts about the track's horizon rather than about the middle of
// the frame, so it occupies the same space as the scenes that draw ground.
vec2 centre = vec2(sin(t * 1.7) * 0.28, cos(t * 1.3) * 0.18 + sigHorizonY() * 0.45);
vec2 q = sigCamera(p) - centre;
// The body is the track's signature form — this scene is one shape in an
// empty frame, so the shape had better be the track's.
float wobble = fbm(q * 2.4 + t, 4) * u_wobble;
float d = (castMain(q / max(u_size, 1e-3)) * u_size) * (1.0 + wobble);
// TRAIT style: the body's edge is drawn in the track's hand. The scene's
// u_softness says how soft this orb is; u_sigSoft says how soft this VIDEO
// is, and the two multiply.
float edge = u_softness * mix(0.35, 1.5, sat(u_sigSoft));
float body = smoothstep(edge * 0.5, -edge * 0.5, d);
float glow = exp(-max(d, 0.0) * (5.0 / max(0.4, 0.05))) * 0.4;
// A rim in the track's line weight, so a sharp-handed track gets a defined
// limb against the halo instead of only a softer gradient.
float rim = inkStroke(d) * u_sigLine;
vec3 col = pal(0) * 0.05;
col = mix(col, pal(1), body * 0.85);
col += pal(2) * body * body * 0.5;
col += pal(3) * glow * 0.35;
col += pal(2) * rim * 0.5;
// Fine grain keeps large flat areas from banding.
col = sigAir(col, p, smoothstep(0.0, 1.6, length(q)));
col += (hash12(uv * 640.0 + floor(u_frame)) - 0.5) * 0.12 * 0.08;
return vec4(inkValue(col), 1.0);
}
`,
};
export default slowOrb;