#30: forced lighting, intro sounds, scarecrow chest glow

- DayNight.forced ("" / "morning" / "night") overrides target(); snap()
  still works. DayNight.morning() is the MORNING phase's look.
  lanterns_dark keeps every lantern at 0.
- synth_audio.gd: ufo_hum (4 s loop), ufo_whine, part_fall, life_flash,
  ufo_zoom, car_door, each on its own seed (existing wavs unchanged).
  FarmAudio cues for those plus door_creak (kenney creak1/2), all in
  LOCAL_CUES.
- PlayerCharacter: a blue core glow on the chest bone (BoneAttachment3D):
  an unshaded gem, an additive halo pulled toward the camera, and a weak
  pulsing OmniLight3D. On for every scarecrow; set_core_glow(on) hides
  it. set_tint skips it; the hit flash overlay and ToonLook leave it alone.
- test_look: forced/lanterns_dark, the intro cues, the glow on both
  scarecrows, hit flash intact, set_core_glow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-07 21:51:14 -04:00
parent 5dbad4c915
commit 4b86f655c4
17 changed files with 562 additions and 4 deletions

View file

@ -12,6 +12,14 @@ extends SceneTree
## torch tick; back-to-back plays blend into one roar)
## alien_beam.wav a buzzing, warbling ray hum over a high whine and a fizz (an alien ray
## tick; back-to-back plays blend into one hum)
## and the opening intro's (OpeningIntro):
## ufo_hum.wav 4 s loop: the big UFO's low, wobbling, beating drone and a faint warble
## ufo_whine.wav a 2 s spin-up: a whine rising faster and faster, pulsing as it spins
## part_fall.wav a 1.5 s falling whistle, louder as it comes down (the thud is "fall")
## life_flash.wav the blue flash: a crack, a rising zap, a low whomp, and a shimmer of
## sparkles dying away
## ufo_zoom.wav the UFO leaving: a whoosh and a hum whose pitch drops away (doppler)
## car_door.wav a car door slamming: a latch click and a dull metal thunk
## Loops carry a WAV 'smpl' loop point, so the importer's "Detect From WAV" loops them; every
## periodic part of a loop has a whole number of cycles in it and filtered noise is warmed up
## on the loop's own tail, so the seam is silent. Run with the editor closed, then let the
@ -44,6 +52,19 @@ func _initialize() -> void:
_write("torch_roar.wav", _roar(0.42), false)
_rng.seed = 19 # its own seed too
_write("alien_beam.wav", _beam(0.34), false)
# The opening intro's, each on its own seed as well.
_rng.seed = 23
_write("ufo_hum.wav", _hum(4.0), true)
_rng.seed = 29
_write("ufo_whine.wav", _whine(2.0), false)
_rng.seed = 31
_write("part_fall.wav", _whistle(1.5), false)
_rng.seed = 37
_write("life_flash.wav", _life_flash(1.4), false)
_rng.seed = 41
_write("ufo_zoom.wav", _zoom(2.2), false)
_rng.seed = 43
_write("car_door.wav", _door(0.5), false)
quit(0)
@ -162,6 +183,33 @@ func _night(seconds: float) -> PackedFloat32Array:
return _normalize(buf, 0.45)
## The big UFO hovering: two buzzy low tones a little apart (so they beat), both wobbling in
## pitch, under a faint high warble, throbbing, over a low rumble. Every cycle and wobble is a
## whole number of times in the loop (the wobbles' phase is integrated exactly), so it's seamless.
func _hum(seconds: float) -> PackedFloat32Array:
var n := int(seconds * RATE)
var rumble := _noise_lowpass(n, 120.0)
var buf := PackedFloat32Array()
buf.resize(n)
# (Hz, wobble Hz, wobble depth, level): 220, 227, and 1320 cycles in 4 s; wobbles of 6 and 20.
var voices := [[55.0, 1.5, 0.03, 1.0], [56.75, 1.5, 0.03, 0.7], [330.0, 5.0, 0.015, 0.12]]
for i in n:
var t := float(i) / RATE
var s := 0.0
for v: Array in voices:
var f: float = v[0]
var rate: float = v[1]
var phase := f * t + f * float(v[2]) * (1.0 - cos(TAU * rate * t)) / (TAU * rate)
if f < 100.0:
for h in range(1, 7):
s += float(v[3]) * sin(TAU * phase * h) / pow(h, 1.2)
else:
s += float(v[3]) * (0.8 + 0.2 * sin(TAU * 0.5 * t)) * sin(TAU * phase)
var throb := 0.75 + 0.25 * sin(TAU * 3.0 * t) # 12 throbs in 4 s
buf[i] = throb * s + 0.35 * rumble[i]
return _normalize(buf, 0.6)
func _engine(seconds: float) -> PackedFloat32Array:
var n := int(seconds * RATE)
var rumble := _noise_lowpass(n, 180.0)
@ -302,6 +350,143 @@ func _beam(length: float) -> PackedFloat32Array:
return _normalize(buf, 0.7)
## The UFO spinning up: a whine (and a fifth above it) sweeping up faster and faster from a low
## hum, pulsing quicker as it spins, over a rising rush of air; it ends at its peak.
func _whine(length: float) -> PackedFloat32Array:
var n := int(length * RATE)
var air := _band_sweep(n, 300.0, 3000.0, 0.15)
var buf := PackedFloat32Array()
buf.resize(n)
var phase := 0.0
var spin := 0.0
for i in n:
var u := float(i) / n
var f := 140.0 * pow(1800.0 / 140.0, pow(u, 1.3))
phase += f / RATE
spin += lerpf(3.0, 28.0, u * u) / RATE
var pulse := 1.0 - 0.35 * (0.5 + 0.5 * sin(TAU * spin))
var tone := sin(TAU * phase) + 0.3 * sin(TAU * phase * 2.0) + 0.12 * sin(TAU * phase * 3.0) \
+ 0.4 * sin(TAU * phase * 1.5)
var env := minf(u / 0.08, 1.0) * (0.45 + 0.55 * u) * minf((1.0 - u) / 0.04, 1.0)
buf[i] = env * (pulse * tone + 0.6 * u * air[i])
return _normalize(buf, 0.7)
## A falling whistle: a near-pure tone gliding down (with a breath of air), swelling as it
## comes; it stops dead where the part lands.
func _whistle(length: float) -> PackedFloat32Array:
var n := int(length * RATE)
var air := _noise_lowpass(n, 5000.0)
var air_low := _noise_lowpass(n, 1500.0)
var buf := PackedFloat32Array()
buf.resize(n)
var phase := 0.0
for i in n:
var t := float(i) / RATE
var u := float(i) / n
phase += 1900.0 * pow(620.0 / 1900.0, u) * (1.0 + 0.008 * sin(TAU * 6.0 * t)) / RATE
var env := minf(u / 0.13, 1.0) * (0.4 + 0.6 * u) * minf((1.0 - u) / 0.025, 1.0)
buf[i] = env * (sin(TAU * phase) + 0.15 * sin(TAU * phase * 2.0) + 0.25 * (air[i] - air_low[i]))
return _normalize(buf, 0.6)
## The blue flash that brings the scarecrow to life: a sharp crack, a buzzy zap sweeping up, a
## low whomp under it, and a shimmer of high sparkles that flicker and die away.
func _life_flash(length: float) -> PackedFloat32Array:
var n := int(length * RATE)
var white := _noise_lowpass(n, 9000.0)
var white_low := _noise_lowpass(n, 2000.0)
var buf := PackedFloat32Array()
buf.resize(n)
var zap := 0.0
var whomp := 0.0
for i in n:
var t := float(i) / RATE
zap += (220.0 * pow(8.0, minf(t / 0.2, 1.0))) / RATE
whomp += lerpf(110.0, 55.0, minf(t / 0.4, 1.0)) / RATE
var buzz := 0.0
for h in [1, 3, 5]: # (the 7th would pass the Nyquist limit at the top of the sweep)
buzz += sin(TAU * zap * h) / h
var zap_env := minf(t / 0.01, 1.0) * (1.0 if t < 0.2 else exp(-(t - 0.2) * 8.0))
buf[i] = 0.7 * minf(t / 0.001, 1.0) * (white[i] - white_low[i]) * exp(-t * 30.0) + 0.5 * zap_env * buzz \
+ 0.5 * minf(t / 0.005, 1.0) * sin(TAU * whomp) * exp(-t * 6.0)
for k in 14: # the sparkles
var f := _rng.randf_range(2000.0, 6500.0)
var trem := _rng.randf_range(8.0, 20.0)
var at := _rng.randf_range(0.0, 0.25)
var amp := _rng.randf_range(0.04, 0.08)
for i in range(int(at * RATE), n):
var t := float(i) / RATE - at
var flicker := 0.5 + 0.5 * sin(TAU * trem * t)
buf[i] += amp * minf(t / 0.02, 1.0) * exp(-t * 2.6) * flicker * sin(TAU * f * t)
return _normalize(buf, 0.8)
## The UFO zooming off: a rush of air and a buzzy hum, both dropping in pitch as it goes (fast
## at first, then settling: a doppler fall) and fading away.
func _zoom(length: float) -> PackedFloat32Array:
var n := int(length * RATE)
var air := _band_sweep(n, 2600.0, 350.0, 0.15)
var buf := PackedFloat32Array()
buf.resize(n)
var phase := 0.0
for i in n:
var t := float(i) / RATE
var u := float(i) / n
phase += (260.0 + 690.0 * exp(-u * 4.0)) * (1.0 + 0.02 * sin(TAU * 7.0 * t)) / RATE
var tone := 0.0
for h in [1, 3, 5]:
tone += sin(TAU * phase * h) / h
var env := minf(u / 0.03, 1.0) * pow(1.0 - u, 1.6)
buf[i] = env * (0.5 * tone + 0.8 * air[i])
return _normalize(buf, 0.75)
## A car door slamming: the latch's click (and a second as it catches), then a dull thunk: a low
## thump, a few damped, out-of-tune panel tones, and a puff of low noise.
func _door(length: float) -> PackedFloat32Array:
var n := int(length * RATE)
var click := _noise_lowpass(n, 9000.0)
var click_low := _noise_lowpass(n, 3000.0)
var thud := _noise_lowpass(n, 400.0)
var buf := PackedFloat32Array()
buf.resize(n)
var hit := 0.006 # the thunk starts just after the first click
var panel := [[143.0, 14.0, 0.5], [231.0, 18.0, 0.35], [389.0, 24.0, 0.22], [612.0, 30.0, 0.14], [980.0, 40.0, 0.08]]
var phase := 0.0
for i in n:
var t := float(i) / RATE
var s := 0.35 * minf(t / 0.0005, 1.0) * (click[i] - click_low[i]) * exp(-t / 0.0015)
if t > 0.035:
s += 0.2 * (click[i] - click_low[i]) * exp(-(t - 0.035) / 0.0012)
if t >= hit:
var th := t - hit
phase += lerpf(85.0, 62.0, minf(th / 0.15, 1.0)) / RATE
var attack := minf(th / 0.002, 1.0)
s += attack * sin(TAU * phase) * exp(-th * 16.0)
for p: Array in panel:
s += attack * float(p[2]) * sin(TAU * float(p[0]) * th) * exp(-th * float(p[1]))
s += 0.6 * attack * thud[i] * exp(-th * 25.0)
buf[i] = s
return _normalize(buf, 0.85)
## White noise through a resonant band whose center glides from f0 to f1 (q: lower is narrower).
func _band_sweep(n: int, f0: float, f1: float, q: float) -> PackedFloat32Array:
var buf := PackedFloat32Array()
buf.resize(n)
var low := 0.0
var band := 0.0
for i in n:
var u := float(i) / n
var w := TAU * f0 * pow(f1 / f0, u) / RATE
var high := _rng.randf_range(-1.0, 1.0) - low - q * band
band += w * high
low += w * band
buf[i] = band
return _normalize(buf, 1.0)
func _horn() -> PackedFloat32Array:
var n := int(0.9 * RATE)
var buf := PackedFloat32Array()