#!/usr/bin/env python3 """Render the matched L18 review views as small readable JPEGs.""" import os import subprocess from pathlib import Path ROOT = Path(__file__).resolve().parents[4] CAPTURE = ROOT / "Standalone/bin/linux/VoxelForgeOffscreenCapture-linux18-clang" EXPORTS = ROOT / "Standalone/Research/WorldAssemblerM3/Linux18/exports" OUT = ROOT / "Standalone/Research/WorldAssemblerM3/Linux18/captures" LOGS = ROOT / "Saved/Linux" OUT.mkdir(parents=True, exist_ok=True) env = os.environ.copy() env["LP_NUM_THREADS"] = "12" env["XDG_CACHE_HOME"] = str(ROOT / "Saved/Linux/mesa-cache") views = [ ("floating-islands-flat-square-after", "floating-islands-flat-square.vfmesh", (-11.612444, -118.221237, -19.8452), 0, 0, True), ("floating-islands-flat-square-no-edges", "floating-islands-flat-square.vfmesh", (-11.612444, -118.221237, -19.8452), 0, 0, False), ("floating-islands-island-view-after", "floating-islands-island-view.vfmesh", (-22, -19, -22.8), 0, -4, True), ("floating-islands-ceiling-up", "floating-islands-island-view.vfmesh", (-22, -19, -22.8), 0, 80, True), ("surface-world-l1-spawn-after", "surface-world-l1-spawn.vfmesh", (0, -35, -487.94), 0, -22, False), ("surface-world-horizon-after", "surface-world-l1-spawn.vfmesh", (0, -35, -487.94), 0, 0, False), ] for name, scene_name, camera, yaw, pitch, tile_edges in views: scene = EXPORTS / scene_name png = LOGS / f"l18-{name}.png" jpg = OUT / f"{name}.jpg" render_log = LOGS / f"l18-{name}-render.log" convert_log = LOGS / f"l18-{name}-jpeg.log" command = [str(CAPTURE), str(scene), str(png), "--size=1600x900", "--shade=readable", f"--tile-edges={'on' if tile_edges else 'off'}", "--tile-edge-width-m=0.15", "--camera-m="+",".join(map(str, camera)), f"--yaw-deg={yaw}", f"--pitch-deg={pitch}"] with render_log.open("w", encoding="utf-8") as stream: subprocess.run(command, cwd=ROOT, env=env, stdout=stream, stderr=subprocess.STDOUT, check=True) ffmpeg = ["ffmpeg", "-nostdin", "-hide_banner", "-loglevel", "error", "-y", "-i", str(png), "-frames:v", "1", "-q:v", "4", str(jpg)] with convert_log.open("w", encoding="utf-8") as stream: subprocess.run(ffmpeg, cwd=ROOT, env=env, stdout=stream, stderr=subprocess.STDOUT, check=True) if jpg.stat().st_size > 300_000: raise SystemExit(f"{jpg.name} exceeds the 300 KB review limit") print(f"[Capture] {jpg.relative_to(ROOT)} bytes={jpg.stat().st_size} status=PASS")