makepad/apps/vj/resources/effects/111_trans_pip.splash
Admin f44616b2a7 makepad-vj effects: the effect renderstack, with the shaders inside the documents
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.
2026-08-23 01:35:44 +02:00

37 lines
1.9 KiB
Text

// PICTURE-IN-PICTURE — deck B inset over deck A. SIZE scales the inset,
// POS walks it through the four corners (0 = top-left, sweep clockwise).
// The fader FLIES IT IN: at 0 no inset, at full it sits there; mid-ride
// it scales in — which makes it a click-autofade-friendly entrance too.
{
name: "PiP"
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"
p2: 0.5
dials: [
{name: "SIZE", bind: "p0", default: 0.4},
{name: "POS", bind: "p1", default: 0.9},
{name: "FRAME", bind: "p2", default: 0.5}
]
shader: draw.DrawVjFxDuo {
trans: fn(uv: vec2, t: float) -> vec4 {
let a = self.deck_a(uv)
let size = (0.2 + self.user.x * 0.4) * t
// Corner tour: 0 TL, 0.25 TR, 0.5 BR, 0.75 BL.
let q = self.user.y * 4.0
let cx = mix(0.02, 0.98 - size, clamp(q, 0.0, 1.0) * step(q, 2.0) + step(2.0, q) * (1.0 - clamp(q - 2.0, 0.0, 1.0)))
let cy = mix(0.03, 0.97 - size, clamp(q - 1.0, 0.0, 1.0) * step(q, 3.0) + step(3.0, q) * (1.0 - clamp(q - 3.0, 0.0, 1.0)))
let local = vec2((uv.x - cx) / max(size, 0.001), (uv.y - cy) / max(size, 0.001))
let inside = step(0.0, local.x) * step(local.x, 1.0) * step(0.0, local.y) * step(local.y, 1.0)
let b = self.deck_b(local)
// A hairline border so the inset reads as a WINDOW; FRAME
// scales its width (mid-knob = the stock hairline, 0 = none).
let edge = min(min(local.x, 1.0 - local.x), min(local.y, 1.0 - local.y))
let border = step(edge, 0.02 * (self.user.z * 2.0)) * inside
let c = a.mix(b, inside * step(0.001, t))
return c.mix(vec4(1.0, 1.0, 1.0, 1.0), border * 0.7)
}
}
}