makepad/apps/vj/resources/effects/75_coin_fountain.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

68 lines
2.2 KiB
Text

// COIN FOUNTAIN — the greedy Kick Forge variant: fewer, FAT gold chips
// with high spin and maximum glint, tossed in slower arcs (moderate
// gravity = lower but longer flights) so the payout hangs tumbling and
// strobing. Pattern taught: the glint channel driven hard by `high` —
// hats literally make the money sparkle — and low `falloff` so the whole
// drum pays out, not just the centre.
{
name: "Coin Fountain"
engine: "forge"
seed: 77
shards: 1200
radius: 3.6
impulse: 8.0
gravity: 34.0
spin: 2.6
membrane_wave: 0.35
shard_size: 0.26
scatter: 0.8
falloff: 0.35
pile: 0.5
glint: 2.6
beat_pulse: 0.5
p0: "0.7 + 2.0*bass"
p1: "0.2 + 0.8*bass"
p2: "0.4 + 2.5*high"
// PERFORMANCE DIALS — the engine's own p-levers; touching one holds
// its audio binding above at a fixed gain.
dials: [
{name: "HEAT", bind: "p0", default: 0.5},
{name: "RING", bind: "p1", default: 0.5},
{name: "EMBER", bind: "p2", default: 0.5}
]
color_bg: #x0a0806
color_a: #xc9a12c // old gold
color_b: #xffd86a // bright gold
color_c: #xfff7d0 // glint white
cam_orbit: 0.14
cam_fov: 54.0
fog: 0.028
glow: 1.25
stages: [
{kind: "bloom", threshold: 0.5, strength: "1.3 + 1.0*high", levels: 3},
{kind: "tiltshift", focus: 0.5, width: 0.35, levels: 2}
]
// THE LOOK LIVES HERE. This block is not a reference to the
// engine's shader — it IS the pixel math this effect runs.
// Rewrite it and the effect looks different; everything else
// (geometry, motion, the content coupling, the beat) keeps
// working, because the block SUBCLASSES the engine shader.
// Inputs: t = flight heat 0..1, attr = (id, aux, r0, r1).
// Signals: self.time_beat (time, beat, phase, pulse),
// self.sig (bar, bpm, energy, dt), self.user (p0..p3),
// self.col_a/b/c/bg, self.fog (density, glow, content, -).
shader: draw.DrawVjFxForge {
fx_color: fn(t: float, attr: vec4, normal: vec3, wpos: vec3) -> vec4 {
let base = self.col_a.mix(self.col_b, fract(attr.w * 7.93))
let flash = self.col_c * (t * 0.55)
return vec4(base.xyz + flash.xyz, 1.0)
}
}
}