# @description A study of direction after fr-041: debris. by Farbrausch (2007). A dark sepia city is established from street level, then lifts, folds and tears itself into a storm of masonry. Original music. # @tags homage, cinematic, city # debris.dmt - a study of direction after fr-041: debris. (Farbrausch, 2007) # 96 BPM, 23 bars = 57.5 s. A dark sepia city is established from street level, # then lifts, folds and tears itself into a storm of masonry. Original music. title DEBRIS song bpm=96 speed=6 rpb=4 channels=7 loop=0 volume=0.44 scale=2 dither=1 order 0 0 1 1 2 2 3 3 4 4 4 5 6 6 7 7 8 8 9 10 11 11 11 pan 0.50 0.36 0.50 0.52 0.62 0.42 0.50 text tword "DEBRIS" text tcred1 "after fr-041: debris." text tcred2 "by Farbrausch, 2007" uniform camx camy camz fx fy fz rx ry rz ux uy uz roll farD brk storm letterA fiss glow fogA titleA credA flash trail quake kE ringx ringy ringz timeline { 0:00 brk=0.00 storm=0.00 letterA=0.00 fiss=0.00 glow=0.15 fog=0.95 trail=0.06 titleA=0.00 credA=0.00 2:00 brk=0.01 storm=0.02 glow=0.20 3:00 brk=0.02 storm=0.03 glow=0.22 4:00 brk=0.04 storm=0.05 glow=0.28 5:00 brk=0.08 storm=0.08 glow=0.30 6:00 brk=0.14 storm=0.12 glow=0.34 6:08 brk=0.17 storm=0.14 7:00 brk=0.24 storm=0.20 glow=0.42 8:00 brk=0.32 storm=0.35 glow=0.50 9:00 brk=0.38 storm=0.58 glow=0.52 10:00 brk=0.42 storm=0.70 glow=0.55 trail=0.10 10:08 brk=0.45 storm=0.66 11:00 brk=0.47 storm=0.48 glow=0.46 trail=0.08 12:00 brk=0.48 storm=0.22 glow=0.42 letterA=0.00 fiss=0.00 12:08 brk=0.49 storm=0.18 letterA=1.00 13:00 brk=0.50 storm=0.16 letterA=1.00 trail=0.05 14:00 brk=0.52 storm=0.18 letterA=1.00 15:00 brk=0.55 storm=0.28 letterA=0.95 15:08 brk=0.58 storm=0.33 letterA=0.85 fiss=0.00 16:00 brk=0.70 storm=0.78 letterA=0.30 fiss=0.25 glow=0.62 trail=0.14 17:00 brk=0.82 storm=0.94 letterA=0.10 fiss=0.60 glow=0.70 18:00 brk=0.93 storm=1.00 letterA=0.00 fiss=1.00 glow=0.78 trail=0.18 19:00 brk=1.00 storm=0.90 fiss=1.00 glow=0.85 trail=0.20 20:00 brk=1.00 storm=0.68 fiss=0.80 glow=0.62 trail=0.16 21:00 brk=1.00 storm=0.55 fiss=0.60 glow=0.55 trail=0.10 22:00 brk=1.00 storm=0.42 fiss=0.45 glow=0.50 trail=0.02 titleA=0.00 credA=0.00 22:08 titleA=1.00 22:12 credA=1.00 } # ------------------------------------------------------------------ instruments inst kick { f = 42 + 460 * exp(-t * 40) $p = $p + f / sr body = sin($p * tau) * exp(-t * 6.0) click = hp(noise(), 1900) * exp(-t * 95) * 0.4 out(dist((body * 1.85 + click) * 1.1, 1.5) * 0.78) } inst impact { f = 26 + 120 * exp(-t * 5) $p = $p + f / sr body = sin($p * tau) * exp(-t * 2.0) blast = lp(noise(), 760) * exp(-t * 4.5) out(dist(body * 1.5 + blast * 0.8, 1.25) * 0.50) } inst metal { n = svf(noise(), 1400 + 2800 * exp(-t * 24), 0.62) m = sin(tau * (307 + 60 * t) * t + 2.4 * sin(t * 21)) * exp(-t * 7) out((r2 * 0.95 + m * 0.5) * exp(-t * 5.5) * 0.34) } inst tick { out(hp(noise(), 7400) * exp(-t * (44 + 70 * (1 - vel))) * 0.16) } inst sub { e = env(0.008, 0.20, 0.74, 0.30) s = sin(ph * tau) + 0.20 * sin(ph * tau * 2) out(dist(s * e, 1.3) * 0.38) } inst bass { e = env(0.006, 0.13, 0.55, 0.11) s = saw(ph) * 0.5 + sin(ph * tau * 0.5) * 0.42 + sin(ph * tau) * 0.30 s = fold(s * (1 + 0.9 * e), 1.4) s = svf(s, 130 + 900 * e + 500 * p0, 0.36) out(dist(s * e, 1.45) * 0.46) } inst choir nna=continue { e = env(1.10, 0.9, 0.86, 2.6) v = 0.006 * sin(t * 4.3) + 0.003 * sin(t * 2.7) s = usaw(freq * (1 + v), 0.17) f1 = svf(s, 560 + 160 * p0, 0.87) a = r2 f2 = svf(s, 1150 + 260 * p1, 0.85) b = r2 out((a * 0.95 + b * 0.55 + s * 0.10) * e * 0.065) } inst bell { e = exp(-t * 1.55) m = sin(ph * tau * 1.41 + 0.9 * sin(t * 1.2)) * 1.7 * exp(-t * 2.1) s = sin(ph * tau + m) + 0.30 * sin(ph * tau * 2.76) + 0.10 * sin(ph * tau * 5.41) out(s * e * 0.24) } inst air nna=continue { e = env(0.90, 1.1, 0.82, 2.2) n = svf(noise(), 240 + 1800 * p0 + 260 * sin(t * 0.21), 0.52) out((n * 0.85 + r2 * 0.38) * e * 0.12) } chan 3 { wet = verb(x, 0.88, 0.42) out(x * 0.74 + wet * 0.70) } chan 4 { d = dly(x, 0.3125, 0.42) d2 = dly(x, 0.46875, 0.34) out(x * 0.80 + d * 0.34 + d2 * 0.22) } chan 5 { wet = verb(x, 0.90, 0.50) out(x * 0.72 + wet * 0.60) } master { dl = dly(l, 0.417, 0.30) dr = dly(r, 0.531, 0.30) wet = verb(l * 0.5 + r * 0.5, 0.84, 0.46) out(dist((l + dr * 0.14 + wet * 0.16) * 0.72, 1.05), dist((r + dl * 0.14 + wet * 0.16) * 0.72, 1.05)) } # ------------------------------------------------------------------ patterns # 0: drone, distant city pattern 0 rows=16 { . | . | D-1 4 30 | D-3 5 26 | . | C-4 7 14 S00 | . . . . . | . | . | A-3 5 16 | . | . . . . . | . | . | D-3 5 20 | D-5 6 12 | . . . | . | . | F-3 5 14 | . | . . } # 1: a heartbeat under the street pattern 1 rows=16 { C-1 1 30 | . | D-1 4 32 | D-3 5 26 | . | C-4 7 16 S20 | . . . . . | . | . | A-3 5 16 | . | . . | C-6 2 12 | . | D-3 5 22 | . | . . . . | . | A-0 4 28 | F-3 5 18 | D-5 6 12 | . . . | C-6 2 10 | . | . | . | . . } # 2: pulse, sub, first cracks pattern 2 rows=16 { C-1 1 38 | . | D-1 4 36 | D-3 5 26 | . | C-4 7 16 S40 | . . | . | . | . | . | . . | . | . | . | . | . . | . | . | . | . | . C-1 1 34 | . | A-0 4 34 | A-3 5 18 | . | . . | . | . | . | . | . . | . | . | . | . | . . | C-6 2 14 | . | . | . | . C-1 1 38 | . | D-1 4 36 | D-3 5 26 | . | . . | . | . | . | . | . . | . | . | . | . | . . | . | . | . | . | . C-1 1 34 | . | F-0 4 32 | F-3 5 18 | . | . . | . | . | . | . | . . | . | . | . | . | . . | C-6 2 16 | . | . | . | . } # 3: bass enters, metal answers pattern 3 rows=16 { C-1 1 40 | . | D-1 4 40 | D-3 5 28 | . | C-4 7 18 S80 | . . | . | D-1 4 20 | . | . | . . | . | F-1 4 30 | . | . | . . | . | D-1 4 24 | . | . | . C-1 1 38 | C-5 2 30 | A-0 4 38 | A-3 5 20 | . | . . | . | A-0 4 22 | . | . | . . | . | C-1 4 28 | . | . | . . | . | A#0 4 26 | . | . | . C-1 1 40 | . | D-1 4 40 | D-3 5 28 | . | . . | . | D-1 4 22 | . | . | . . | . | F-1 4 30 | . | . | . . | . | G-1 4 26 | . | . | . C-1 1 38 | C-5 2 34 | A-0 4 38 | A-3 5 20 | . | . . | . | A-0 4 20 | . | . | . . | . | C-1 4 28 | . | . | . . | C-5 2 20 | A#0 4 26 | . | . | . } # 4: full industrial groove - blocks lift pattern 4 rows=16 { C-1 1 40 | . | D-1 4 3E | D-3 5 30 | . | C-4 7 18 S80 | . . | . | D-1 4 22 | . | . | . . | C-5 2 34 | F-1 4 32 | . | . | . C-1 1 34 | . | D-1 4 24 | . | . | . C-1 1 40 | C-5 2 30 | A-0 4 3E | A-3 5 22 | . | C-4 7 20 S90 | . . | . | A-0 4 22 | . | . | . . | C-5 2 34 | C-1 4 32 | . | . | . C-1 1 34 | . | A#0 4 26 | . | . | . C-1 1 40 | . | D-1 4 3E | D-3 5 30 | . | . . | . | D-1 4 22 | . | . | . . | C-5 2 34 | F-1 4 32 | . | . | . C-1 1 34 | . | G-1 4 28 | . | . | . C-1 1 40 | C-5 2 30 | A-0 4 3E | A-3 5 22 | . | . . | . | A-0 4 22 | . | . | . . | C-5 2 32 | C-1 4 30 | . | . | . C-1 1 34 | C-5 2 18 | A#0 4 26 | . | . | . } # 5: the break before the pull-back pattern 5 rows=16 { C-1 6 40 | C-5 2 36 | D-1 4 40 | D-3 5 32 | . | C-4 7 22 S40 | . . | . | . | . | . | . . | . | . | . | . | . . | . | . | . | . | . . | C-5 2 26 | A-0 4 32 | A-3 5 24 | . | . . | . | . | . | . | . . | . | . | . | . | . . | . | . | . | . | . . | . | D-1 4 36 | D-3 5 30 | D-5 6 14 | . . | . | . | . | . | . . | . | . | . | . | . . | . | . | . | . | . . | C-6 2 18 | A-0 4 30 | F-3 5 24 | . | . . | . | . | . | . | . . | . | . | . | . | . . | . | . | . | . | . } # 6: quiet - the giant letters pattern 6 rows=16 { . | . | D-1 4 15 | D-3 5 15 | . | . | . . | . | . | F-3 5 11 | . | C-4 7 14 S20 | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | A-0 4 12 | A-3 5 11 | D-5 6 16 | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | D-1 4 13 | D-3 5 14 | . | . | . . | . | . | . | . | . | . . | . | . | . | F-5 6 13 | . | . . | . | . | . | . | . | . . | C-6 2 8 | A-0 4 11 | A-3 5 10 | . | C-4 7 16 S30 | . . | . | . | . | . | . | . . | . | . | . | E-5 6 12 | . | . . | . | . | . | . | . | . } # 7: quiet 2 - more air pattern 7 rows=16 { . | . | D-1 4 15 | D-3 5 15 | . | C-4 7 16 S30 | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | A-0 4 12 | A-3 5 11 | D-5 6 15 | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | D-1 4 13 | D-3 5 14 | . | . | . . | . | . | . | . | . | . . | . | . | F-3 5 10 | F-5 6 12 | . | . . | . | . | . | . | . | . . | C-6 2 10 | A-0 4 12 | A-3 5 10 | . | C-4 7 18 S60 | . . | . | . | . | . | . | . . | . | . | . | E-5 6 11 | . | . . | . | . | . | . | . | . } # 8: build - the cut pattern 8 rows=16 { C-1 1 40 | . | D-1 4 3E | D-3 5 30 | . | C-4 7 30 S00 | . . | . | D-1 4 24 | . | . | C-4 7 30 S20 | . . | C-5 2 34 | F-1 4 32 | . | . | C-4 7 30 S40 | . . | . | D-1 4 24 | . | . | C-4 7 30 S60 | . C-1 1 38 | C-5 2 30 | A-0 4 3E | A-3 5 22 | . | C-4 7 30 S80 | . . | C-5 2 22 | A-0 4 22 | . | . | C-4 7 30 SA0 | . . | C-5 2 34 | C-1 4 32 | . | . | C-4 7 30 S80 | . C-1 1 34 | . | A#0 4 26 | . | . | C-4 7 30 S60 | . C-1 1 40 | C-6 2 20 | D-1 4 3E | D-3 5 30 | . | C-4 7 30 S80 | . . | C-5 2 26 | D-1 4 24 | . | . | C-4 7 30 SA0 | . . | C-5 2 34 | F-1 4 32 | . | . | C-4 7 30 S80 | . . | C-5 2 20 | G-1 4 28 | . | . | C-4 7 30 S40 | . C-1 1 40 | C-5 2 30 | A-0 4 3E | A-3 5 22 | . | C-4 7 30 S60 | . C-1 1 34 | . | A-0 4 26 | . | . | C-4 7 30 S80 | . C-1 1 40 | C-5 2 34 | C-1 4 30 | . | . | C-4 7 30 SA0 | . C-1 1 40 | C-6 2 26 | A#0 4 28 | . | . | C-4 7 30 S40 | . } # 9: the sky tears pattern 9 rows=16 { C-1 1 40 | C-5 2 38 | D-1 4 40 | D-3 5 32 | . | C-4 7 24 S60 | C-1 6 40 . | . | D-1 4 24 | D#3 5 20 | . | . | . C-1 1 38 | C-5 2 30 | F-1 4 34 | . | A#5 6 17 | . | . C-1 1 40 | . | D-1 4 26 | . | . | . | . C-1 1 40 | C-5 2 38 | A-0 4 40 | A-3 5 24 | D-5 6 16 | C-4 7 26 S70 | C-1 6 40 . | . | A-0 4 24 | . | . | . | . C-1 1 38 | C-5 2 30 | C-1 4 34 | . | A-5 6 17 | . | . C-1 1 40 | C-5 2 22 | A#0 4 28 | . | . | . | . C-1 1 40 | C-5 2 38 | D-1 4 40 | D-3 5 32 | . | . | . . | . | D-1 4 24 | F-3 5 20 | . | . | . C-1 1 38 | C-5 2 30 | F-1 4 34 | . | F-5 6 17 | . | . C-1 1 40 | . | G-1 4 28 | . | . | . | . C-1 1 40 | C-5 2 38 | A-0 4 40 | A-3 5 24 | E-5 6 15 | C-4 7 26 S80 | C-1 6 40 . | . | A-0 4 24 | . | . | . | . C-1 1 38 | C-5 2 30 | C-1 4 34 | . | E-5 6 17 | . | . C-1 1 40 | C-5 2 22 | A#0 4 28 | D#3 5 18 | . | . | . } # 10: collapse pattern 10 rows=16 { C-1 6 40 | C-5 2 34 | D-1 4 40 | D-3 5 30 | . | C-4 7 24 S30 | C-1 6 40 . | . | . | . | . | . | . . | . | D-1 4 24 | . | . | . | . . | . | . | . | . | . | . . | C-5 2 24 | A-0 4 30 | A-3 5 22 | D-5 6 17 | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . C-1 6 40 | . | D-1 4 36 | D-3 5 28 | . | C-4 7 22 S40 | C-1 6 40 . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | C-6 2 20 | A-0 4 28 | F-3 5 20 | A#4 6 17 | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . } # 11: dissolve, title pattern 11 rows=16 { C-1 6 30 | C-5 2 28 | D-1 4 28 | D-3 5 22 | . | C-4 7 24 S10 | C-1 6 30 . | . | . | . | . | . | . . | . | . | A-3 5 15 | . | . | . . | . | . | . | . | . | . . | C-6 2 16 | A-0 4 20 | F-3 5 22 | D-5 6 14 | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . . | . | D-1 4 24 | D-3 5 26 | . | C-4 7 20 S30 | . . | . | . | . | . | . | . . | C-5 2 14 | . | . | . | . | . . | . | . | . | . | . | . . | . | A-0 4 22 | A-3 5 15 | . | . | . . | . | . | . | E-5 6 10 | . | . . | . | . | . | . | . | . . | . | . | . | . | . | . } # ------------------------------------------------------------------ geometry fn box(px, py, pz, bx, by, bz) { qx = abs(px) - bx qy = abs(py) - by qz = abs(pz) - bz return len(len(max(qx, 0), max(qy, 0)), max(qz, 0)) + min(max(qx, max(qy, qz)), 0) } fn buckle(px, pz) { b = brk * brk return b * (1.25 * sin(pz * 0.21 + brk * 3.0) + 0.55 * sin(pz * 0.061 - 1.3)) * exp(-abs(px - 6) * 0.03) } fn bridge(px, py, pz) { # an elevated road across the canyon; it folds and dives as brk rises bend = 2.6 * sin(px * 0.13 + brk * 3.4) + brk * 7.0 * sin(px * 0.05) bz = pz - (26 + bend * 0.5) return box(px - 6, py - (7.4 - brk * 3.0 * sin(px * 0.08)), bz, 44, 0.19, 1.10) * 0.8 } fn ringd(px, py, pz) { # the landmark: a monumental steel portal over the avenue qx = px - 6 qy = py - 20.0 rq = len(qx, qy) return len(rq - 14.0, pz - 40) - 1.0 } fn city(px, py, pz) { g = py - buckle(px, pz) cx = floor(px / 12 + 0.5) cz = floor(pz / 12 + 0.5) lx = px - cx * 12 lz = pz - cz * 12 hh = 5 + 15 * hash(cx * 12.9898 + cz * 78.233) hh = hh * step(0.09, hash(cx * 3.17 + cz * 5.71)) + 0.05 gm = smooth(0.58, 0.97, brk) gone = step(1 - gm * 1.05, hash(cx * 9.13 + cz * 4.71)) hh = hh * (1 - 0.97 * gone) hw = 2.4 + 0.8 * hash(cx * 2.33 + cz * 4.17) hd = 2.4 + 0.8 * hash(cx * 6.11 + cz * 1.73) th = hash(cx * 1.71 + cz * 9.31) * 0.55 k = smooth(th, th + 0.32, brk) ly = py - hh * 0.5 - k * (4.0 + 16.0 * hash(cx * 5.11 + cz * 2.97)) lx = lx - k * 2.2 * (hash(cx * 8.11 + cz * 3.31) - 0.5) lz = lz - k * 2.2 * (hash(cx * 4.71 + cz * 6.91) - 0.5) ay = k * 2.3 * (hash(cx * 3.91 + cz * 7.73) - 0.5) la = rot(lx, lz, ay) lz = r1 lx = la ax = k * 0.30 * (hash(cx * 6.71 + cz * 1.31) - 0.5) lb = rot(ly, lz, ax) lz = r1 ly = lb d = box(lx, ly, lz, hw, hh * 0.5, hd) return min(min(min(d, g), bridge(px, py, pz)), ringd(px, py, pz)) } fn swarm(sc, spd, seed, st) { ax = u * sc + camx * 0.02 * sc + time * spd + seed * 3.7 ay = v * sc + camy * 0.02 * sc + sin(time * 0.13 + seed) * 0.8 ix = floor(ax) iy = floor(ay) h1 = hash(ix * 1.71 + iy * 4.31 + seed * 2.1) h2 = hash(ix * 7.13 + iy * 2.97 + seed * 5.3) h3 = hash(ix * 3.37 + iy * 8.11 + seed * 7.7) dx = fract(ax) - 0.5 - (h1 - 0.5) * 0.8 dy = fract(ay) - 0.5 - (h2 - 0.5) * 0.8 wd = 0.016 + 0.060 * h3 hg = 0.008 + 0.026 * h1 m = step(abs(dx), wd * st) * step(abs(dy), hg) shade = 0.55 + 0.45 * step(0.0, dx + dy) return m * shade * step(0.18, h3) } frame { kE = exp(-trig(0) * 8) mE = exp(-trig(1) * 9) iE = exp(-trig(6) * 4) brk = evtl(brk) storm = evtl(storm) letterA = evtl(letterA) fiss = evtl(fiss) glow = evtl(glow) fogA = evtl(fog) trail = evtl(trail) titleA = evtl(titleA) credA = evtl(credA) quake = 1.8 * brk * brk + iE * 0.8 # ---- shot 1: street level dolly, tilting up at the lifting block p1 = smooth(0, 19, t) s1x = 6.0 + 0.55 * sin(t * 0.17) + quake * 0.05 * sin(t * 31) s1y = 1.78 + 1.5 * p1 * p1 + quake * 0.03 * sin(t * 27) s1z = -10 + 38 * p1 tilt = smooth(9, 18, t) s1tx = 6 + 3.5 * tilt + 1.4 * sin(t * 0.13) s1ty = 3.4 + 13.5 * tilt s1tz = s1z + 18 # ---- shot 2: the crane back. same corner becomes one fleck in the storm; # then the camera tilts up to the letters standing in the haze p2 = smooth(20, 32, t) p3 = smooth(30, 40, t) s2x = mix(6, -4, p2) + 6 * p3 + 1.2 * sin(t * 0.11) s2y = mix(3.2, 12, p2) + 1.0 * p3 s2z = mix(20, -6, p2) - 8 * p3 s2tx = mix(10, 6, p2) + 3 * p3 s2ty = mix(18, 7.0, p2) + 2 * smooth(32, 39, t) s2tz = mix(38, 44, p2) # ---- shot 3: cut. inside the storm, diving between the falling blocks p4 = smooth(40, 50, t) s3x = 6.0 - 2.0 * p4 + 0.8 * sin(t * 0.9) s3y = 3.2 + 1.5 * p4 + 0.4 * sin(t * 1.3) s3z = 26 + 38 * p4 s3tx = 6 + 3 * sin(t * 0.4) s3ty = 5 + 4 * p4 s3tz = s3z + 34 # ---- shot 4: settle, look up at the tear p5 = smooth(50, 57.5, t) s4x = mix(4.0, 2.0, p5) + 1.0 * sin(t * 0.28) s4y = mix(4.7, 8.5, p5) s4z = mix(64, 72, p5) s4tx = mix(6.0, 2.0, p5) s4ty = mix(9.0, 20.0, p5) s4tz = 110 # ---- chain the shots (hard cut at 40 s) cut = step(40, t) camx = mix(s1x, s2x, p2) camy = mix(s1y, s2y, p2) camz = mix(s1z, s2z, p2) tx = mix(s1tx, s2tx, p2) ty = mix(s1ty, s2ty, p2) tz = mix(s1tz, s2tz, p2) camx = mix(camx, s3x, cut) camy = mix(camy, s3y, cut) camz = mix(camz, s3z, cut) tx = mix(tx, s3tx, cut) ty = mix(ty, s3ty, cut) tz = mix(tz, s3tz, cut) camx = mix(camx, s4x, p5) camy = mix(camy, s4y, p5) camz = mix(camz, s4z, p5) tx = mix(tx, s4tx, p5) ty = mix(ty, s4ty, p5) tz = mix(tz, s4tz, p5) # ---- shake on impacts and on the cut shakeA = iE * 0.22 + exp(-abs(t - 40) * 7) * 0.35 + 0.05 * brk camx = camx + shakeA * sin(t * 43.1) * 0.5 camy = camy + shakeA * sin(t * 37.7 + 1.3) * 0.35 tx = tx + shakeA * sin(t * 29.3 + 0.7) * 0.7 # ---- camera basis fx = tx - camx fy = ty - camy fz = tz - camz fl = len(len(fx, fz), fy) + 0.0001 fx = fx / fl fy = fy / fl fz = fz / fl rl = len(fx, fz) + 0.0001 rx = fz / rl ry = 0 rz = -fx / rl ux = fy * rz uy = fz * rx - fx * rz uz = -fy * rx # ---- roll: subtle in the street, tumbling inside the storm rollA = mix(0.02 * sin(t * 0.21), 0.05 * sin(t * 0.17), p2) rollA = mix(rollA, 0.22 * sin(t * 0.63) + 0.08 * sin(t * 1.7), cut) roll = mix(rollA, 0.03 * sin(t * 0.15), p5) farD = mix(62, 132, clamp((camy - 5) / 25, 0, 1)) flash = max(iE * 1.1, kE * 0.22) + exp(-abs(t - 40) * 9) * 0.6 # project the giant ring centre into screen space so the cube spiral wraps it rgx = 6.0 - camx rgy = 20.0 - camy rgz = 40.0 - camz rzd = rgx * fx + rgy * fy + rgz * fz rzd = max(rzd, 0.5) ringz = rzd ringx = (rgx * rx + rgy * ry + rgz * rz) / (rzd * 0.72) ringy = (rgx * ux + rgy * uy + rgz * uz) / (rzd * 0.72) } pixel { # ---------------------------------------------------------------- camera ray ru = rot(u, v, roll) rv = r1 dx = fx + rx * ru * 0.72 + ux * rv * 0.72 dy = fy + ry * ru * 0.72 + uy * rv * 0.72 dz = fz + rz * ru * 0.72 + uz * rv * 0.72 dl = len(len(dx, dz), dy) + 0.00001 dx = dx / dl dy = dy / dl dz = dz / dl # ---------------------------------------------------------------- march tt = 0.05 d = 1 hit = 0 repeat i 40 { px = camx + dx * tt py = camy + dy * tt pz = camz + dz * tt d = city(px, py, pz) hit = max(hit, step(d, 0.028)) tt = tt + max(d * 0.76, 0.03) * step(0.028, d) * step(tt, farD) } px = camx + dx * tt py = camy + dy * tt pz = camz + dz * tt # ---------------------------------------------------------------- normal e = 0.035 c0 = city(px, py, pz) c1 = city(px + e, py, pz) c2 = city(px, py + e, pz) c3 = city(px, py, pz + e) nx = c1 - c0 ny = c2 - c0 nz = c3 - c0 nl = len(len(nx, nz), ny) + 0.00001 nx = nx / nl ny = ny / nl nz = nz / nl # ---------------------------------------------------------------- local block cx0 = floor(px / 12 + 0.5) cz0 = floor(pz / 12 + 0.5) llx = px - cx0 * 12 llz = pz - cz0 * 12 hh = 5 + 15 * hash(cx0 * 12.9898 + cz0 * 78.233) hh = hh * step(0.09, hash(cx0 * 3.17 + cz0 * 5.71)) + 0.05 gm = smooth(0.58, 0.97, brk) gone = step(1 - gm * 1.05, hash(cx0 * 9.13 + cz0 * 4.71)) hh = hh * (1 - 0.97 * gone) hw = 2.4 + 0.8 * hash(cx0 * 2.33 + cz0 * 4.17) hd = 2.4 + 0.8 * hash(cx0 * 6.11 + cz0 * 1.73) th = hash(cx0 * 1.71 + cz0 * 9.31) * 0.55 kk = smooth(th, th + 0.32, brk) rise = kk * (4.0 + 16.0 * hash(cx0 * 5.11 + cz0 * 2.97)) lly = py - hh * 0.5 - rise llx = llx - kk * 2.2 * (hash(cx0 * 8.11 + cz0 * 3.31) - 0.5) llz = llz - kk * 2.2 * (hash(cx0 * 4.71 + cz0 * 6.91) - 0.5) ay = kk * 2.3 * (hash(cx0 * 3.91 + cz0 * 7.73) - 0.5) la = rot(llx, llz, ay) llz = r1 llx = la ax = kk * 0.30 * (hash(cx0 * 6.71 + cz0 * 1.31) - 0.5) lb = rot(lly, llz, ax) llz = r1 lly = lb # ---------------------------------------------------------------- shading gb = py - buckle(px, pz) ground = step(abs(gb), 0.10) dbg = bridge(px, py, pz) steel = step(abs(dbg), 0.35) * (1 - ground) drg = ringd(px, py, pz) rring = step(abs(drg), 0.28) * (1 - ground) side = (1 - ground) * (1 - steel) * (1 - rring) # facade grid in the block's own frame wv = (lly + hh * 0.5) * 2.6 + hash(cx0 * 5.7 + cz0 * 2.1) * 1.7 wu = (abs(nx) > abs(nz) ? llz : llx) * 3.2 + hash(cx0 * 2.9 + cz0 * 8.3) * 2.0 fu = fract(wu) fv = fract(wv) inw = step(0.24, fu) * step(fu, 0.70) * step(0.28, fv) * step(fv, 0.62) wc = hash(floor(wu) * 3.31 + floor(wv) * 7.73 + cx0 * 13.1 + cz0 * 7.9) flick = 0.14 * sin(t * 2.1 + wc * 12.0) * step(0.7, hash(floor(wu) + floor(wv) * 2.1)) lit = inw * step(0.755, wc + flick + 0.07 * kE) * side btint = hash(cx0 * 7.7 + cz0 * 3.1) cold = lit * step(0.94, btint) warm = lit * (1 - cold) floorline = step(0.88, fract((lly + hh * 0.5) * 0.34)) * side roof = step(0.65, abs(ny)) * (1 - ground) * (1 - rring) roofg = step(0.70, hash(floor(llx * 2.2) * 3.1 + floor(llz * 2.2) * 7.3 + cx0 * 5.1)) * roof * 0.030 neon = step(0.82, hash(cx0 * 2.31 + cz0 * 4.77)) * step(0.65, abs(ny)) * (1 - ground) * (1 - rring) neonb = neon * (1 - steel) * step(hh - 0.55, lly + hh * 0.5) * step(lly + hh * 0.5, hh + 0.02) * step(0.55, hash(cx0 * 8.1 + cz0 * 1.9)) # brick courses and aggregate grain = hash(px * 4.1 + pz * 3.3 + py * 6.7) * 0.5 + hash(px * 13.1 + py * 17.3) * 0.5 course = step(0.84, fract((lly + hh * 0.5) * 5.2 + hash(cx0 * 3.1 + cz0 * 2.7) * 4.0)) * side # light: cold sky key from above, warm sodium bounce from the street lxn = -0.35 lyn = 0.82 lzn = -0.45 diff = max(nx * lxn + ny * lyn + nz * lzn, 0) amb = 0.010 + 0.020 * max(ny, 0) brick = (0.085 + 0.095 * grain + 0.025 * btint) * (1 - ground * 0.80) bt2 = hash(cx0 * 3.7 + cz0 * 6.1) brr = brick * (0.92 + 0.38 * bt2) bgg = brick * (0.60 + 0.10 * bt2) bbb = brick * (0.46 + 0.08 * bt2) # wet blue street: sky sheen, sodium pools, lane paint ix = fract(px / 12 + 0.5) - 0.5 iz = fract(pz / 12 + 0.5) - 0.5 pool = exp(-len(ix, iz) * 9) * (0.55 + 0.45 * hash(floor(px / 12 + 0.5) * 1.7 + floor(pz / 12 + 0.5) * 4.3)) streak = exp(-abs(ix) * 26) * 0.4 + exp(-abs(iz) * 26) * 0.4 lane = step(abs(px - 6), 0.07) * step(0.55, fract(pz * 0.33)) * 0.16 fres = pow(max(1 + dy, 0), 5) * 0.11 sxd = abs(fract(px / 12) - 0.5) * 12 szd = abs(fract(pz / 12) - 0.5) * 12 dash = (step(sxd, 0.10) * step(0.5, fract(pz * 0.5)) + step(szd, 0.10) * step(0.5, fract(px * 0.5))) cross = step(sxd, 2.3) * step(szd, 2.3) * step(0.5, fract((px + pz) * 0.8)) swalk = exp(-abs(abs(llx) - hw - 0.45) * 10) + exp(-abs(abs(llz) - hd - 0.45) * 10) asphalt = 0.55 + 0.45 * fbm(px * 0.45, pz * 0.45, 3) wet = ground * (pool * 0.38 + streak * 0.10 + lane + fres + 0.012 + dash * 0.075 + cross * 0.025 + swalk * 0.05) * asphalt # sodium lamps down both sides of the canyon lz0 = floor(pz / 12 + 0.5) * 12 lamp = exp(-len(len(px - 3.2, pz - lz0), py - 4.6) * 1.15) + exp(-len(len(px - 8.8, pz - lz0), py - 4.6) * 1.15) lamp = lamp * (0.35 + 0.4 * hash(lz0 * 0.37)) # assemble: cold concrete and warm brick, cream windows cr = amb * 0.80 + brr + diff * 0.060 cg = amb * 1.15 + bgg + diff * 0.075 cb = amb * 1.55 + bbb + diff * 0.095 dwin = inw * side * 0.016 bandrow = step(0.90, fract((lly + hh * 0.5) * 0.95)) * side * 0.026 seam = step(0.955, fract(wu * 0.25)) * side * 0.016 cr = cr + dwin * 0.70 + roofg * 0.85 + bandrow * 0.7 + seam * 0.6 + course * 0.12 cg = cg + dwin * 0.62 + roofg * 0.88 + bandrow * 0.6 + seam * 0.7 + course * 0.11 cb = cb + dwin * 0.52 + roofg * 0.90 + bandrow * 0.5 + seam * 0.8 + course * 0.10 # cream window light is the only warm source cr = cr + warm * 1.10 + cold * 0.18 cg = cg + warm * 0.76 + cold * 0.50 cb = cb + warm * 0.40 + cold * 0.78 cr = cr + wet * 0.58 + lamp * 0.36 + neonb * 0.85 cg = cg + wet * 0.76 + lamp * 0.20 + neonb * 0.30 cb = cb + wet * 0.96 + lamp * 0.09 + neonb * 0.15 # cool grazing rim, so slabs and the ring read against the sky vdn = dx * nx + dy * ny + dz * nz rim = pow(1 - abs(vdn), 3.0) * 0.30 cr = cr + rim * 0.58 cg = cg + rim * 0.78 cb = cb + rim * 1.10 cr = cr - floorline * 0.012 cg = cg - floorline * 0.010 cb = cb - floorline * 0.010 # steel bridge: cold girders with sodium running lights btop = steel * step(0.55, abs(ny)) brun = steel * step(0.975, fract(px * 0.55)) * step(0.4, abs(ny)) * 0.14 cr = cr + steel * (0.105 + 0.03 * sin(t * 3.0 + pz) + lamp * 0.12) + btop * 0.05 + brun * 1.0 cg = cg + steel * (0.115 + 0.03 * sin(t * 2.4 + pz) + lamp * 0.08) + btop * 0.06 + brun * 0.62 cb = cb + steel * (0.130 + 0.03 * sin(t * 2.9 + pz) + lamp * 0.05) + btop * 0.07 + brun * 0.34 # the giant ring: rusted ribs, bright inner lip, cold outer edge anel = atan2(py - 20.0, px - 6) rq = len(px - 6, py - 20.0) rib = step(0.45, fract(anel * 12.0 + 0.5)) tub = step(0.5, fract((rq - 13.0) * 7.0 + anel * 0.8)) rust = 0.45 + 0.55 * hash(floor(anel * 24.0) * 1.7 + 2.3) panel = step(0.78, hash(floor(anel * 24.0) * 3.1 + 7.7)) lip = exp(-abs(rq - 12.98) * 26.0) * rring redge = exp(-abs(rq - 15.02) * 26.0) * rring cr = cr + rring * ((0.190 + 0.070 * rib) * rust + diff * 0.22 + panel * 0.30) * (0.82 + 0.18 * tub) + lip * 1.10 + redge * 0.55 cg = cg + rring * ((0.125 + 0.045 * rib) * rust + diff * 0.24 + panel * 0.19) * (0.82 + 0.18 * tub) + lip * 1.02 + redge * 0.72 cb = cb + rring * ((0.095 + 0.030 * rib) * rust + diff * 0.28 + panel * 0.10) * (0.82 + 0.18 * tub) + lip * 0.95 + redge * 0.95 # fog: cool blue-grey overcast fr = 0.032 fg = 0.044 fb = 0.058 fogk = exp(-tt * 0.008 * fogA) cr = mix(fr, cr, fogk * hit) cg = mix(fg, cg, fogk * hit) cb = mix(fb, cb, fogk * hit) # ---------------------------------------------------------------- sky sky = 1 - hit hy = clamp(dy, -0.15, 0.9) skyT = smooth(-0.04, 0.78, hy) skr = mix(0.082, 0.010, skyT) skg = mix(0.108, 0.028, skyT) skb = mix(0.128, 0.048, skyT) cloud = fbm(u * 2.3 + t * 0.006, v * 2.0 - t * 0.010, 4) cl2 = smooth(0.34, 0.74, cloud) skr = skr + cl2 * 0.055 skg = skg + cl2 * 0.058 skb = skb + cl2 * 0.062 cl3 = smooth(0.55, 0.9, fbm(u * 5.1 - 3.0, v * 4.2 + 1.4, 3)) skr = skr - cl3 * 0.030 skg = skg - cl3 * 0.026 skb = skb - cl3 * 0.022 # sodium band at the horizon, warmer on one side hang = exp(-max(dy + 0.04, 0) * 7.0) wb = hang * (0.55 + 0.45 * sin(u * 1.7 + 0.7)) skr = skr + wb * 0.26 * (0.4 + 0.6 * glow) skg = skg + wb * 0.145 * (0.4 + 0.6 * glow) skb = skb + wb * 0.045 * (0.4 + 0.6 * glow) # cold moon behind cloud mo = exp(-len(u - 0.28, v - 0.34) * 4.2) * 0.10 skr = skr + mo * 0.72 skg = skg + mo * 0.86 skb = skb + mo * 1.05 cr = cr + sky * skr cg = cg + sky * skg cb = cb + sky * skb # ---------------------------------------------------------------- sky fracture if (fiss > 0.01) { n1 = fbm(u * 1.7 + 4.7, v * 1.7 - 2.3, 4) n2 = fbm(u * 4.3 - 2.0, v * 4.3 + 5.0, 3) vd = vor(u * 2.7 + n1 * 0.9 + n2 * 0.35, v * 2.7 + n1 * 0.6) e0 = r2 - vd edge = exp(-e0 * mix(120, 44, fiss)) edge = edge * step(0.52, hash(r1 * 91.7 + floor(t * 0.4))) halo = exp(-e0 * 15.0) * 0.15 tear = exp(-abs(u + 0.10 * sin(t * 0.4) - 0.05) * mix(95, 28, fiss)) * step(0.45, fiss) smk = fbm(u * 1.25 + t * 0.012, v * 1.25 - t * 0.018, 4) brk2 = (0.45 + 0.55 * n2) * (1 - 0.45 * smooth(0.45, 0.85, smk)) hole = smooth(0.62, 1.0, fiss) * exp(-len(u - 0.05, v - 0.12) * 1.6) cr = cr + sky * (fiss * (edge * 1.15 + halo + tear * 0.95) * brk2 + hole * 0.75) cg = cg + sky * (fiss * (edge * 0.80 + halo * 0.60 + tear * 0.58) * brk2 + hole * 0.80) cb = cb + sky * (fiss * (edge * 0.55 + halo * 0.40 + tear * 0.36) * brk2 + hole * 0.86) } # ---------------------------------------------------------------- giant letters if (letterA > 0.01) { if (y > 0.28 && y < 0.46) { wy = (y - 0.28) / 0.18 wxp = (x - 0.18) / 0.64 * 6 li = floor(wxp) lx = fract(wxp) col = smooth(40, 47, t) hl = hash(li * 3.7 + 1.1) lx = lx + col * (hl - 0.5) * 0.9 wy = wy + col * (0.15 + 0.85 * hash(li * 7.3 + 2.2)) slice = floor(wy * 12) lx = lx + col * (hash(slice * 1.7 + li * 5.3) - 0.5) * 0.55 code = str(tword, li) g = glyph(code, lx, wy) g2 = glyph(code, lx + 0.030, wy + 0.026) inside = step(0.5, g) rim = max(g2 - g, 0) hg = 0.5 + 0.5 * wy lr = 0.245 + 0.095 * hg lg = 0.255 + 0.090 * hg lb = 0.255 + 0.085 * hg # sparse windows inside the monolith, to sell its scale wl = step(0.9965, hash(floor(x * 170) * 1.3 + floor(y * 96) * 7.1)) wl2 = step(0.9975, hash(floor(x * 170 + 3.1) * 2.7 + floor(y * 96 + 1.7) * 5.3)) g3 = glyph(code, lx - 0.026, wy - 0.022) rim2 = max(g3 - g, 0) cr = mix(cr, lr, inside * letterA * 0.90) cg = mix(cg, lg, inside * letterA * 0.90) cb = mix(cb, lb, inside * letterA * 0.90) fband = step(0.90, fract(wy * 8.0)) * inside * 0.018 cgrain = (hash(x * 731.0 + y * 389.0) - 0.5) * 0.045 cr = cr + inside * letterA * (wl * 0.95 + wl2 * 0.38 + cgrain) + fband * 0.35 cg = cg + inside * letterA * (wl * 0.72 + wl2 * 0.54 + cgrain) + fband * 0.34 cb = cb + inside * letterA * (wl * 0.48 + wl2 * 0.68 + cgrain) + fband * 0.33 cr = cr + rim * letterA * 0.45 + rim2 * letterA * 0.16 cg = cg + rim * letterA * 0.48 + rim2 * letterA * 0.18 cb = cb + rim * letterA * 0.55 + rim2 * letterA * 0.22 } } # ---------------------------------------------------------------- cube spiral # dense tumbling cubes wrapping the giant ring, like the original spA = smooth(10.0, 14.0, t) * (1.0 - smooth(36.0, 40.0, t)) * step(ringz, 80.0) if (spA > 0.01) { scx = u - ringx scy = v - ringy rc = len(scx, scy) ac = atan2(scy, scx) baseR = 14.0 / (ringz * 0.72) rr = baseR * (1.0 + 0.045 * sin(ac * 3.0 + t * 0.55) + 0.020 * sin(ac * 8.0 - t * 0.9)) spin = t * 0.55 sc = ac / tau * 18.0 - spin + rc * 0.6 ci = floor(sc) cf = fract(sc) h0 = hash(ci * 7.13 + 2.7) h1 = hash(ci * 3.71 + 5.1) h2 = hash(ci * 9.37 + 1.9) scale = 16.0 / ringz rad = (0.022 + 0.030 * h1) * scale sz = 0.30 + 0.20 * h0 bx = abs(rc - rr) / rad by = abs(cf - 0.5) / sz blk = step(bx, 1.0) * step(by, 1.0) * step(0.02, h2) side = step(0.0, (rc - rr) * 3.0 + (cf - 0.5)) sh = (0.30 + 0.70 * h0) * (0.55 + 0.45 * side) cr = cr + blk * spA * sh * 0.45 cg = cg + blk * spA * sh * 0.50 cb = cb + blk * spA * sh * 0.58 cr = cr * (1.0 - blk * spA * 0.10) cg = cg * (1.0 - blk * spA * 0.10) cb = cb * (1.0 - blk * spA * 0.08) } # ---------------------------------------------------------------- debris storm if (storm > 0.02) { m1 = swarm(9, 0.05, 1.3, 3.0) m2 = swarm(15, 0.10, 4.7, 2.6) m3 = swarm(26, 0.19, 8.1, 2.0) dust = storm * (m1 * 0.95 + m2 * 0.80 + m3 * 0.60) cr = cr + dust * 0.52 cg = cg + dust * 0.68 cb = cb + dust * 0.80 # dark flecks in front of the glow md = swarm(11, 0.07, 6.3, 2.4) + swarm(21, 0.15, 3.1, 3.2) md = min(md, 1) * storm * 0.55 cr = cr * (1 - md) cg = cg * (1 - md) cb = cb * (1 - md) # a few big cubes big = swarm(5.5, 0.02, 2.9, 1.1) cr = cr + big * storm * 0.22 cg = cg + big * storm * 0.16 cb = cb + big * storm * 0.11 } # ---------------------------------------------------------------- title + credit if (titleA > 0.01) { bm = smooth(0.27, 0.40, y) * (1 - smooth(0.52, 0.65, y)) cm = smooth(0.650, 0.685, y) * (1 - smooth(0.765, 0.800, y)) dim = max(bm, cm) * titleA * 0.68 cr = cr * (1 - dim) cg = cg * (1 - dim) cb = cb * (1 - dim) if (y > 0.34 && y < 0.50) { wy = (y - 0.34) / 0.16 wxp = (x - 0.26) / 0.48 * 6 li = floor(wxp) lx = fract(wxp) code = str(tword, li) g = glyph(code, lx, wy) cr = mix(cr, 0.92, step(0.5, g) * titleA) cg = mix(cg, 0.83, step(0.5, g) * titleA) cb = mix(cb, 0.70, step(0.5, g) * titleA) } } if (credA > 0.01) { if (y > 0.688 && y < 0.724) { cw = 0.50 / 21 cxp = (x - 0.25) / cw ci = floor(cxp) lx = fract(cxp) g = glyph(str(tcred1, ci), lx, (y - 0.688) / 0.036) cr = mix(cr, 0.74, step(0.5, g) * credA) cg = mix(cg, 0.66, step(0.5, g) * credA) cb = mix(cb, 0.55, step(0.5, g) * credA) } if (y > 0.730 && y < 0.766) { cw = 0.50 / 20 cxp = (x - 0.25) / cw ci = floor(cxp) lx = fract(cxp) g = glyph(str(tcred2, ci), lx, (y - 0.730) / 0.036) cr = mix(cr, 0.72, step(0.5, g) * credA) cg = mix(cg, 0.64, step(0.5, g) * credA) cb = mix(cb, 0.53, step(0.5, g) * credA) } } # exposure, flash, feedback cr = cr * (1.10 + 0.35 * kE + 0.55 * flash) cg = cg * (1.14 + 0.32 * kE + 0.50 * flash) cb = cb * (1.18 + 0.30 * kE + 0.46 * flash) fade = smooth(0, 1.0, t) rgb(cr * fade, cg * fade, cb * fade) cprev(x, y, trail) } post { b = tap(-2, 0) + tap(2, 0) + tap(0, -2) + tap(0, 2) + tap(-3, -3) + tap(3, 3) + tap(-3, 3) + tap(3, -3) bl = b * 0.125 ca = 0.15 + 2.2 * flash rs = tap(ca, 0) bs = tap(-ca, 0) rr = mix(cget(0), rs, 0.22) + bl * 0.20 gg = cget(1) + bl * 0.22 bb = mix(cget(2), bs, 0.22) + bl * 0.28 bleed = max(bl * 1.7 - cget(0), 0) * 0.22 rr = rr + bleed * 0.55 gg = gg + bleed * 0.75 bb = bb + bleed * 1.05 rain = step(0.992, hash(floor(x * 430) * 1.7 + floor(y * 95 - time * 26))) * (1 - smooth(14, 24, time)) * 0.11 rr = rr + rain * 0.8 gg = gg + rain * 0.9 bb = bb + rain d = len(u, v) rr = rr * (1 - 0.42 * d * d) gg = gg * (1 - 0.42 * d * d) bb = bb * (1 - 0.42 * d * d) gr = (hash(x * 917.1 + y * 331.7 + frame * 17.3) - 0.5) * 0.030 # cold grade: pull the reds down, lift the blues, raise the midtones lum = 0.30 * rr + 0.59 * gg + 0.11 * bb rr = mix(rr, lum * 0.94, 0.18) gg = mix(gg, lum * 1.00, 0.18) bb = mix(bb, lum * 1.10, 0.18) rr = rr * 1.03 + 0.002 gg = gg * 1.05 + 0.003 bb = bb * 1.08 + 0.005 rgb(rr + gr, gg + gr, bb + gr * 1.1) }