makepad/apps/vj/resources/effects/109_trans_additive.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

32 lines
1.4 KiB
Text

// ADDITIVE MIX — the MX50's luminance add: deck B's light POURS INTO deck
// A instead of replacing it (white areas bloom, black adds nothing).
// GAIN pushes B hotter before the add. Ride the fader for how much light.
{
name: "Additive Mix"
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"
p1: 0.5
dials: [
{name: "GAIN", bind: "p0", default: 0.5},
{name: "CURVE", bind: "p1", default: 0.5},
{name: "KEY", bind: "p2", default: 0.0}
]
shader: draw.DrawVjFxDuo {
trans: fn(uv: vec2, t: float) -> vec4 {
let a = self.deck_a(uv)
let b = self.deck_b(uv)
let gain = 0.5 + self.user.x * 1.5
// CURVE bends the pour's fader response (1:1 at mid-knob).
let tt = pow(clamp(t, 0.0, 1.0), pow(4.0, self.user.y * 2.0 - 1.0))
// KEY gates the add by B's own luminance: 0 = plain add,
// full = only B's bright parts pour.
let luma = dot(b.xyz, vec3(0.2126, 0.7152, 0.0722))
let gate = mix(1.0, smoothstep(0.25, 0.75, luma), self.user.z)
let c = a.xyz + b.xyz * gain * tt * gate
return vec4(min(c.x, 1.0), min(c.y, 1.0), min(c.z, 1.0), 1.0)
}
}
}