The VJ's EFFECT surface is a small renderer of its own. An effect is a
`.splash` DOCUMENT — engine choice, stages, fields, parameters and now the
SHADERS THEMSELVES live in the document rather than in Rust. That is the
shape this commit introduces (dev has never seen an intermediate one): a
document is the whole effect, and the Rust side is the engine families that
documents draw with.
The engine families: particles and emitters, GPU sim swarms and fluid, static
meshes (firefly synchrony, harmonograph loom, domino liturgy), tiles, flock,
clouds, city, pipes, stock charts, an SDF raymarcher with a subclassable
`scene_sdf`, and a mountain-jet endless range with a beat-pulsed fighter.
Three things make them a system rather than a demo reel:
- SIM FIELDS — a float simulation-texture primitive, so an engine can carry
GPU state across frames (wind, particles, fluid) instead of being a pure
function of the clock.
- CONTENT COUPLING — `content:` in a document and `input0` on every engine's
tex0, so an effect can consume the program video: drapes, backdrops,
mirrors, billboards, chrome, frescoes, canopy, glass, silk, wall, swarm,
pen and mosaic families all take the picture playing behind them.
- MUSIC BINDING — shaders read the beat, so the whole library moves with the
track rather than on its own clock.
Roughly a hundred seeded preset documents ship with it, each with a lazily
rendered animated thumbnail (rendered 4x and box-downscaled, 16-tap SSAA);
the thumbnail pass went from four minutes to eleven seconds. CONTRACT.md is
the document contract and its verify recipe; IDEAS.md is the campaign tracker.
49 lines
1.8 KiB
Text
49 lines
1.8 KiB
Text
// CHROMA KEY — green-screen over the program: deck B replaces deck A
|
|
// wherever B is NEAR THE KEY COLOR… inverted logic from the luma key:
|
|
// the KEYED color becomes transparent, the rest of B rides over A. HUE
|
|
// picks the key color (0 = green, sweep for blue), TOL the tolerance,
|
|
// SOFT the matte edge. Ridden like every MX50 mode: the fader holds it.
|
|
{
|
|
name: "Chroma Key"
|
|
engine: "transition"
|
|
// Overlay semantics: ridden to the fader's end the key STAYS fully
|
|
// applied (the composite is the destination) — never a snap to
|
|
// plain B. Zero only at the A end.
|
|
engage: "ramp"
|
|
dials: [
|
|
{name: "HUE", bind: "p0", default: 0.33},
|
|
{name: "TOL", bind: "p1", default: 0.35},
|
|
{name: "SOFT", bind: "p2", default: 0.2}
|
|
]
|
|
shader: draw.DrawVjFxDuo {
|
|
hue_of: fn(c: vec3) -> float {
|
|
let hi = max(c.x, max(c.y, c.z))
|
|
let lo = min(c.x, min(c.y, c.z))
|
|
let d = hi - lo
|
|
if d < 0.0001 {
|
|
return 0.0
|
|
}
|
|
let mut h = 0.0
|
|
if hi == c.x {
|
|
h = modf((c.y - c.z) / d + 6.0, 6.0)
|
|
} else if hi == c.y {
|
|
h = (c.z - c.x) / d + 2.0
|
|
} else {
|
|
h = (c.x - c.y) / d + 4.0
|
|
}
|
|
return h / 6.0
|
|
}
|
|
trans: fn(uv: vec2, t: float) -> vec4 {
|
|
let a = self.deck_a(uv)
|
|
let b = self.deck_b(uv)
|
|
let h = self.hue_of(b.xyz)
|
|
let d0 = abs(h - self.user.x)
|
|
let dist = min(d0, 1.0 - d0)
|
|
let tol = 0.02 + self.user.y * 0.2
|
|
let soft = 0.005 + self.user.z * 0.1
|
|
// Inside the tolerance = the matte (transparent); outside = B.
|
|
let matte = smoothstep(tol - soft, tol + soft, dist)
|
|
return a.mix(b, matte * t)
|
|
}
|
|
}
|
|
}
|