Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
BK0: raea bake light --compare, and the bake's test set
shinyobjectz356dacd53fc8
diff --git a/Cargo.lock b/Cargo.lockindex 1d9b83ff..db646ea5 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -13871,6 +13871,19 @@ dependencies = ["serde_json",]+[[package]]+name = "raea-app-lightbake"+version = "0.1.0"+dependencies = [+ "image",+ "libc",+ "raea-io-home",+ "raea-light",+ "raea-runtime-bundle",+ "serde_json",+ "sha2 0.10.9",+]+[[package]]name = "raea-app-make"version = "0.1.0"@@ -14259,6 +14272,7 @@ dependencies = ["raea-app-game","raea-app-judge","raea-app-layers",+ "raea-app-lightbake","raea-app-make","raea-app-media","raea-app-notes",diff --git a/Cargo.toml b/Cargo.tomlindex 349f3777..ab541e86 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -199,6 +199,7 @@ members = ["runtime/scene2d","runtime/shared","apps/ask",+ "apps/lightbake","apps/double","apps/check","apps/check/cause",diff --git a/apps/lightbake/Cargo.toml b/apps/lightbake/Cargo.tomlnew file mode 100644index 00000000..39e9c3dc--- /dev/null+++ b/apps/lightbake/Cargo.toml@@ -0,0 +1,22 @@+[package]+name = "raea-app-lightbake"+version = "0.1.0"+edition = "2024"+license = "FSL-1.1-ALv2"+publish = false+description = "raea bake light: bounce light baked into lightmaps on raea's own ray tracer, and the bar it is held to against Cycles (docs/bake.feature)"++[dependencies]+# the frames' distance in stops, as raea light check measures it (LT1)+raea-light = { path = "../../engine/light" }+# the CLI's flag reader and result type+raea-runtime-bundle = { path = "../../runtime/bundle" }+# raea's own files (the test set, the Blender library scripts) and the home folder+raea-io-home = { path = "../../io/home" }+image = { version = "0.25", default-features = false, features = ["png"] }+serde_json = "1"+sha2 = "0.10"++[target.'cfg(unix)'.dependencies]+# wait4: a step's peak memory+libc = "0.2"diff --git a/apps/lightbake/sets.json b/apps/lightbake/sets.jsonnew file mode 100644index 00000000..acc8e795--- /dev/null+++ b/apps/lightbake/sets.json@@ -0,0 +1,13 @@+{+ "about": "the bake's test set (docs/bake.feature BK0), for `raea bake light --compare DIR`: each set's Cycles still (blender/look.py, given the composition's own sky, tone and lens) and Cycles bake (blender/lightbake.py), and raea's frames beside them",+ "sets": [+ { "name": "table", "dir": "bench/bake", "file": "table.tsx", "composition": "table", "cycles": ["table-cycles.tsx", "table-cycles"], "bar": true, "texels": 128,+ "look": ["--hdri", "media/kloofendal_48d_partly_cloudy_puresky_1k.hdr", "--strength", "0.25", "--rotation", "0.6", "--tone", "agx", "--exposure", "-0.8", "--focus", "2.5", "--fstop", "2.8", "--size", "1280x720"] },+ { "name": "cornell", "dir": "bench/bake", "file": "cornell.tsx", "composition": "cornell", "cycles": ["cornell-cycles.tsx", "cornell-cycles"], "texels": 128,+ "look": ["--tone", "agx", "--exposure", "0", "--size", "1280x720"] },+ { "name": "window", "dir": "bench/bake", "file": "window.tsx", "composition": "window", "cycles": ["window-cycles.tsx", "window-cycles"], "texels": 64,+ "look": ["--hdri", "media/kloofendal_48d_partly_cloudy_puresky_1k.hdr", "--strength", "0.25", "--rotation", "0.6", "--tone", "agx", "--exposure", "1.5", "--size", "1280x720"] },+ { "name": "atelier", "dir": "~/Studio/raea/projects/atelier", "file": "compositions/atelier.tsx", "composition": "set", "texels": 64, "reference": false,+ "why": "a test agent's project, still being built; its Manifold solids stop `raea blender open` (filed with raea bug), so its Blender bake runs through its own tools/bake.sh. It joins at BK5, with that bake as the comparison" }+ ]+}diff --git a/apps/lightbake/src/compare.rs b/apps/lightbake/src/compare.rsnew file mode 100644index 00000000..4a5218f0--- /dev/null+++ b/apps/lightbake/src/compare.rs@@ -0,0 +1,200 @@+//! One set against Cycles (docs/bake.feature BK0): its Cycles still (blender/look.py) and Cycles bake+//! (blender/lightbake.py), kept in DIR/NAME until the set or the samples change, then raea's frames beside them: the set+//! unbaked, the set with Cycles' maps, and the set with raea's own bake. A frame is measured against the Cycles still by+//! its RMSE (sRGB 0..1 over every pixel and channel, as docs/blender-research.md's table) and in stops (raea light+//! check's distance); a lightmap against Cycles' in stops, texel by texel on the same UVs (map_stops).++use crate::{key, library, run, Ran, Set};+use raea_runtime_bundle::R;+use serde_json::{json, Value};+use std::path::{Path, PathBuf};++/// The bar (BK0): the frame with raea's bake within this RMSE of the Cycles still on the table set (lightbake.py's gives+/// 0.040), no mesh's map off by more than a third of a stop on average, in under a quarter of lightbake.py's time.+pub const BAR_RMSE: f64 = 0.045;+pub const BAR_STOPS: f64 = 1.0 / 3.0;+pub const BAR_TIME: f64 = 0.25;++/// The set's Cycles references, made: the export, look.py's still at `samples` (OUT/cycles.png), lightbake.py's bake at+/// `samples` into the set's media/baked/NAME/, which the set's `cycles` composition reads.+fn reference(set: &Set, samples: u32, out: &Path, baked: &Path) -> R<Value> {+ let bl = out.join("bl");+ let _ = std::fs::remove_dir_all(&bl);+ let _ = std::fs::remove_dir_all(baked);+ let stem = Path::new(&set.file).file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_default();+ let open = run(&set.dir, &["blender".into(), "open".into(), set.file.clone(), "--no-window".into(), "-o".into(), format!("{}", bl.display())], &out.join("open.log"))?;+ let (blend, look) = (bl.join(format!("{stem}.blend")), bl.join("look.blend"));+ let mut a = vec!["blender".into(), "run".into(), format!("{}", library("look.py")?.display()), format!("{}", blend.display()), format!("{}", look.display())];+ a.extend(set.look.iter().cloned());+ a.extend(["--engine".into(), "cycles".into(), "--samples".into(), samples.to_string(), "--still".into(), format!("{}", out.join("cycles.png").display())]);+ let still = run(&set.dir, &a, &out.join("look.log"))?;+ let a = vec!["blender".into(), "run".into(), format!("{}", library("lightbake.py")?.display()), format!("{}", look.display()), format!("{}", baked.join("set.glb").display()), "--samples".into(), samples.to_string(), "--texels".into(), set.texels.to_string()];+ let bake = run(&set.dir, &a, &out.join("lightbake.log"))?;+ Ok(json!({ "export": open.json(), "still": still.json(), "lightbake": bake.json() }))+}++/// Frame 0 of `composition` in `file`, drawn by raea into OUT/LABEL/: the picture and what it cost.+fn frame(set: &Set, file: &str, composition: &str, out: &Path, label: &str) -> R<(PathBuf, Ran)> {+ let dir = out.join(label);+ let _ = std::fs::remove_dir_all(&dir);+ std::fs::create_dir_all(&dir).map_err(|e| e.to_string())?;+ let a = ["render", file, "--composition", composition, "--at", "0", "-o", &format!("{}/", dir.display())].map(String::from);+ let ran = run(&set.dir, &a, &out.join(format!("{label}.log")))?;+ Ok((dir.join("frame-00000.png"), ran))+}++fn round(x: f64) -> f64 {+ (x * 10000.0).round() / 10000.0+}++/// RMSE of two pictures the same size, sRGB 0..1 over every pixel and channel.+pub fn rmse(a: &Path, b: &Path) -> R<f64> {+ let load = |p: &Path| image::open(p).map(|i| i.to_rgb8()).map_err(|e| format!("{}: {e}", p.display()));+ let (a, b) = (load(a)?, load(b)?);+ if a.dimensions() != b.dimensions() {+ return Err(format!("sizes differ: {:?} against {:?}", a.dimensions(), b.dimensions()));+ }+ let sum: f64 = a.as_raw().iter().zip(b.as_raw()).map(|(x, y)| ((*x as f64 - *y as f64) / 255.0).powi(2)).sum();+ Ok((sum / a.as_raw().len().max(1) as f64).sqrt())+}++/// A raea frame against the Cycles still: RMSE, and the mean and worst tile in stops.+fn measure(got: &(PathBuf, Ran), cycles: &Path) -> R<Value> {+ let d = raea_light::metric::distance(&raea_light::metric::load(&got.0)?, &raea_light::metric::load(cycles)?)?;+ Ok(json!({ "rmse": round(rmse(&got.0, cycles)?), "mean_stops": round(d.mean as f64), "worst_stops": round(d.worst as f64), "render": got.1.json() }))+}++/// A lightmap against another on the same UVs, each scaled by its lightmap_exposure: over the texels both cover, the+/// mean distance in stops, the mean signed (brighter is positive), and the worst 8 x 8 tile's mean distance.+pub fn map_stops(a: &Path, a_exposure: f64, b: &Path, b_exposure: f64) -> R<Value> {+ let lum = |p: &Path, k: f64| -> R<(u32, u32, Vec<f64>)> {+ let i = image::open(p).map_err(|e| format!("{}: {e}", p.display()))?.to_rgb32f();+ Ok((i.width(), i.height(), i.pixels().map(|q| k * (0.2126 * q[0] as f64 + 0.7152 * q[1] as f64 + 0.0722 * q[2] as f64)).collect()))+ };+ let ((w, h, a), (bw, bh, b)) = (lum(a, a_exposure)?, lum(b, b_exposure)?);+ if (w, h) != (bw, bh) {+ return Err(format!("map sizes differ: {w}x{h} against {bw}x{bh}"));+ }+ let (mut sum, mut signed, mut n) = (0.0, 0.0, 0usize);+ let mut tiles = vec![(0.0, 0usize); w.div_ceil(8) as usize * h.div_ceil(8) as usize];+ for (i, (x, y)) in a.iter().zip(&b).enumerate() {+ if *x <= 0.0 || *y <= 0.0 {+ continue;+ }+ let st = (x / y).log2();+ (sum, signed, n) = (sum + st.abs(), signed + st, n + 1);+ let t = &mut tiles[(i / w as usize / 8) * w.div_ceil(8) as usize + (i % w as usize) / 8];+ *t = (t.0 + st.abs(), t.1 + 1);+ }+ let worst = tiles.iter().filter(|t| t.1 >= 32).map(|t| t.0 / t.1 as f64).fold(0.0, f64::max);+ let k = n.max(1) as f64;+ Ok(json!({ "texels": n, "mean_stops": round(sum / k), "bias_stops": round(signed / k), "worst_tile_stops": round(worst) }))+}++/// Whether a set's numbers meet the bar, and why not.+fn bar(r: &Value) -> Value {+ let f = &r["frames"]["raea-bake"];+ if f["made"] == json!(false) {+ return json!({ "met": false, "why": f["why"] });+ }+ let rmse = f["rmse"].as_f64().is_some_and(|x| x <= BAR_RMSE);+ let meshes = r["meshes"].as_array().is_some_and(|m| m.iter().all(|m| m["raea"]["mean_stops"].as_f64().is_some_and(|x| x <= BAR_STOPS)));+ let time = match (f["bake"]["seconds"].as_f64(), r["reference"]["lightbake"]["seconds"].as_f64()) {+ (Some(a), Some(b)) => a < b * BAR_TIME,+ _ => false,+ };+ json!({ "met": rmse && meshes && time, "rmse": rmse, "meshes": meshes, "time": time })+}++pub fn set(set: &Set, samples: u32, out: &Path, fresh: bool) -> R<Value> {+ std::fs::create_dir_all(out).map_err(|e| format!("{}: {e}", out.display()))?;+ let mut r = json!({ "name": set.name, "samples": samples });+ if let Err(why) = &set.reference {+ r["reference"] = json!({ "made": false, "why": why });+ return Ok(r);+ }+ let (baked, cycles, made) = (set.dir.join("media/baked").join(&set.name), out.join("cycles.png"), out.join("made.json"));+ let key = key(set, samples);+ let kept = std::fs::read_to_string(&made).ok().and_then(|t| serde_json::from_str::<Value>(&t).ok());+ r["reference"] = match kept.filter(|k| !fresh && k["key"] == json!(key) && cycles.is_file() && baked.join("set.lightmaps.json").is_file()) {+ Some(k) => {+ let mut v = k["reference"].clone();+ v["kept"] = json!(true);+ v+ }+ None => {+ let v = reference(set, samples, out, &baked)?;+ std::fs::write(&made, json!({ "key": key, "reference": v }).to_string()).map_err(|e| e.to_string())?;+ v+ }+ };+ r["frames"]["raea"] = measure(&frame(set, &set.file, &set.composition, out, "raea")?, &cycles)?;+ if let Some((file, comp)) = &set.cycles {+ r["frames"]["cycles-bake"] = measure(&frame(set, file, comp, out, "cycles-bake")?, &cycles)?;+ }+ // rask: BK5 raea's own bake of the set (<LightBake>): its frame against the Cycles still, its time and memory, and each mesh's map against Cycles' by map_stops on lightbake.py's UVs+ r["frames"]["raea-bake"] = json!({ "made": false, "why": "raea's bake isn't built yet (BK1-BK5)" });+ let maps: Value = std::fs::read_to_string(baked.join("set.lightmaps.json")).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default();+ r["meshes"] = json!(maps["meshes"].as_array().into_iter().flatten().map(|m| json!({ "mesh": m["mesh"], "size": m["size"], "cycles_exposure": m["lightmap_exposure"] })).collect::<Vec<_>>());+ if set.bar {+ r["bar"] = bar(&r);+ }+ Ok(r)+}++/// The table a person reads: a line a set and frame, then the Cycles bake's cost and the bar.+pub fn table(reports: &[Value]) -> String {+ let mut t = format!("{:<10} {:<12} {:>7} {:>7} {:>7}\n", "set", "frame", "rmse", "stops", "worst");+ for r in reports {+ let name = r["name"].as_str().unwrap_or("");+ if r["reference"]["made"] == json!(false) {+ t += &format!("{name:<10} (no reference: {})\n", r["reference"]["why"].as_str().unwrap_or(""));+ continue;+ }+ for (label, f) in r["frames"].as_object().into_iter().flatten() {+ let n = |k: &str| match f[k].as_f64() {+ Some(x) => format!("{x:.4}"),+ None => "-".into(),+ };+ let why = f["why"].as_str().map(|w| format!(" ({w})")).unwrap_or_default();+ t += &format!("{name:<10} {label:<12} {:>7} {:>7} {:>7}{why}\n", n("rmse"), n("mean_stops"), n("worst_stops"));+ }+ let (lb, st) = (&r["reference"]["lightbake"], &r["reference"]["still"]);+ t += &format!("{name:<10} Cycles at {} samples: lightbake.py {}s (peak {} MB) for {} meshes, the still {}s\n", r["samples"], lb["seconds"], lb["peak_mb"], r["meshes"].as_array().map_or(0, Vec::len), st["seconds"]);+ if let Some(b) = r.get("bar") {+ t += &format!("{name:<10} bar: {}\n", if b["met"] == json!(true) { "met".to_string() } else { format!("not met: {}", b["why"].as_str().unwrap_or("see report.json")) });+ }+ }+ t+}++#[cfg(test)]+mod tests {+ use super::*;++ fn png16(path: &Path, w: u32, h: u32, v: u16) {+ image::ImageBuffer::<image::Rgb<u16>, _>::from_pixel(w, h, image::Rgb([v, v, v])).save(path).unwrap();+ }++ #[test]+ fn a_map_twice_as_bright_is_one_stop_off_and_its_exposure_brings_it_back() {+ let d = std::env::temp_dir().join(format!("raea-lightbake-{}", std::process::id()));+ std::fs::create_dir_all(&d).unwrap();+ let (a, b) = (d.join("a.png"), d.join("b.png"));+ png16(&a, 16, 16, 40000);+ png16(&b, 16, 16, 20000);+ let off = map_stops(&a, 1.0, &b, 1.0).unwrap();+ assert_eq!((off["mean_stops"].as_f64(), off["bias_stops"].as_f64(), off["texels"].as_u64()), (Some(1.0), Some(1.0), Some(256)));+ assert_eq!(map_stops(&a, 1.0, &b, 2.0).unwrap()["mean_stops"].as_f64(), Some(0.0));+ assert!(rmse(&a, &b).unwrap() > 0.3 && rmse(&a, &a).unwrap() == 0.0);+ let _ = std::fs::remove_dir_all(&d);+ }++ #[test]+ fn the_bar_is_unmet_until_raeas_bake_exists() {+ let r = json!({ "frames": { "raea-bake": { "made": false, "why": "not yet" } } });+ assert_eq!(bar(&r)["met"], json!(false));+ let r = json!({ "frames": { "raea-bake": { "rmse": 0.04, "bake": { "seconds": 4.0 } } }, "meshes": [{ "raea": { "mean_stops": 0.2 } }], "reference": { "lightbake": { "seconds": 20.0 } } });+ assert_eq!(bar(&r)["met"], json!(true));+ }+}diff --git a/apps/lightbake/src/lib.rs b/apps/lightbake/src/lib.rsnew file mode 100644index 00000000..834bd895--- /dev/null+++ b/apps/lightbake/src/lib.rs@@ -0,0 +1,158 @@+//! `raea bake light EDIT.tsx [--composition ID] [--samples N] [--compare DIR]` (docs/bake.feature): raea's own bake of a+//! composition's static parts (BK1-BK5), and the bar it is held to (BK0). `--compare DIR` runs the test set (sets.json)+//! through Cycles (blender/look.py's still and blender/lightbake.py's bake, both at --samples, 1024 by default) and+//! through raea, then writes DIR/report.json and a table: each frame's RMSE and stops against the Cycles still, each+//! mesh's lightmap against Cycles', and each bake's time and peak memory.+//!+//! A set in sets.json: { "name", "dir" (under raea's home, or ~/...), "file", "composition", "cycles": [file,+//! composition] (the set drawn with lightbake.py's maps), "look": [look.py's flags, the composition's own values],+//! "texels" (lightbake.py's texels a metre), "bar": true (the set the bar is read on), "reference": false and "why" (a+//! set whose references can't be made yet) }.++pub mod compare;++use raea_runtime_bundle::{flag, R};+use serde_json::{json, Value};+use sha2::{Digest, Sha256};+use std::path::{Path, PathBuf};++pub const USAGE: &str = "raea bake light EDIT.tsx [--composition ID] [--samples N] | raea bake light --compare DIR [--sets FILE] [--set NAME] [--samples N] [--fresh] (bounce light baked into lightmaps on raea's ray tracer; --compare measures the test set against Cycles' bake and still, docs/bake.feature)";++/// One set of the test set, as sets.json lists it.+pub struct Set {+ pub name: String,+ pub dir: PathBuf,+ pub file: String,+ pub composition: String,+ pub cycles: Option<(String, String)>,+ pub look: Vec<String>,+ pub texels: u32,+ pub bar: bool,+ pub reference: Result<(), String>,+}++fn home_path(p: &str) -> PathBuf {+ match (p.strip_prefix("~/"), raea_io_home::user_home()) {+ (Some(rest), Some(h)) => h.join(rest),+ _ if Path::new(p).is_absolute() => PathBuf::from(p),+ _ => raea_io_home::home().join(p),+ }+}++pub fn sets(path: &Path) -> R<Vec<Set>> {+ let text = std::fs::read_to_string(path).map_err(|e| format!("{}: {e}", path.display()))?;+ let v: Value = serde_json::from_str(&text).map_err(|e| format!("{}: {e}", path.display()))?;+ let list = v["sets"].as_array().ok_or(format!("{}: no \"sets\" list", path.display()))?;+ let strs = |x: &Value| x.as_array().map(|a| a.iter().filter_map(|s| s.as_str().map(String::from)).collect::<Vec<_>>()).unwrap_or_default();+ list.iter()+ .map(|s| {+ let text = |k: &str| match &s[k] {+ Value::String(v) => Ok(v.clone()),+ _ => Err(format!("{}: a set without \"{k}\"", path.display())),+ };+ let cycles = match strs(&s["cycles"]).as_slice() {+ [file, comp] => Some((file.clone(), comp.clone())),+ _ => None,+ };+ let reference = if s["reference"] == json!(false) { Err(s["why"].as_str().unwrap_or("not yet").to_string()) } else { Ok(()) };+ Ok(Set { name: text("name")?, dir: home_path(&text("dir")?), file: text("file")?, composition: text("composition")?, cycles, look: strs(&s["look"]), texels: s["texels"].as_u64().unwrap_or(128) as u32, bar: s["bar"] == json!(true), reference })+ })+ .collect()+}++/// What a step cost: its seconds, and its peak memory in MB where the OS reports it (a child's and its children's).+#[derive(Debug, Clone, Copy)]+pub struct Ran {+ pub seconds: f64,+ pub peak_mb: Option<u64>,+}++impl Ran {+ pub fn json(&self) -> Value {+ json!({ "seconds": (self.seconds * 10.0).round() / 10.0, "peak_mb": self.peak_mb })+ }+}++#[cfg(unix)]+fn wait(child: std::process::Child) -> R<(bool, Option<u64>)> {+ let (mut status, pid) = (0, child.id() as libc::pid_t);+ // SAFETY: rusage is plain data, zeroed is a valid value; wait4 reaps the child std spawned and never waited on+ let mut ru: libc::rusage = unsafe { std::mem::zeroed() };+ if unsafe { libc::wait4(pid, &mut status, 0, &mut ru) } < 0 {+ return Err(format!("waiting for {pid}: {}", std::io::Error::last_os_error()));+ }+ // ru_maxrss is bytes on macOS, kilobytes elsewhere+ let kb = if cfg!(target_os = "macos") { ru.ru_maxrss as u64 / 1024 } else { ru.ru_maxrss as u64 };+ Ok((libc::WIFEXITED(status) && libc::WEXITSTATUS(status) == 0, Some(kb / 1024)))+}++#[cfg(not(unix))]+fn wait(mut child: std::process::Child) -> R<(bool, Option<u64>)> {+ Ok((child.wait().map_err(|e| e.to_string())?.success(), None))+}++/// This raea with `args` in `dir`, its output into `log`: what it cost, or the log's last lines.+pub fn run(dir: &Path, args: &[String], log: &Path) -> R<Ran> {+ let exe = std::env::current_exe().map_err(|e| e.to_string())?;+ let out = std::fs::File::create(log).map_err(|e| format!("{}: {e}", log.display()))?;+ let err = out.try_clone().map_err(|e| e.to_string())?;+ let t = std::time::Instant::now();+ let child = std::process::Command::new(exe).current_dir(dir).args(args).stdout(out).stderr(err).spawn().map_err(|e| e.to_string())?;+ let (ok, peak_mb) = wait(child)?;+ let ran = Ran { seconds: t.elapsed().as_secs_f64(), peak_mb };+ if ok {+ return Ok(ran);+ }+ let text = std::fs::read_to_string(log).unwrap_or_default();+ let last: Vec<&str> = text.lines().filter(|l| !l.starts_with("Fra:") && l.chars().any(|c| !c.is_whitespace())).rev().take(4).collect();+ Err(format!("raea {} failed ({}): {}", args.first().map_or("", String::as_str), log.display(), last.into_iter().rev().collect::<Vec<_>>().join(" | ")))+}++/// A set's identity for its kept references: every .tsx in its folder and its parts/, the flags look.py and lightbake.py+/// get, and the samples.+pub fn key(s: &Set, samples: u32) -> String {+ let mut h = Sha256::new();+ for d in [s.dir.clone(), s.dir.join("parts")] {+ let mut fs: Vec<PathBuf> = std::fs::read_dir(&d).into_iter().flatten().flatten().map(|e| e.path()).filter(|p| p.extension().is_some_and(|x| x == "tsx")).collect();+ fs.sort();+ for f in fs {+ h.update(f.file_name().unwrap_or_default().as_encoded_bytes());+ h.update(std::fs::read(&f).unwrap_or_default());+ }+ }+ h.update(format!("{:?} {} {samples}", s.look, s.texels));+ h.finalize().iter().map(|b| format!("{b:02x}")).collect()+}++/// Where the Blender library scripts are (sdk/guides/craft/bevy/blender), with `name` there, or why not.+pub fn library(name: &str) -> R<PathBuf> {+ let p = raea_io_home::home().join("sdk/guides/craft/bevy/blender").join(name);+ if p.is_file() { Ok(p) } else { Err(format!("no {} (the Blender library script the Cycles reference is made with)", p.display())) }+}++pub fn cli(args: &[String]) -> R<String> {+ if args.get(1).map(String::as_str) != Some("light") {+ return Err(format!("usage: {USAGE}"));+ }+ let samples: u32 = flag(args, "--samples").map(|v| v.parse().map_err(|_| format!("--samples {v}: a count of samples a texel"))).transpose()?.unwrap_or(1024);+ let Some(out) = flag(args, "--compare").map(PathBuf::from) else {+ // rask: BK5 `raea bake light EDIT.tsx` bakes a composition's <LightBake> ahead of a render and says what it baked+ return Err("raea's own bake isn't built yet (docs/bake.feature BK1-BK5); `raea bake light --compare DIR` measures the test set against Cycles".into());+ };+ let list = sets(&flag(args, "--sets").map_or_else(|| raea_io_home::home().join("apps/lightbake/sets.json"), PathBuf::from))?;+ let only = flag(args, "--set");+ let fresh = args.iter().any(|a| a == "--fresh");+ std::fs::create_dir_all(&out).map_err(|e| format!("{}: {e}", out.display()))?;+ let mut reports = Vec::new();+ for s in list.iter().filter(|s| only.is_none() || only.as_deref() == Some(s.name.as_str())) {+ eprintln!("raea bake light: {} ...", s.name);+ reports.push(compare::set(s, samples, &out.join(&s.name), fresh)?);+ }+ if reports.is_empty() {+ return Err(format!("no set named {}", only.unwrap_or_default()));+ }+ let report = json!({ "samples": samples, "sets": reports });+ let path = out.join("report.json");+ std::fs::write(&path, serde_json::to_string_pretty(&report).unwrap_or_default()).map_err(|e| e.to_string())?;+ Ok(format!("{}raea bake light: wrote {}", compare::table(&reports), path.display()))+}diff --git a/bench/bake/baked.tsx b/bench/bake/baked.tsxnew file mode 100644index 00000000..160a798f--- /dev/null+++ b/bench/bake/baked.tsx@@ -0,0 +1,19 @@+// A set as blender/lightbake.py left it (docs/bake.feature BK0): one <Model> of its meshes, each with its Cycles+// lightmap and the exposure that puts the bake at raea's brightness, from the .lightmaps.json lightbake.py wrote. A+// mesh lightbake.py left unbaked (a metal) is drawn as raea draws it. `raea bake light --compare` makes media/baked/.+import { staticFile } from "raea";+import { Model } from "raea/3d";+import { Lightmap, StandardMaterial } from "raea/pbr";++export type BakeInfo = { meshes: { mesh: string; material: string[]; map: string; lightmap_exposure: number }[] };++export function Baked({ dir, info }: { dir: string; info: BakeInfo }) {+ return (+ <Model src={staticFile(`${dir}/set.glb`)}>+ {info.meshes.map((m) => (+ <Lightmap key={`l-${m.mesh}`} mesh={m.mesh} image={staticFile(`${dir}/lightmaps/${m.map.split("/").pop()}`)} />+ ))}+ {info.meshes.flatMap((m) => m.material.map((mat) => <StandardMaterial key={`m-${mat}`} material={mat} lightmap_exposure={m.lightmap_exposure} />))}+ </Model>+ );+}diff --git a/bench/bake/cornell-cycles.tsx b/bench/bake/cornell-cycles.tsxnew file mode 100644index 00000000..3ba1a6c0--- /dev/null+++ b/bench/bake/cornell-cycles.tsx@@ -0,0 +1,17 @@+// The cornell set with Cycles' bounce light baked into its lightmaps by blender/lightbake.py, any sun left live: what raea's+// own bake is measured against (docs/bake.feature BK0). `raea bake light --compare` makes media/baked/cornell/.+import { AbsoluteFill, Composition, registerRoot } from "raea";+import { Baked } from "./baked";+import { Look } from "./parts/cornell";+import info from "./media/baked/cornell/set.lightmaps.json";++function Shot() {+ return (+ <AbsoluteFill style={{ background: "#000000" }}>+ <Look />+ <Baked dir="baked/cornell" info={info} />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="cornell-cycles" component={Shot} width={1280} height={720} fps={30} durationInFrames={1} />);diff --git a/bench/bake/cornell.tsx b/bench/bake/cornell.tsxnew file mode 100644index 00000000..d0e4aa7f--- /dev/null+++ b/bench/bake/cornell.tsx@@ -0,0 +1,14 @@+// The cornell set drawn by raea with nothing baked: the "before" frame (docs/bake.feature BK0, apps/lightbake/sets.json).+import { AbsoluteFill, Composition, registerRoot } from "raea";+import { Look, Parts } from "./parts/cornell";++function Shot() {+ return (+ <AbsoluteFill style={{ background: "#000000" }}>+ <Look />+ <Parts />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="cornell" component={Shot} width={1280} height={720} fps={30} durationInFrames={1} />);diff --git a/bench/bake/media/.gitignore b/bench/bake/media/.gitignorenew file mode 100644index 00000000..44fd3967--- /dev/null+++ b/bench/bake/media/.gitignore@@ -0,0 +1 @@+baked/diff --git a/bench/bake/media/kloofendal_48d_partly_cloudy_puresky_1k.hdr b/bench/bake/media/kloofendal_48d_partly_cloudy_puresky_1k.hdrnew file mode 100644index 00000000..cb2eb465Binary files /dev/null and b/bench/bake/media/kloofendal_48d_partly_cloudy_puresky_1k.hdr differdiff --git a/bench/bake/media/kloofendal_48d_partly_cloudy_puresky_1k.hdr.json b/bench/bake/media/kloofendal_48d_partly_cloudy_puresky_1k.hdr.jsonnew file mode 100644index 00000000..d11c8e60--- /dev/null+++ b/bench/bake/media/kloofendal_48d_partly_cloudy_puresky_1k.hdr.json@@ -0,0 +1 @@+{"source":"https://polyhaven.com/a/kloofendal_48d_partly_cloudy_puresky","license":"CC0","credit":"Poly Haven"}diff --git a/bench/bake/parts/cornell.tsx b/bench/bake/parts/cornell.tsxnew file mode 100644index 00000000..a9821596--- /dev/null+++ b/bench/bake/parts/cornell.tsx@@ -0,0 +1,50 @@+// A Cornell box (docs/bake.feature BK0): white floor, ceiling and back, a red left wall and a green right one, two+// white blocks, lit only by an emissive panel in the ceiling. Nothing here is lit live: every bit of light on its+// walls is the panel's, directly or bounced, so it measures a bake's emissives and colour bleeding with no sun or sky.+import { LinearRgba } from "raea/color";+import { ToneMapping } from "raea/3d";+import { AmbientLight } from "raea/light";+import { StandardMaterial } from "raea/pbr";+import { Cuboid, Mesh3d } from "raea/mesh";+import { Quat, Transform } from "raea/transform";+import { Camera3d } from "raea/camera";++export function Look() {+ return (+ <>+ <Camera3d transform={Transform.fromXyz(0, 1, 3.4).lookingAt([0, 1, 0])} projection={{ Perspective: { fov: (40 * Math.PI) / 180 } }} />+ <AmbientLight brightness={0} />+ <ToneMapping mode="agx" exposure={0} />+ </>+ );+}++const WHITE = "#bdbdb6";+type Box = [string, [number, number, number], [number, number, number], string, number?];+// name, centre, half size, colour, turn about y; the walls 0.1 thick and overlapping at the corners, so no light leaks+const BOXES: Box[] = [+ ["floor", [0, -0.05, 0], [1.1, 0.05, 1.1], WHITE],+ ["ceiling", [0, 2.05, 0], [1.1, 0.05, 1.1], WHITE],+ ["back", [0, 1, -1.05], [1.1, 1.1, 0.05], WHITE],+ ["left", [-1.05, 1, 0], [0.05, 1.1, 1.1], "#a3261c"],+ ["right", [1.05, 1, 0], [0.05, 1.1, 1.1], "#2f8a2a"],+ ["tall", [-0.35, 0.6, -0.3], [0.3, 0.6, 0.3], WHITE, 0.3],+ ["short", [0.38, 0.3, 0.32], [0.3, 0.3, 0.3], WHITE, -0.3],+];++export function Parts() {+ return (+ <>+ {BOXES.map(([name, [x, y, z], half, color, turn]) => (+ <Mesh3d key={name} name={name} transform={Transform.fromXyz(x, y, z).withRotation(Quat.fromRotationY(turn ?? 0))}>+ <Cuboid half_size={half} />+ <StandardMaterial base_color={color} perceptual_roughness={1} />+ </Mesh3d>+ ))}+ <Mesh3d name="panel" transform={Transform.fromXyz(0, 1.995, 0)}>+ <Cuboid half_size={[0.25, 0.004, 0.25]} />+ <StandardMaterial base_color="#ffffff" emissive={new LinearRgba(4200, 3000, 1000, 1)} />+ </Mesh3d>+ </>+ );+}diff --git a/bench/bake/parts/table.tsx b/bench/bake/parts/table.tsxnew file mode 100644index 00000000..e1b6e2f3--- /dev/null+++ b/bench/bake/parts/table.tsx@@ -0,0 +1,65 @@+// The table set (docs/bake.feature BK0): sdk/guides/craft/bevy/realism.md's example, flat colours, where+// docs/blender-research.md measured 0.154 / 0.074 / 0.040 against Cycles. Look is everything the bake leaves live (the+// camera, sky, sun and finish); Parts is the static set a bake covers, every part named so its lightmap finds it.+import { staticFile } from "raea";+import { Environment, Sphere, ToneMapping, Bloom, Grade, AmbientOcclusion, Shadows, DepthOfField } from "raea/3d";+import { StandardMaterial } from "raea/pbr";+import { Cuboid, Cylinder, Mesh3d } from "raea/mesh";+import { DirectionalLight } from "raea/light";+import { Transform } from "raea/transform";+import { Camera3d } from "raea/camera";++// what look.py is given for the Cycles reference: these same values (apps/lightbake/sets.json)+export const SKY = "kloofendal_48d_partly_cloudy_puresky_1k.hdr";++export function Look() {+ return (+ <>+ <Camera3d transform={Transform.fromXyz(0.9, 1.35, 2.3).lookingAt([0, 0.85, 0])} projection={{ Perspective: { fov: (38 * Math.PI) / 180 } }}>+ <DepthOfField focal_distance={2.5} aperture_f_stops={2.8} />+ </Camera3d>+ <Environment src={staticFile(SKY)} intensity={0.25} rotation={0.6} background />+ <DirectionalLight transform={Transform.fromXyz(4, 5, 3).lookingAt([0, 0, 0])} illuminance={45000} color="#fff1e0" shadow_maps_enabled />+ <Shadows distance={8} firstCascade={3} mapSize={4096} />+ <AmbientOcclusion quality="high" />+ <ToneMapping mode="agx" exposure={-0.8} />+ <Bloom intensity={0.08} />+ <Grade saturation={1.05} vignette={{ intensity: 0.35, radius: 0.8, smoothness: 3 }} aberration={0.003} />+ </>+ );+}++const LEGS: [number, number][] = [[-0.74, -0.4], [0.74, -0.4], [-0.74, 0.4], [0.74, 0.4]];++export function Parts() {+ return (+ <>+ <Mesh3d name="floor" transform={Transform.fromXyz(0, -0.05, 0)}>+ <Cuboid half_size={[6, 0.05, 6]} />+ <StandardMaterial base_color="#9a958c" perceptual_roughness={1} />+ </Mesh3d>+ <Mesh3d name="wall" transform={Transform.fromXyz(0, 1.5, -1.6)}>+ <Cuboid half_size={[6, 1.5, 0.08]} />+ <StandardMaterial base_color="#9a958c" perceptual_roughness={1} />+ </Mesh3d>+ <Mesh3d name="top" transform={Transform.fromXyz(0, 0.74, 0)}>+ <Cuboid half_size={[0.8, 0.025, 0.45]} />+ <StandardMaterial base_color="#7a3e22" perceptual_roughness={0.45} />+ </Mesh3d>+ {LEGS.map(([x, z], i) => (+ <Mesh3d key={`leg${i}`} name={`leg${i}`} transform={Transform.fromXyz(x, 0.36, z)}>+ <Cuboid half_size={[0.03, 0.36, 0.03]} />+ <StandardMaterial base_color="#7a3e22" perceptual_roughness={0.55} />+ </Mesh3d>+ ))}+ <Mesh3d name="ball" transform={Transform.fromXyz(-0.35, 0.925, 0.05)}>+ <Sphere radius={0.16} />+ <StandardMaterial base_color="#ffffff" perceptual_roughness={0.06} metallic={1} />+ </Mesh3d>+ <Mesh3d name="vase" transform={Transform.fromXyz(0.3, 0.965, -0.1)}>+ <Cylinder radius={0.09} half_height={0.2} />+ <StandardMaterial base_color="#c9b9a3" perceptual_roughness={0.3} />+ </Mesh3d>+ </>+ );+}diff --git a/bench/bake/parts/window.tsx b/bench/bake/parts/window.tsxnew file mode 100644index 00000000..1f559c2f--- /dev/null+++ b/bench/bake/parts/window.tsx@@ -0,0 +1,57 @@+// A room lit through one window (docs/bake.feature BK0): a closed 4 x 3 x 5 m room, the window in its right wall, the+// sun through it in a patch on the floor and the sky through it, a sofa and a low table. Almost all of what the camera+// sees is bounce light, the case lightmaps exist for. The wall is four boxes around the opening, not a boolean.+import { staticFile } from "raea";+import { Environment, ToneMapping, AmbientOcclusion, Shadows } from "raea/3d";+import { StandardMaterial } from "raea/pbr";+import { Cuboid, Mesh3d } from "raea/mesh";+import { DirectionalLight } from "raea/light";+import { Transform } from "raea/transform";+import { Camera3d } from "raea/camera";++export const SKY = "kloofendal_48d_partly_cloudy_puresky_1k.hdr";++export function Look() {+ return (+ <>+ <Camera3d transform={Transform.fromXyz(-1.6, 1.5, 2.2).lookingAt([1.2, 0.9, -1.2])} projection={{ Perspective: { fov: (60 * Math.PI) / 180 } }} />+ <Environment src={staticFile(SKY)} intensity={0.25} rotation={0.6} background />+ <DirectionalLight transform={Transform.fromXyz(8, 6, -1).lookingAt([1, 0, -0.5])} illuminance={45000} color="#fff1e0" shadow_maps_enabled />+ <Shadows distance={12} firstCascade={4} mapSize={4096} />+ <AmbientOcclusion quality="high" />+ <ToneMapping mode="agx" exposure={1.5} />+ </>+ );+}++const WALL = "#c8c2b6";+type Box = [string, [number, number, number], [number, number, number], string, number];+// name, centre, half size, colour, roughness. The room's inside is x -2..2, y 0..3, z -2.5..2.5; the window in the+// x = 2 wall, 1.6 wide (z -1.6..0) and 1.6 high (y 0.9..2.5)+const BOXES: Box[] = [+ ["floor", [0, -0.1, 0], [2.2, 0.1, 2.7], "#8a6a4a", 0.8],+ ["ceiling", [0, 3.1, 0], [2.2, 0.1, 2.7], "#e0ddd6", 1],+ ["left", [-2.1, 1.5, 0], [0.1, 1.6, 2.7], WALL, 1],+ ["back", [0, 1.5, -2.6], [2.2, 1.6, 0.1], WALL, 1],+ ["front", [0, 1.5, 2.6], [2.2, 1.6, 0.1], WALL, 1],+ ["sill", [2.1, 0.45, 0], [0.1, 0.45, 2.7], WALL, 1],+ ["lintel", [2.1, 2.75, 0], [0.1, 0.25, 2.7], WALL, 1],+ ["pier-back", [2.1, 1.7, -2.05], [0.1, 0.8, 0.45], WALL, 1],+ ["pier-front", [2.1, 1.7, 1.3], [0.1, 0.8, 1.3], WALL, 1],+ ["sofa", [-1.5, 0.35, -0.6], [0.45, 0.35, 1.1], "#3d5a73", 0.9],+ ["sofa-back", [-1.85, 0.75, -0.6], [0.12, 0.35, 1.1], "#3d5a73", 0.9],+ ["table", [0, 0.2, -0.5], [0.5, 0.2, 0.35], "#6b4a30", 0.6],+];++export function Parts() {+ return (+ <>+ {BOXES.map(([name, [x, y, z], half, color, rough]) => (+ <Mesh3d key={name} name={name} transform={Transform.fromXyz(x, y, z)}>+ <Cuboid half_size={half} />+ <StandardMaterial base_color={color} perceptual_roughness={rough} />+ </Mesh3d>+ ))}+ </>+ );+}diff --git a/bench/bake/table-cycles.tsx b/bench/bake/table-cycles.tsxnew file mode 100644index 00000000..50b02f22--- /dev/null+++ b/bench/bake/table-cycles.tsx@@ -0,0 +1,17 @@+// The table set with Cycles' bounce light baked into its lightmaps by blender/lightbake.py, any sun left live: what raea's+// own bake is measured against (docs/bake.feature BK0). `raea bake light --compare` makes media/baked/table/.+import { AbsoluteFill, Composition, registerRoot } from "raea";+import { Baked } from "./baked";+import { Look } from "./parts/table";+import info from "./media/baked/table/set.lightmaps.json";++function Shot() {+ return (+ <AbsoluteFill style={{ background: "#000000" }}>+ <Look />+ <Baked dir="baked/table" info={info} />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="table-cycles" component={Shot} width={1280} height={720} fps={30} durationInFrames={1} />);diff --git a/bench/bake/table.tsx b/bench/bake/table.tsxnew file mode 100644index 00000000..56a2195a--- /dev/null+++ b/bench/bake/table.tsx@@ -0,0 +1,14 @@+// The table set drawn by raea with nothing baked: the "before" frame (docs/bake.feature BK0, apps/lightbake/sets.json).+import { AbsoluteFill, Composition, registerRoot } from "raea";+import { Look, Parts } from "./parts/table";++function Shot() {+ return (+ <AbsoluteFill style={{ background: "#000000" }}>+ <Look />+ <Parts />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="table" component={Shot} width={1280} height={720} fps={30} durationInFrames={1} />);diff --git a/bench/bake/window-cycles.tsx b/bench/bake/window-cycles.tsxnew file mode 100644index 00000000..e7ed3e94--- /dev/null+++ b/bench/bake/window-cycles.tsx@@ -0,0 +1,17 @@+// The window set with Cycles' bounce light baked into its lightmaps by blender/lightbake.py, any sun left live: what raea's+// own bake is measured against (docs/bake.feature BK0). `raea bake light --compare` makes media/baked/window/.+import { AbsoluteFill, Composition, registerRoot } from "raea";+import { Baked } from "./baked";+import { Look } from "./parts/window";+import info from "./media/baked/window/set.lightmaps.json";++function Shot() {+ return (+ <AbsoluteFill style={{ background: "#000000" }}>+ <Look />+ <Baked dir="baked/window" info={info} />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="window-cycles" component={Shot} width={1280} height={720} fps={30} durationInFrames={1} />);diff --git a/bench/bake/window.tsx b/bench/bake/window.tsxnew file mode 100644index 00000000..5221619d--- /dev/null+++ b/bench/bake/window.tsx@@ -0,0 +1,14 @@+// The window set drawn by raea with nothing baked: the "before" frame (docs/bake.feature BK0, apps/lightbake/sets.json).+import { AbsoluteFill, Composition, registerRoot } from "raea";+import { Look, Parts } from "./parts/window";++function Shot() {+ return (+ <AbsoluteFill style={{ background: "#000000" }}>+ <Look />+ <Parts />+ </AbsoluteFill>+ );+}++registerRoot(() => <Composition id="window" component={Shot} width={1280} height={720} fps={30} durationInFrames={1} />);diff --git a/docs/bake.feature b/docs/bake.featureindex 85d8173c..5a97cd04 100644--- a/docs/bake.feature+++ b/docs/bake.feature@@ -47,7 +47,7 @@ Feature: Light baked by raea: bounce light into lightmaps on raea's own ray tracGiven the plan| crate | file | lines | job || raea-app-lightbake | apps/lightbake/src/lib.rs | 220 | `raea bake light EDIT.tsx [--composition ID] [--samples N] [--compare DIR]`: bake, then report |- | raea-app-lightbake | apps/lightbake/src/compare.rs | 180 | the same set's Cycles bake (lightbake.py) and Cycles still (look.py --engine cycles) beside raea's: stops and RMSE per mesh and per frame, time, memory |+ | raea-app-lightbake | apps/lightbake/src/compare.rs | 220 | the same set's Cycles bake (lightbake.py) and Cycles still (look.py --engine cycles) beside raea's: stops and RMSE per mesh and per frame, time, memory || raea-app-lightbake | apps/lightbake/sets.json | 40 | the test set: blender-research's table set, a Cornell box, a sunlit room with one window, the atelier's static set |Then each set has a Cycles reference at 1024 samples: its lightmaps and a still from a fixed cameraAnd `raea bake light --compare DIR` writes DIR/report.json and a table: for each set, raea's bake against Cycles'diff --git a/engine/cli/Cargo.toml b/engine/cli/Cargo.tomlindex 4ac2f200..26db2339 100644--- a/engine/cli/Cargo.toml+++ b/engine/cli/Cargo.toml@@ -75,6 +75,8 @@ raea-app-judge = { path = "../../apps/judge" }# raea scene lint|explain|light|stage (docs/stage-guards.feature)raea-app-scene = { path = "../../apps/scene" }raea-app-ask = { path = "../../apps/ask" }+# raea bake light (docs/bake.feature)+raea-app-lightbake = { path = "../../apps/lightbake" }raea-app-make = { path = "../../apps/make" }raea-app-media = { path = "../../apps/media" }# `raea app run|check|bundle` and `raea rune` on either target (docs/targets.feature T0b)diff --git a/engine/cli/src/cli.rs b/engine/cli/src/cli.rsindex 43dfdd16..83c96962 100644--- a/engine/cli/src/cli.rs+++ b/engine/cli/src/cli.rs@@ -145,9 +145,9 @@ pub fn run(args: &[String]) -> R<String> {let usage = format!("{usage}\n {} ({})", raea_sys_fixes::USAGE, raea_sys_fixes::ABOUT); // a problem looked up before it's guessed at (systems/fixes)// a workspace's files and specs (docs/projects.feature), listed under render's usage like librarylet usage = format!("{usage}\n raea spec FILE.ts [--as brief|script|taste|parts] (a spec's default export as JSON, checked against its schema: brief.ts, script.ts, taste.ts, NAME.parts.ts)\n raea workspace init [NAME] [--layout LAYOUT] | raea workspace adopt DIR [--name NAME] | raea workspace [--json] (a workspace: a git repo of projects under raea.root, ~/Documents/raea unless git config says)\n raea project new NAME [--storage inline|submodule] | raea project split NAME [--remote URL] | raea project join NAME | raea project [--json] (a project in the workspace: its folder, brief.ts, media/, out/; split and join keep its history)\n raea check EDIT.tsx --quick [--shape S] [--platform P] [--taste T] [-o check.json] (three stills of a composition checked for text: clipped, cramped, safe areas, sizes; about a second)\n raea hook [claude|codex|gemini|kimi] (every agent's tool hooks, which raea skills install adds: before a shell command, media opened in the Mac's viewer while the raea app is installed is stopped once for raea show (the same command again goes through); after a save, the quick check on a composition)\n raea next [DIR] (the two or three useful next steps for the project, from its brief, compositions, renders and checks)\n raea doctor [--fix] [DIR] (what doesn't match this raea: old brief files, an older workspace format, an agent's skill from another version)\n raea app run|check|bundle APP.tsx [--target web|native] [--size WxH] [--script steps.json] [--png DIR] [-o App.app] (a TSX app on @raea/ui: its window, the headless check, a Mac app; web is Blitz on Bevy, native is Rune; the app's `export const app` sets the target, web when it doesn't; raea rune ... is --target native)\n {}\n {}\n {} ({})\n {}\n {}\n {}", skill::USAGE, tools::blender::USAGE, tools::motion::SETUP_USAGE, tools::motion::SETUP_ABOUT, raea_app_engines::godot::USAGE, raea_app_engines::shot::USAGE, raea_app_engines::round::USAGE);- let (export_game, capcut, layers, xml, scene, physics, splat, wear) = (raea_app_game::USAGE, raea_app_capcut::USAGE, raea_app_layers::USAGE, raea_app_layers::USAGE_XML, raea_app_scene::USAGE, motion::physics::USAGE, tools::splat::USAGE, raea_runtime_wear::USAGE);+ let (export_game, capcut, layers, xml, scene, physics, splat, wear, bake) = (raea_app_game::USAGE, raea_app_capcut::USAGE, raea_app_layers::USAGE, raea_app_layers::USAGE_XML, raea_app_scene::USAGE, motion::physics::USAGE, tools::splat::USAGE, raea_runtime_wear::USAGE, raea_app_lightbake::USAGE);let apps = format!(" {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n {}\n", raea_app_direction::check::USAGE, raea_app_check::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_ask::USAGE, raea_app_make::USAGE, raea_app_direction::USAGE, raea_app_direction::findings::USAGE, raea_app_notes::USAGE, raea_app_fingerprint::USAGE, raea_sys_index::cli::USAGE);- return Ok(format!("raea: renders, plays and checks raea compositions (React and TypeScript) on the GPU.\n\nusage: {usage}\n raea init (a project's files where they're missing: edit.tsx, cuts.ts, components/, AGENTS.md)\n raea cut TAKE \"line\" ... | --at A-B ... [--append] (cuts.ts and words.json: a take under media/ cut in the pauses around each line it says, transcribed first if it has no TAKE.words.json; or at those seconds)\n raea frame TAKE [--at S] (how a take fits the edit: a talking take for <FaceFrame>, a screen for <ScreenFit>, from where its face is)\n raea component list | raea component add NAME ... [--shared] [--force] | raea part list | raea part add NAME ... [--shared] [--force] (a ready component or set copied into components/, or the workspace's shared/components/ with --shared, yours to change; raea part is its old name)\n raea brand DOMAIN|URL (the brand kit read from its website on this machine: brand/brand.css, brand/brand.json, BRAND.md, logos in media/brand; says when a plain fetch saw too little)\n raea guide [NAME] (craft, the floor read before any edit; the modes: pitch, explain, story, play, tool; motion, music, layout and the rest; bevy and bevy/NAME for 3D)\n raea context PROJECT (what to read before working on a project: taste, brief, look, the floor and its modes' guides)\n{apps} raea play EDIT.tsx [--input | --input-script KEYS.json] [--size WxH] [--seconds N|end] (a game, live; also: --input-log FILE --offscreen --snapshot T FILE --json FILE --seek F FILE --pick X,Y --view YAW,PITCH,DISTANCE --scrub N --baked --autoplay --no-vsync --master --3d)\n {export_game} (a game as a program of its own: a Mac app or a command)\n {capcut}\n {layers}\n {xml}\n {scene} (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)\n {physics} (the bakes <Physics> and <Goo> make)\n {wear} (a .glb's weathering causes for raea/wear: the model with a second UV set and its cause maps, made once in the asset store)\n {splat} (footage trained into a Gaussian splat for <Splat>; setup installs its tools)\n raea run SCRIPT.ts (a TypeScript program on the engine, headless: its default export is called, what it prints is the answer; a check like a room's checkLayout; also: --timeout S)\n raea gen image|video|music|sfx|speech|mesh|text \"PROMPT\" | gen plan|run FLOW.ts|FLOW.json | gen comfy import|export|run|schema FILE | gen models | gen balance (generated media through made.app, fal, Replicate, OpenRouter, Modal or ComfyUI; ComfyUI workflows both ways: raea gen alone lists its flags)\n {neural_usage} (DLSS 5 neural rendering on a `render --aov` folder, with its motion and depth: your own MLX-DLSS build and weights, RAEA_MLXDLSS and RAEA_DLSS_MODEL)\n {light_usage} (each scene on each light path against its path-traced reference: distance in stops, the worst tile, a moving shot's flicker, a frame's cost; DIR/report.json)\n raea mezz [--check] PATH... (an intra-only ProRes copy of each long-GOP source over 1080p, for smooth scrubbing; --check says which would get one)\n raea traces [show [N|last|DIR]] (the sessions raea left, newest first: how each ended, its glitches; show tells one in full)"));+ return Ok(format!("raea: renders, plays and checks raea compositions (React and TypeScript) on the GPU.\n\nusage: {usage}\n raea init (a project's files where they're missing: edit.tsx, cuts.ts, components/, AGENTS.md)\n raea cut TAKE \"line\" ... | --at A-B ... [--append] (cuts.ts and words.json: a take under media/ cut in the pauses around each line it says, transcribed first if it has no TAKE.words.json; or at those seconds)\n raea frame TAKE [--at S] (how a take fits the edit: a talking take for <FaceFrame>, a screen for <ScreenFit>, from where its face is)\n raea component list | raea component add NAME ... [--shared] [--force] | raea part list | raea part add NAME ... [--shared] [--force] (a ready component or set copied into components/, or the workspace's shared/components/ with --shared, yours to change; raea part is its old name)\n raea brand DOMAIN|URL (the brand kit read from its website on this machine: brand/brand.css, brand/brand.json, BRAND.md, logos in media/brand; says when a plain fetch saw too little)\n raea guide [NAME] (craft, the floor read before any edit; the modes: pitch, explain, story, play, tool; motion, music, layout and the rest; bevy and bevy/NAME for 3D)\n raea context PROJECT (what to read before working on a project: taste, brief, look, the floor and its modes' guides)\n{apps} raea play EDIT.tsx [--input | --input-script KEYS.json] [--size WxH] [--seconds N|end] (a game, live; also: --input-log FILE --offscreen --snapshot T FILE --json FILE --seek F FILE --pick X,Y --view YAW,PITCH,DISTANCE --scrub N --baked --autoplay --no-vsync --master --3d)\n {export_game} (a game as a program of its own: a Mac app or a command)\n {capcut}\n {layers}\n {xml}\n {scene} (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)\n {physics} (the bakes <Physics> and <Goo> make)\n {bake}\n {wear} (a .glb's weathering causes for raea/wear: the model with a second UV set and its cause maps, made once in the asset store)\n {splat} (footage trained into a Gaussian splat for <Splat>; setup installs its tools)\n raea run SCRIPT.ts (a TypeScript program on the engine, headless: its default export is called, what it prints is the answer; a check like a room's checkLayout; also: --timeout S)\n raea gen image|video|music|sfx|speech|mesh|text \"PROMPT\" | gen plan|run FLOW.ts|FLOW.json | gen comfy import|export|run|schema FILE | gen models | gen balance (generated media through made.app, fal, Replicate, OpenRouter, Modal or ComfyUI; ComfyUI workflows both ways: raea gen alone lists its flags)\n {neural_usage} (DLSS 5 neural rendering on a `render --aov` folder, with its motion and depth: your own MLX-DLSS build and weights, RAEA_MLXDLSS and RAEA_DLSS_MODEL)\n {light_usage} (each scene on each light path against its path-traced reference: distance in stops, the worst tile, a moving shot's flicker, a frame's cost; DIR/report.json)\n raea mezz [--check] PATH... (an intra-only ProRes copy of each long-GOP source over 1080p, for smooth scrubbing; --check says which would get one)\n raea traces [show [N|last|DIR]] (the sessions raea left, newest first: how each ended, its glitches; show tells one in full)"));}// `--version`: the release's version, which a skill's front matter names (docs/skills.feature SK6)if args.len() == 1 && matches!(args[0].as_str(), "--version" | "-V") {@@ -262,6 +262,7 @@ pub fn run(args: &[String]) -> R<String> {Some("splat") => return tools::splat::splat(args),// `physics bake|goo|part ...`: the bakes <Physics> and <Goo> make (systems/bake, registered in motion/physics.rs)Some("physics") => return motion::physics::cli(args),+ Some("bake") => return raea_app_lightbake::cli(args), // `bake light`: bounce light baked on raea's ray tracer, held to Cycles (apps/lightbake)// `wear bake REQUEST.json [-o OUT.json]`: raea/wear's cause maps of a .glb (raea-runtime-wear, registered in thread.rs)Some("wear") => return raea_runtime_wear::cli(args, motion::media_path),// `scene lint|explain EDIT.tsx`: what each 3D part rests on; floating, sunk and clipping parts (raea-sys-contact, through motion/contact.rs)diff --git a/engine/cli/src/tests.rs b/engine/cli/src/tests.rsindex 634f43f8..707744eb 100644--- a/engine/cli/src/tests.rs+++ b/engine/cli/src/tests.rs@@ -32,7 +32,7 @@ fn help_lists_every_verb() {let listed = |v: &str| [format!("raea {v} "), format!("raea {v}\n"), format!("| {v} ")].iter().any(|l| help.contains(l.as_str()));let missing: Vec<_> = verbs.iter().filter(|v| !listed(v) && !unlisted.contains(&v.as_str())).collect();assert!(missing.is_empty(), "not in raea help: {missing:?}");- for usage in [raea_app_check::USAGE, raea_app_ask::USAGE, raea_app_direction::check::USAGE, raea_app_direction::USAGE, raea_app_notes::USAGE, raea_app_game::USAGE, raea_app_scene::USAGE, motion::physics::USAGE, raea_runtime_wear::USAGE, tools::splat::USAGE, tools::sound::SAO_USAGE, tools::sound::TOKENSYNTH_USAGE, tools::song::USAGE, motion::track::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_make::USAGE, tools::blender::USAGE] {+ for usage in [raea_app_check::USAGE, raea_app_ask::USAGE, raea_app_direction::check::USAGE, raea_app_direction::USAGE, raea_app_notes::USAGE, raea_app_game::USAGE, raea_app_scene::USAGE, motion::physics::USAGE, raea_runtime_wear::USAGE, tools::splat::USAGE, tools::sound::SAO_USAGE, tools::sound::TOKENSYNTH_USAGE, tools::song::USAGE, motion::track::USAGE, raea_app_solid::USAGE, raea_app_judge::USAGE, raea_app_make::USAGE, tools::blender::USAGE, raea_app_lightbake::USAGE] {assert!(help.contains(usage), "{usage}");}}diff --git a/tools/layers.toml b/tools/layers.tomlindex 41dbc6e7..0f41d7e9 100644--- a/tools/layers.toml+++ b/tools/layers.toml@@ -212,6 +212,7 @@ raea-app-judge = "apps"raea-app-make = "apps"raea-app-scene = "apps" # raea scene lint|explain|light|stageraea-app-ask = "apps"+raea-app-lightbake = "apps" # raea bake light (docs/bake.feature)raea-app-double = "apps"raea-app-solid = "apps"raea-app-media = "apps"