# @description A portal cut through an embedded starfield texture. Branches choose the picture inside it and the sound of the opening transient. # @tags procedural # @collection Demos # @music pulse, snare, bass and FM glints with a branched kick attack # @visual a moving portal into a warped embedded PPM nebula; nested if/else selects the expensive inner field, a dim outer sky, selective edge glow and post bloom # threshold.dmt — a portal cut through an embedded PPM starfield. # The inside uses a warped texture and geometric detail; the outside skips that # work entirely. Branches also choose the sound of the opening transient. title THRESHOLD song bpm=112 speed=6 rpb=4 channels=4 loop=0 volume=0.7 scale=1 dither=1 order 0 1 0 1 1 0 1 0 pan 0.5 0.55 0.5 0.7 texture nebula "assets/threshold-nebula.ppm" text caption "T H R E S H O L D" uniform radius shimmer inst pulse { if (t < 0.035) { out(sin(tau * (92 - t * 1200) * t) * exp(-t * 32) * 0.65 + noise() * exp(-t * 170) * 0.16) } else { out(sin(tau * 49 * t) * exp(-t * 8) * 0.75) } } inst snare { out(hp(noise(), 1200) * exp(-t * 18) * 0.34) } inst bass { e = env(0.02, 0.2, 0.45, 0.3) out((sin(ph * tau) + 0.18 * saw(ph)) * e * 0.5) } inst glint { e = env(0.005, 0.5, 0, 0.5) out((sin(ph * tau + 0.9 * sin(ph * tau * 2)) + sin(ph * tau * 2.01) * 0.25) * e * 0.25) } master { dl = dly(l, 0.268, 0.38) dr = dly(r, 0.402, 0.35) out(l + dr * 0.25, r + dl * 0.25) } pattern 0 rows=16 { C-2 1 38 | . | C-2 3 32 | C-5 4 20 . | . | . | . . | . | . | G-5 4 18 . | . | . | . C-2 1 30 | D-4 2 25 | . | E-5 4 1C . | . | . | . . | . | G-2 3 2E | D-5 4 18 . | . | . | . C-2 1 38 | . | C-2 3 32 | C-5 4 20 . | . | . | . . | . | . | A-5 4 18 . | . | . | . C-2 1 30 | D-4 2 25 | . | G-5 4 1C . | . | . | . . | . | G-2 3 2E | E-5 4 18 . | . | . | . } pattern 1 rows=16 { C-2 1 38 | . | A-1 3 32 | A-5 4 20 . | . | . | . . | . | . | G-5 4 18 . | . | . | . C-2 1 30 | D-4 2 25 | . | E-5 4 1C . | . | . | . . | . | E-2 3 2E | D-5 4 18 . | . | . | . C-2 1 38 | . | A-1 3 32 | C-6 4 20 . | . | . | . . | . | . | A-5 4 18 . | . | . | . C-2 1 30 | D-4 2 25 | . | G-5 4 1C . | . | . | . . | . | E-2 3 2E | E-5 4 18 . | . | . | . } frame { radius = 0.38 + 0.12 * smooth(0, 16, beat) + 0.035 * sin(beat * tau * 0.25) shimmer = exp(-trig(0) * 9) } pixel { cx = u * 0.72 cy = v * 1.12 + 0.04 d = len(cx, cy) # Cheap backdrop: one bilinear sample of the embedded RGB image. back = tex(nebula, x, y) bg = r1 bb = r2 if (d < radius) { # Only portal pixels pay for domain warping and a folded geometric field. warp = fbm(cx * 4 + beat * 0.09, cy * 4, 4) - 0.5 rr = tex(nebula, fract(x * 1.8 + warp * 0.22 + beat * 0.015), fract(y * 1.8 + warp * 0.13)) gg = r1 bl = r2 foldline = kifs(cx * 1.7 + warp * 0.15, cy * 1.7, 1.63, beat * 0.025, 5) veins = exp(-foldline * 17) * 0.38 core = exp(-d * 9) * (0.2 + 0.35 * shimmer) rgb(rr * 1.2 + veins * 0.25 + core * 0.4, gg * 1.25 + veins * 0.6 + core * 0.6, bl * 1.35 + veins + core) } else { if (v < -0.45) { # A quiet reflection below the horizon. rgb(back * 0.12, bg * 0.15, bb * 0.23 + 0.015) } else { rgb(back * 0.27, bg * 0.28, bb * 0.45) } } edge = abs(d - radius) if (edge < 0.065) { glow = exp(-edge * 65) * (0.65 + 0.3 * shimmer) cadd(glow * 0.6, glow * 0.83, glow) } # The label is rasterized only in its narrow band. if (v < -0.64 && v > -0.8) { tx = (u + 0.95) / 0.105 ty = (-v - 0.64) / 0.13 letter = glyph(str(caption, floor(tx)), fract(tx), ty) cadd(letter * 0.38, letter * 0.67, letter) } } post { # Bright portal edges receive a small horizontal bloom; dark sky is untouched. if (cget(2) > 0.48) { left = tap(-2, 0) right = tap(2, 0) cadd((left + right) * 0.055, (r1 + r2) * 0.02, (r1 + r2) * 0.035) } }