Files
gig-line/Tools/review/hero_compare.py
T
zwitschi 4d27109668 refactor(tools): group the sixty scripts by what they talk to
One directory with sixty scripts stopped being navigable, and the grouping is also the sandbox boundary:

  Tools/unreal/    commandlets and the two map builders, with ue_common.py and ue_placement.py as the
                   shared imports (they need the engine)
  Tools/blender/   builders, exporters, the FBX preset, the MPFB character pipeline, blender_screenshots
                   (they need the Blender Flatpak)
  Tools/review/    the visual loop: render_screenshots.sh, judge_screenshot.py, hero_compare.py,
                   build_comparison_md.py, e2e_asset_check.py, hero_iterate.sh, visual_loop.py,
                   visual_targets.json
  Tools/gen/       image and texture generation: the ComfyUI driver, deterministic texture writers,
                   reference fetching
  Tools/input/     OS-level input injection
  root             _common.py, check-lfs.sh, addon_compat_probe.py, sibling_asset_audit.py, tests/

Every moved script now resolves the repository root as ../.. and puts the tools root plus its siblings on
sys.path, so 'import ue_common' still works from unreal/. The test suite bootstrap does the same for the five
folders. render_screenshots.sh takes the folder as a third argument to run_cmdlet, and the e2e driver,
hero_iterate.sh and the comparison generator were repointed.

51 README rows now link to their new location, the README gains a Layout section naming each folder's
sandbox, and the architecture notes and Blender README follow the moves.

Verified: 108 tests pass, prettier is clean, judge_screenshot.py and hero_compare.py run from their new
homes, and the e2e run was aborted mid-way (it had been rebuilding an empty DemoMap for 15 minutes) and is
being rerun against the new layout.
2026-11-10 12:40:30 +01:00

57 lines
1.8 KiB
Python

"""Build a side-by-side plate from a reference photograph and a rendered capture.
python3 Tools/review/hero_compare.py \
--reference Art/reference/hero-masonic/02-masonictemple01.jpg \
--render Screenshots/review/review-hero-facade-front.png \
--out Screenshots/review/hero-compare-front.png
Both halves are scaled to the same height and labelled, so the two can be read at a glance instead of
flipping between files. Reference photography is git-ignored and never committed; only the plate is.
Result: the plate path on stdout.
"""
import argparse
import os
from PIL import Image, ImageDraw
LABEL_H = 56
TARGET_H = 900
def load_scaled(path, height):
image = Image.open(path).convert("RGB")
width = int(image.width * height / image.height)
return image.resize((width, height), Image.LANCZOS)
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--reference", required=True)
parser.add_argument("--render", required=True)
parser.add_argument("--out", required=True)
parser.add_argument("--left-label", default="reference")
parser.add_argument("--right-label", default="rendered")
args = parser.parse_args()
left = load_scaled(args.reference, TARGET_H)
right = load_scaled(args.render, TARGET_H)
gap = 16
width = left.width + right.width + gap * 3
plate = Image.new("RGB", (width, TARGET_H + LABEL_H + gap * 2), (24, 24, 26))
plate.paste(left, (gap, LABEL_H + gap))
plate.paste(right, (gap * 2 + left.width, LABEL_H + gap))
draw = ImageDraw.Draw(plate)
draw.text((gap, 18), args.left_label, fill=(235, 235, 235))
draw.text((gap * 2 + left.width, 18), args.right_label, fill=(235, 235, 235))
os.makedirs(os.path.dirname(os.path.abspath(args.out)), exist_ok=True)
plate.save(args.out)
print(args.out)
main()