Grass Cutters Together: the project as of moon-sweepers f3666f0

A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NiemandKG
2026-11-06 18:44:40 +06:00
parent 0f0467cd0c
commit d1c3761e58
4190 changed files with 270757 additions and 1 deletions

View File

@ -0,0 +1,21 @@
{
"voice": "fgDJOgmENIR82PueQrVs",
"lines": {
"asst_hello": "[deadpan] Hi. I'm the Director's assistant. I'll be in your ear the whole time. [pause] He shouts. I explain.",
"asst_tools": "Your hands are empty. Walk to the supply wall on the west side of the deck and take the nail scissors. Press E.",
"asst_mow": "Hop down to the meadow, space at the railing. Then hold left click and sweep the blade over the grass. [deadpan] Every blade counts. Apparently.",
"asst_full": "Your container's full. Press E at the depot to hand it all in. Or Q to tie a bundle you can carry and throw.",
"asst_spend": "You've got cash. Better tools at the supply wall, upgrades at the console. Mowers come from a garage. [pause] Build one with the hammer.",
"asst_nocash": "[sighs] Not enough money. Mow more.",
"asst_drive": "W A S D to drive. Shift to boost. R for the chase view. E to hop off.",
"asst_hopper": "That machine's hopper is full. Unload it at the base yard or a garage pad.",
"asst_rain": "Rain's coming. The solar panels will give less for a while.",
"asst_acid": "[concerned] Acid rain. It burns patches of the meadow. That grass is gone, and it pays nothing.",
"asst_wind": "The wind is picking up. Keep an eye out for twisters.",
"asst_storm": "Thunderstorm. Dark skies, weak sun, and twisters about. [pause] Stay sharp.",
"asst_meteors": "[softly] Meteor shower tonight. Look up. [pause] It's actually pretty.",
"asst_twister": "[alarmed] Twister incoming! It rips up the grass in its path and it will throw you around!",
"asst_thrown": "[deadpan] You got thrown by a twister. [pause] Noted.",
"asst_ufo": "[nervous] Something is coming down out of the sky. [pause] I'm sure it's fine."
}
}

View File

@ -0,0 +1,186 @@
"""Cuts the G.R.A.S.S.A. director portrait (a 3D-ish render on black) into South Park style layers:
the body with the lower jaw, the upper head that flaps up when he talks (the moustache rides on it), and the dark mouth.
Usage: python cut_layers.py <portrait.png> <out_dir>"""
import sys, os, json
import numpy as np
from PIL import Image, ImageDraw, ImageFilter
from scipy import ndimage
src, out = sys.argv[1], sys.argv[2]
os.makedirs(out, exist_ok=True)
im = Image.open(src).convert("RGB")
a = np.asarray(im).astype(np.float32)
H, W = a.shape[:2]
mx = a.max(2)
# background: flood the near-black from the borders
lab, _ = ndimage.label(mx <= 10)
edge = set(np.unique(np.concatenate([lab[0], lab[-1], lab[:, 0], lab[:, -1]]))) - {0}
bg = np.isin(lab, list(edge))
fg = Image.fromarray(np.where(bg, 0, 255).astype(np.uint8), "L").filter(ImageFilter.MinFilter(3)).filter(ImageFilter.GaussianBlur(0.8))
alpha = np.asarray(fg).astype(np.float32)
CUT = 528 # straight across the head, just under the middle of the moustache
HEAD_TOP, CHIN = 0, 600
# the head's span at the cut
row = alpha[CUT] > 128
xs = np.where(row[150:914])[0] + 150
# the head is the run that contains the face middle
mid = 520
left = mid
while left > 0 and alpha[CUT, left - 1] > 128: left -= 1
right = mid
while right < W - 1 and alpha[CUT, right + 1] > 128: right += 1
# moustache: grey, unsaturated, in the box under the nose
sat = a.max(2) - a.min(2)
box = np.zeros_like(bg)
box[455:575, 380:665] = True
must = box & (sat < 34) & (mx > 55) & (mx < 200)
mimg = Image.fromarray((must * 255).astype(np.uint8), "L").filter(ImageFilter.MaxFilter(5)).filter(ImageFilter.MinFilter(5)).filter(ImageFilter.MaxFilter(3))
must = np.asarray(mimg) > 128
# the upper head: everything of the figure above the cut, between the ears; plus the moustache wherever it hangs
yy, xx = np.mgrid[0:H, 0:W]
head = (yy < CUT) & (alpha > 0)
# the shoulders reach up beside the head? they don't above the cut, but keep the collar out
head |= must
head_alpha = np.where(head, alpha, 0)
# soften the cut edge by one pixel so it doesn't alias
body_alpha = np.where(head & ~((yy >= CUT) & ~must), 0, alpha)
body_alpha = np.where(must & (yy >= CUT - 2), alpha, body_alpha) # placeholder, refilled below
# the skin under the hanging moustache: interpolate each row from the cheeks either side
body = a.copy()
for y in range(CUT - 2, 575):
m = must[y]
if not m.any(): continue
x = 380
while x < 665:
if m[x]:
x0 = x
while x < 665 and m[x]: x += 1
x1 = x
l = body[y, max(0, x0 - 3)]
r = body[y, min(W - 1, x1 + 2)]
for k in range(x0, x1):
t = (k - x0 + 0.5) / max(1, x1 - x0)
body[y, k] = l * (1 - t) + r * t
else:
x += 1
body_alpha = alpha.copy()
body_alpha[yy < CUT] = 0
# crop: the bust, 3:4
X0, X1, Y0 = 150, 914, 0
Y1 = Y0 + int((X1 - X0) * 4 / 3)
def save(rgb, al, name):
rgba = np.dstack([np.clip(rgb, 0, 255), np.clip(al, 0, 255)]).astype(np.uint8)[Y0:Y1, X0:X1]
Image.fromarray(rgba, "RGBA").save(os.path.join(out, name))
# the arms: the render stands in a T-pose, so each arm comes off at the shoulder and is hung down at his side, drawn
# behind the coat (the game swings it about the shoulder); the coat's shoulders are cut on a slope where the arms were
AY0, AY1 = 572, 752 # the rows the outstretched arms cover
LCUT, RCUT = 300, 754 # where the sleeves meet the coat's sides
LIN, RIN = 390, 664 # how far in the arm layers reach (hidden behind the coat once hung)
PIVOTS = ((338, 648), (716, 648))
HANG = 74 # degrees down from straight out
band = (yy >= AY0) & (yy <= AY1)
neck = yy < 645
arm_masks = (band & (xx < LIN) & ~(neck & (xx >= LCUT)), band & (xx > RIN) & ~(neck & (xx <= RCUT)))
off = band & ((xx < LCUT) | (xx > RCUT))
slope = band & (yy < 640) & ((xx < LCUT + (640 - yy) * 0.9) | (xx > RCUT - (640 - yy) * 0.9))
off |= slope & ~((yy < 618) & (xx > LCUT + 60) & (xx < RCUT - 60))
keep = 1.0 - ndimage.gaussian_filter(off.astype(np.float32), 0.8)
body_alpha = body_alpha * np.where(off | (keep < 0.999), keep, 1.0)
for name, mask, piv, sgn in (("T_Dir_ArmL.png", arm_masks[0], PIVOTS[0], 1), ("T_Dir_ArmR.png", arm_masks[1], PIVOTS[1], -1)):
rgba = np.dstack([np.clip(a, 0, 255), np.where(mask, alpha, 0)]).astype(np.uint8)
arm = Image.fromarray(rgba, "RGBA").rotate(sgn * HANG, center=piv, resample=Image.BICUBIC)
arm.crop((X0, Y0, X1, Y1)).save(os.path.join(out, name))
print(name, "shoulder", ((piv[0] - X0) / (X1 - X0), (piv[1] - Y0) / (Y1 - Y0)))
save(body, body_alpha, "T_Dir_Body.png")
# the mouth: nothing but a dark void, a little rounded
mw, mh = 512, 128
m = Image.new("RGBA", (mw, mh), (0, 0, 0, 0))
d = ImageDraw.Draw(m)
d.rounded_rectangle([0, 0, mw - 1, mh - 1], radius=60, fill=(10, 6, 8, 255))
m.save(os.path.join(out, "T_Dir_Mouth.png"))
# the eyes: the pupils come off the head (the whites filled in behind them) and are drawn on their own so they can look
# about; a lids layer (everything round the whites) goes back over them, so a pupil never shows on skin or glasses
eyes = []
head_rgb = a.copy()
lids_alpha = np.zeros_like(alpha)
for (x0, x1) in ((360, 520), (535, 700)):
y0, y1 = 325, 445
sub = a[y0:y1, x0:x1]
smx, smn = sub.max(2), sub.min(2)
pupil = ndimage.binary_fill_holes(smx < 60)
lab, n = ndimage.label(pupil)
if n > 1:
sizes = ndimage.sum(pupil, lab, range(1, n + 1))
pupil = lab == (1 + int(np.argmax(sizes)))
pupil = ndimage.binary_fill_holes(pupil)
white = (smn > 160) & ((smx - smn) < 50)
sclera = ndimage.binary_closing(white | pupil, iterations=3)
sclera = ndimage.binary_fill_holes(sclera)
lab, n = ndimage.label(sclera)
if n > 1:
sizes = ndimage.sum(sclera, lab, range(1, n + 1))
sclera = lab == (1 + int(np.argmax(sizes)))
ys, xs = np.where(pupil)
cy, cx = ys.mean(), xs.mean()
r = max(xs.max() - xs.min(), ys.max() - ys.min()) / 2 + 1
# the whites behind the pupil, row by row from the white either side
fill = ndimage.binary_dilation(pupil, iterations=3) & sclera
med = np.median(sub[white & ~fill], axis=0)
keep = sclera & ~fill
for yy_ in range(sub.shape[0]):
row = fill[yy_]
if not row.any(): continue
xs_ = np.where(row)[0]
l_, r_ = xs_.min(), xs_.max()
# the nearest white either side on this row, so the shade under the lid carries across
lk = np.where(keep[yy_, :l_])[0]
rk = np.where(keep[yy_, r_ + 1:])[0]
cl = sub[yy_, lk[-1]].astype(float) if len(lk) else med
cr = sub[yy_, r_ + 1 + rk[0]].astype(float) if len(rk) else med
for xx_ in xs_:
t_ = (xx_ - l_ + 0.5) / max(1, r_ - l_ + 1)
head_rgb[y0 + yy_, x0 + xx_] = cl * (1 - t_) + cr * t_
# soften the patch so no edge shows
patch = head_rgb[y0:y1, x0:x1].copy()
blur = np.stack([ndimage.gaussian_filter(patch[..., c], 2.0) for c in range(3)], -1)
soft = ndimage.gaussian_filter(ndimage.binary_dilation(fill, iterations=2).astype(float), 1.5)
head_rgb[y0:y1, x0:x1] = patch * (1 - soft[..., None]) + blur * soft[..., None]
region = np.zeros_like(alpha, dtype=bool)
region[y0:y1, x0:x1] = True
sc_full = np.zeros_like(region)
sc_full[y0:y1, x0:x1] = sclera
lids_alpha[region & ~sc_full] = alpha[region & ~sc_full]
sy, sx = np.where(sclera)
eyes.append(dict(cx=x0 + cx, cy=y0 + cy, r=r, box=[x0 + sx.min(), y0 + sy.min(), x0 + sx.max(), y0 + sy.max()]))
print("eye", eyes[-1])
# the head without its pupils, and the lids over them
save(head_rgb, head_alpha, "T_Dir_Head.png")
save(head_rgb, lids_alpha, "T_Dir_Lids.png")
# one pupil: a dark ball with its glint up and to the left, like the render
P = 128
pi = Image.new("RGBA", (P, P), (0, 0, 0, 0))
d = ImageDraw.Draw(pi)
d.ellipse([2, 2, P - 3, P - 3], fill=(22, 18, 22, 255))
d.ellipse([10, 8, P - 18, P - 20], fill=(34, 30, 34, 255))
d.ellipse([int(P * 0.22), int(P * 0.16), int(P * 0.42), int(P * 0.36)], fill=(250, 250, 250, 255))
pi = pi.filter(ImageFilter.SMOOTH)
pi.save(os.path.join(out, "T_Dir_Pupil.png"))
# skin for the blinking lids
lid_colour = np.median(a[322:336, 420:470].reshape(-1, 3), axis=0)
cw, ch = X1 - X0, Y1 - Y0
meta = dict(width=cw, height=ch, cut=(CUT - Y0) / ch, mouthLeft=(left + 22 - X0) / cw, mouthRight=(right - 22 - X0) / cw,
eyes=[dict(x=(e["cx"] - X0) / cw, y=(e["cy"] - Y0) / ch, r=e["r"] / cw,
box=[(e["box"][0] - X0) / cw, (e["box"][1] - Y0) / ch, (e["box"][2] - X0) / cw, (e["box"][3] - Y0) / ch]) for e in eyes],
lid=[round(float(c) / 255, 3) for c in lid_colour])
json.dump(meta, open(os.path.join(out, "director.json"), "w"), indent=1)
print(meta)

View File

@ -0,0 +1,36 @@
{
"width": 764,
"height": 1018,
"cut": 0.518664047151277,
"mouthLeft": 0.2709424083769634,
"mouthRight": 0.7212041884816754,
"eyes": [
{
"x": 0.39164805700159083,
"y": 0.3673803071110875,
"r": 0.04581151832460733,
"box": [
0.29581151832460734,
0.33988212180746563,
0.4568062827225131,
0.4106090373280943
]
},
{
"x": 0.6126170328776531,
"y": 0.36734803457217724,
"r": 0.04581151832460733,
"box": [
0.5445026178010471,
0.33988212180746563,
0.7028795811518325,
0.41159135559921417
]
}
],
"lid": [
0.996,
0.682,
0.447
]
}

View File

@ -0,0 +1,87 @@
"""Raw ElevenLabs takes -> game clips in Assets/Audio: the director's lines (a touch of phone colour, trimmed, levelled)
and the intro/call/critter sounds (trimmed, levelled, faded). Run after eleven.py; the raw folder is git-ignored."""
import os, wave
import numpy as np
from scipy import signal
HERE = os.path.dirname(os.path.abspath(__file__))
RAW = os.path.join(HERE, "..", "audio", "eleven_raw")
OUT = os.path.join(HERE, "..", "..", "Assets", "Audio")
def load(name):
w = wave.open(os.path.join(RAW, name))
ch, r = w.getnchannels(), w.getframerate()
a = np.frombuffer(w.readframes(w.getnframes()), np.int16).astype(np.float64) / 32768
if ch == 2: a = a.reshape(-1, 2).mean(1)
return a, r
def save(name, a, r):
a = np.clip(a, -1, 1)
with wave.open(os.path.join(OUT, name + ".wav"), "wb") as w:
w.setnchannels(1); w.setsampwidth(2); w.setframerate(r)
w.writeframes((a * 32767).astype(np.int16).tobytes())
print(name, f"{len(a) / r:.2f}s")
def trim(a, r, floor=0.006, pad=0.06):
win = max(1, int(r * 0.02))
e = np.sqrt(np.convolve(a * a, np.ones(win) / win, "same"))
idx = np.where(e > floor)[0]
if not len(idx): return a
s, t = max(0, idx[0] - int(pad * r)), min(len(a), idx[-1] + int(pad * r * 3))
return a[s:t]
def fade(a, r, fin=0.005, fout=0.08):
n1, n2 = int(fin * r), int(fout * r)
a = a.copy()
if n1: a[:n1] *= np.linspace(0, 1, n1)
if n2: a[-n2:] *= np.linspace(1, 0, n2)
return a
def level(a, peak=0.92):
return a * (peak / max(1e-6, np.abs(a).max()))
VOICE_DB = -15.0
def speech(a, r):
"""Every line, the Director's and the assistant's, at one loudness: the RMS of its voiced 50 ms frames brought down
to VOICE_DB (never up, so nothing clips). The game plays them as they are, under the Voices slider."""
hop = r // 20
k = len(a) // hop
if k == 0: return a
e = np.sqrt((a[:k * hop].reshape(k, hop) ** 2).mean(1))
e = e[e > 10 ** (-50 / 20)]
if not len(e): return a
db = 20 * np.log10(np.sqrt((e ** 2).mean()))
return a * min(1.0, 10 ** ((VOICE_DB - db) / 20))
VOICE = {"dir_intro": "dir_intro_1.wav"}
for f in sorted(os.listdir(RAW)):
if not f.startswith("dir_") or not f.endswith("_0.wav"): continue
name = f[:-6]
if name == "dir_intro": continue
VOICE.setdefault(name, f)
for name, f in VOICE.items():
a, r = load(f)
# the call comes through a phone: roll off the boom and the air, not a tin-can band
b, c = signal.butter(2, [160 / (r / 2), 7000 / (r / 2)], "band")
a = signal.filtfilt(b, c, a)
# gentle squash so the shouting doesn't clip and the mutters still carry
a = np.tanh(a * 1.6) / np.tanh(1.6)
save(name, speech(fade(level(trim(a, r)), r, 0.01, 0.12), r), r)
# the assistant, in your ear over the headset: a little narrower than the Director's phone, and kept even
for f in sorted(os.listdir(RAW)):
if not f.startswith("asst_") or not f.endswith("_0.wav"): continue
a, r = load(f)
b, c = signal.butter(2, [220 / (r / 2), 6500 / (r / 2)], "band")
a = signal.filtfilt(b, c, a)
a = np.tanh(a * 2.0) / np.tanh(2.0)
save(f[:-6], speech(fade(level(trim(a, r), 0.85), r, 0.01, 0.1), r), r)
SFX = {"phone_ring": ("phone_ring_0.wav", 0.8), "call_connect": ("call_connect_0.wav", 0.7), "call_hangup": ("call_hangup_0.wav", 0.7),
"intro_echo": ("intro_echo_0.wav", 0.85), "cut_whoosh_1": ("cut_whoosh_0.wav", 0.9), "cut_whoosh_2": ("cut_whoosh_1.wav", 0.9),
"cut_return": ("cut_return_0.wav", 0.95), "space_rumble": ("space_rumble_0.wav", 0.85),
"bug_scatter_1": ("bug_scatter_0.wav", 0.6), "bug_scatter_2": ("bug_scatter_1.wav", 0.6)}
for name, (f, pk) in SFX.items():
a, r = load(f)
save(name, fade(level(trim(a, r, 0.003), pk), r, 0.004, 0.25), r)

16
Tools/director/lines.json Normal file
View File

@ -0,0 +1,16 @@
{
"voice": "1BfrkuYXmEwp8AWqSLWk",
"lines": {
"dir_intro": "[angry] Listen up, you incompetent idiots! [shouting] EARTH IS OUT OF GRASS! NO GRASS! NOT A SINGLE DAMN BLADE! [frustrated] And you morons are standing around doing NOTHING?! [stern] That planet is covered in grass. And Earth needs EVERY. SINGLE. BLADE. [shouting] I want it CUT! I want it PACKED! And I want it SHIPPED BACK TO EARTH! [furious] I don't care if you have to use nail scissors! [shouting] NOW GET OUT THERE AND MOW THAT GODDAMN PLANET!",
"dir_intro_tag": "[deadpan] This is G.R.A.S.S.A. We take grass very seriously.",
"dir_m0001": "[suspicious] Wait. Is that... progress? [sniffs] Zero point zero zero one percent. [grudging] Earth thanks you. Barely. [shouting] NOW DO THE OTHER NINETY-NINE POINT NINE NINE NINE!",
"dir_m1": "[excited] ONE PERCENT! [clears throat] [stern] I mean... one percent. Acceptable. My grandmother mowed faster, and she used her teeth. [shouting] KEEP CUTTING!",
"dir_m50": "[emotional] Fifty percent. Half a planet. [sniffles] Somewhere on Earth, a cow just smiled for the first time in ten years. [shouting] DON'T YOU DARE STOP NOW!",
"dir_m100": "[voice breaking] One hundred percent. [pause] You did it. You magnificent idiots actually did it. [sobbing] Earth has grass again! [pause] [stern] Now. About the second planet. [pause] [deadpan] I'm kidding. [pause] Unless?",
"dir_machine": "[impressed] A machine! Finally, somebody down there with a brain! [shouting] Now put it to work before I bill you for the fuel!",
"dir_combine": "[shouting] A COMBINE HARVESTER?! [laughs maniacally] NOW we're talking! Earth's lawns will be green by Christmas!",
"dir_drones": "[suspicious] Drones? You bought DRONES? [pause] [grudging] Fine. But if they start a robot uprising, it's coming out of YOUR pay.",
"dir_belts": "[delighted] Conveyor belts! Grass that moves BY ITSELF! [whispers] This is what peak civilization looks like.",
"dir_ufo": "[panicked] Was that a UFO?! [whispers] Listen to me. Do NOT let them take the grass. [shouting] THAT GRASS BELONGS TO EARTH!"
}
}

View File

@ -0,0 +1,76 @@
"""The Director's and the assistant's talking loops (ArtSource/Director/video/*_src.webm, 768x1168, 24 fps, figure on black)
-> Assets/StreamingAssets/Talk/<name>.webm, VP8 with alpha, which the game's VideoPlayer plays behind the call and the hint.
The black is cut away by flooding in from the frame's edge over near-black pixels, so dark trousers and shoes inside the
figure's outline stay solid; the edge is softened by a pixel. Both are cut to head-to-hips (the user: no need to show
them full length), a bust that fills the phone and her small window like a video call.
python -I Tools/director/talk_videos.py all of them
python -I Tools/director/talk_videos.py boss_calm one
"""
import os, subprocess, sys
import numpy as np
from scipy import ndimage
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.normpath(os.path.join(HERE, "..", ".."))
SRC = os.path.join(ROOT, "ArtSource", "Director", "video")
OUT = os.path.join(ROOT, "Assets", "StreamingAssets", "Talk")
W, H = 768, 1168
# name: (crop height from the top, output width)
JOBS = {
"boss_calm": (780, 640), "boss_stern": (780, 640), "boss_angry": (780, 640),
"asst_happy": (780, 400), "asst_stern": (780, 400), "asst_fed": (780, 400),
}
FLOOD, SOLID = 9, 24 # the background is at most this bright; above SOLID a pixel at the edge is fully kept
def frames(path):
p = subprocess.Popen(["ffmpeg", "-v", "error", "-i", path, "-f", "rawvideo", "-pix_fmt", "rgb24", "-"], stdout=subprocess.PIPE)
n = W * H * 3
while True:
b = p.stdout.read(n)
if len(b) < n: break
yield np.frombuffer(b, np.uint8).reshape(H, W, 3)
p.wait()
def key(rgb):
peak = rgb.max(axis=2)
dark = peak <= FLOOD
lab, _ = ndimage.label(dark)
edge = np.unique(np.concatenate([lab[0], lab[-1], lab[:, 0], lab[:, -1]]))
bg = np.isin(lab, edge[edge > 0])
# a soft rim: pixels just off the background fade by brightness, then a one-pixel blur
near = ndimage.binary_dilation(bg, iterations=2) & ~bg
a = np.where(bg, 0.0, 1.0)
a[near] = np.clip((peak[near] - FLOOD) / float(SOLID - FLOOD), 0.0, 1.0)
a = ndimage.uniform_filter(a, 3)
a[~ndimage.binary_dilation(bg, iterations=3)] = 1.0
return (a * 255).astype(np.uint8)
def run(name):
crop, ow = JOBS[name]
oh = int(round(crop * ow / W / 2)) * 2
src = os.path.join(SRC, name + "_src.webm")
os.makedirs(OUT, exist_ok=True)
dst = os.path.join(OUT, name + ".webm")
enc = subprocess.Popen(["ffmpeg", "-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "rgba", "-s", f"{W}x{crop}", "-r", "24", "-i", "-",
"-vf", f"scale={ow}:{oh}:flags=lanczos", "-c:v", "libvpx", "-pix_fmt", "yuva420p", "-auto-alt-ref", "0",
"-b:v", "1800k", "-crf", "10", "-deadline", "good", "-an", dst], stdin=subprocess.PIPE)
n = 0
for rgb in frames(src):
# keyed whole, then cut: the cut edge must not count as frame edge the black floods in from
rgba = np.dstack([rgb, key(rgb)])[:crop]
enc.stdin.write(rgba.tobytes())
n += 1
enc.stdin.close()
enc.wait()
print(name, n, "frames ->", dst, os.path.getsize(dst) // 1024, "KB")
if __name__ == "__main__":
for name in (sys.argv[1:] or list(JOBS)):
run(name)

62
Tools/director/wide_bg.py Normal file
View File

@ -0,0 +1,62 @@
"""A wide mission control behind the Director, for the trailer's close-ups, put together from the pieces of the upright
T_Dir_Bg: the wall in bands, the ceiling lamps, bunting and desks repeated, the banner, the monitor and the window placed
along it."""
import sys
import numpy as np
from PIL import Image, ImageFilter
src = Image.open(sys.argv[1]).convert("RGB")
out = sys.argv[2]
w, h = src.size
a = np.asarray(src).astype(np.float32)
W = int(h * 16 / 9)
# the wall in bands: each row's colour where nothing hangs (the strip between the banner and the window)
plain = a[:, 300:318].mean(axis=1)
canvas = np.repeat(plain[:, None, :], W, axis=1)
img = Image.fromarray(canvas.clip(0, 255).astype(np.uint8))
def crop(x0, y0, x1, y1):
return src.crop((x0, y0, x1, y1))
def tile(piece, y, step, start=0):
for x in range(start, W, step):
img.paste(piece, (x, y))
# ceiling lamps, bunting, desks
lamp = crop(360, 160, 452, 248)
tile(lamp, 160, 330, 30)
bunting = crop(320, 290, 720, 340)
tile(bunting, 290, 400)
desks = crop(0, 680, 700, 840)
tile(desks, 680, 700, 20)
floor = crop(0, 840, 700, h)
tile(floor, 840, 700, 20)
# the monitor, whole: its right half and that half mirrored
half = crop(0, 335, 118, 650)
mon = Image.new("RGB", (236, 315))
mon.paste(half.transpose(Image.FLIP_LEFT_RIGHT), (0, 0))
mon.paste(half, (118, 0))
banner = crop(128, 300, 312, 605)
window = crop(320, 330, 720, 662)
# the window's right frame, cut off in the strip: its left frame drawn again on the right
frame = crop(320, 330, 344, 662)
win = Image.new("RGB", (424, 332))
win.paste(window, (0, 0))
win.paste(frame, (400, 0))
cx = W // 2
img.paste(win, (cx - 212, 330))
img.paste(banner, (cx - 212 - 60 - 184, 300))
img.paste(banner, (cx + 212 + 60, 300))
img.paste(mon, (cx - 212 - 60 - 184 - 70 - 236, 335))
img.paste(mon, (cx + 212 + 60 + 184 + 70, 335))
img.paste(win, (cx - 212 - 60 - 184 - 70 - 236 - 70 - 424, 330))
img.paste(win.transpose(Image.FLIP_LEFT_RIGHT), (cx + 212 + 60 + 184 + 70 + 236 + 70, 330))
img = img.filter(ImageFilter.GaussianBlur(1.5))
img.save(out)
print(img.size)