Skip to content

armgit / raea

Public Imported from GitHub
0

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.

raea light steady --run M: the frame cold against the same frame after M frames played up to it (a cache gaining or losing energy over minutes), the render's output kept in render.log, and a failure names the three things on Solari that build light over frames, not the world cache alone

shinyobjectz2c3bcfa0eba1
diff --git a/docs/manual/reference/cli/light.md b/docs/manual/reference/cli/light.md
index 53ae2b2b..0f1659c4 100644
--- a/docs/manual/reference/cli/light.md
+++ b/docs/manual/reference/cli/light.md
@@ -38,7 +38,7 @@ whatever the composition asks, and `RAEA_LIGHT_SPP=N` draws each frame N times,
`raea light steady` asks one thing of one frame: does its light hold still? It draws frame `--frame` again and again
(`raea render --hold`), so nothing in the scene or the camera moves, and measures what still changes. Grain is a
pixel or two wide and new every frame. A blotch is tens of pixels wide and drifts over lit floors and reflections for a
-quarter of a second or more: on Solari, the world cache lit by too few rays. The two are told apart by size: the
+quarter of a second or more: light built over frames that hasn't settled (on Solari the world cache, ReSTIR's reuse or the denoiser; `DIR/held/render.log` keeps what the render said). The two are told apart by size: the
deviation in time of each 32-pixel square's mean luminance (`blotch`, percent of the mean) against each 8-pixel
square's (`grain`). Grain alone gives a `spread` of 0.25, and blotches bring it toward 1. A run over `--max` fails,
`DIR/held/steady.png` shows where (white is 6%), and `steady.json` holds the numbers. A light whose level moves over the held frames fails too (`drift`, more than 0.05 of a stop between the first and the last quarter measured): a cache gaining or losing energy the longer it runs.
@@ -60,7 +60,7 @@ raea light check bench/light/scenes.json -o out/light/ --scene kitchen --paths s
## Usage
```sh
-raea light check SCENES.json -o DIR [--scene NAME] [--paths raster,traced-ao,solari,gi] [--spp N] [--fresh] | raea light steady EDIT.tsx --frame N [--composition ID] [--frames 96] [--max 1.5] -o DIR | raea light steady DIR [--max 1.5] (steady: frame N held, and whether its light holds still) (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)
+raea light check SCENES.json -o DIR [--scene NAME] [--paths raster,traced-ao,solari,gi] [--spp N] [--fresh] | raea light steady EDIT.tsx --frame N [--composition ID] [--frames 96] [--run M] [--max 1.5] -o DIR | raea light steady DIR [--max 1.5] (steady: frame N held, and whether its light holds still) (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)
```
Headless: it needs nothing running and opens no window. Takes up to 2 arguments besides its flags.
@@ -75,6 +75,7 @@ Headless: it needs nothing running and opens no window. Takes up to 2 arguments
| `--fresh` | – | Make the references again, even where they're kept from an earlier check. |
| `--max` | `1.5` | `steady`: the blotch, in percent, a run may show before it fails. The worst tile may show three times it. |
| `--paths` | `raster,traced-ao,solari,gi` | The light paths to measure, comma-separated (all four by default). |
+| `--run` | `M` | `steady`: also draws the frame cold and at the end of the M frames played up to it, and fails when their levels are more than 0.25 of a stop apart (`energy`). A cache that gains or loses energy over minutes shows here and not in a hold. |
| `--scene` | `NAME` | Check only the scene with this name. |
| `--spp` | `N` | How many times each reference frame is path-traced: its samples a pixel (256 by default). |
| `-o` | `DIR` | The folder for each scene's frames and report.json. |
diff --git a/engine/light/src/lib.rs b/engine/light/src/lib.rs
index fbcb013e..2e7c037c 100644
--- a/engine/light/src/lib.rs
+++ b/engine/light/src/lib.rs
@@ -24,7 +24,7 @@ use std::time::Instant;
const TRACED: [&str; 2] = ["solari", "gi"];
/// How many times a traced path's still is held for `steady`.
const HELD: usize = 96;
-pub const USAGE: &str = "raea light check SCENES.json -o DIR [--scene NAME] [--paths raster,traced-ao,solari,gi] [--spp N] [--fresh] | raea light steady EDIT.tsx --frame N [--composition ID] [--frames 96] [--max 1.5] -o DIR | raea light steady DIR [--max 1.5] (steady: frame N held, and whether its light holds still)";
+pub const USAGE: &str = "raea light check SCENES.json -o DIR [--scene NAME] [--paths raster,traced-ao,solari,gi] [--spp N] [--fresh] | raea light steady EDIT.tsx --frame N [--composition ID] [--frames 96] [--run M] [--max 1.5] -o DIR | raea light steady DIR [--max 1.5] (steady: frame N held, and whether its light holds still)";
/// The light paths a check compares: RAEA_LIGHT's, and traced-ao, raster with systems/rt's traced occlusion in place
/// of SSAO (on a camera with <AmbientOcclusion>; on any other it draws as raster).
diff --git a/engine/light/src/steady.rs b/engine/light/src/steady.rs
index 402d96b6..fb6af322 100644
--- a/engine/light/src/steady.rs
+++ b/engine/light/src/steady.rs
@@ -31,6 +31,8 @@ const MAX_SHOWN: f64 = 6.0;
/// What a run may show before it fails, percent, unless `--max` says: a held raster frame reads 0, Solari with a
/// built cache under 1.
const MAX: f64 = 1.5;
+/// How far a frame's level at the end of a run may be from the frame drawn cold, in stops (`--run`).
+const MAX_ENERGY: f64 = 0.25;
/// How far the held frame's level may move between the first and the last quarter of the measured frames, in stops.
const MAX_DRIFT: f64 = 0.05;
@@ -100,17 +102,24 @@ fn held(dir: &Path) -> R<Vec<PathBuf>> {
/// Frame `frame` of a composition held for `n` frames into `out` (`raea render --hold`), run in `dir` under `env`.
pub fn hold(dir: &Path, file: &str, composition: Option<&str>, frame: &str, n: usize, env: &[(&str, String)], out: &Path) -> R<()> {
+ draw(dir, file, composition, &["--hold", &format!("{frame}:{n}")], env, out)
+}
+
+/// A composition's frames drawn into `out` as `how` says (`--hold N:M`, `--at A,B,...`), run in `dir` under `env`.
+fn draw(dir: &Path, file: &str, composition: Option<&str>, how: &[&str], env: &[(&str, String)], out: &Path) -> R<()> {
let _ = std::fs::remove_dir_all(out);
std::fs::create_dir_all(out).map_err(|e| format!("{}: {e}", out.display()))?;
let mut cmd = std::process::Command::new(std::env::current_exe().map_err(|e| e.to_string())?);
cmd.current_dir(dir).envs(env.iter().map(|(k, v)| (*k, v)));
- cmd.args(["render", file, "--hold", &format!("{frame}:{n}"), "-o"]).arg(format!("{}/", out.display()));
+ cmd.arg("render").arg(file).args(how).arg("-o").arg(format!("{}/", out.display()));
if let Some(c) = composition {
cmd.args(["--composition", c]);
}
let run = cmd.args(["--despite", "clips", "raea light steady measures light, not placement"]).output().map_err(|e| e.to_string())?;
+ // what the render said, kept beside its frames: a refused cache load or a switch that didn't take is read there
+ let err = String::from_utf8_lossy(&run.stderr);
+ let _ = std::fs::write(out.join("render.log"), format!("{}{err}", String::from_utf8_lossy(&run.stdout)));
if !run.status.success() {
- let err = String::from_utf8_lossy(&run.stderr);
return Err(format!("the held render failed: {}", err.lines().rev().take(4).collect::<Vec<_>>().into_iter().rev().collect::<Vec<_>>().join(" | ")));
}
Ok(())
@@ -145,7 +154,7 @@ pub fn line(r: &Value) -> String {
}
/// What a light that doesn't hold still is told.
-pub const WHY: &str = "On Solari this is the world cache lit by too few rays, or gaining or losing energy the longer it runs: bake it (cache.bake, then cache.load), or give it a longer history";
+pub const WHY: &str = "Patches this size are light built over frames that hasn't settled: on Solari the world cache, ReSTIR's reuse or the denoiser. Hold the frame with each switched off in turn (cache.steady or a baked cache, RAEA_SOLARI_DENOISE=0, RAEA_SOLARI_PSR=0) to see which; DIR/render.log holds what each render said";
pub fn steady(args: &[String]) -> R<String> {
let first = args.first().ok_or(format!("usage: {USAGE}"))?;
@@ -159,7 +168,31 @@ pub fn steady(args: &[String]) -> R<String> {
hold(Path::new("."), first, flag(args, "--composition").as_deref(), &frame, n, &[], &out)?;
out
};
- let r = report(&dir, max)?;
+ let mut r = report(&dir, max)?;
+ // --run M: the frame cold against the same frame at the end of M frames played up to it. A cache that gains or
+ // loses energy over minutes (MALL RAT's court, 11-24: 7 times brighter inside the long render) shows here and not
+ // in a hold
+ if let (Some(m), Some(frame), false) = (flag(args, "--run"), flag(args, "--frame"), Path::new(first).is_dir()) {
+ let (m, n): (i64, i64) = (m.parse().map_err(|_| format!("--run takes a count of frames, not {m}"))?, frame.parse().map_err(|_| format!("--frame takes a frame, not {frame}"))?);
+ let base = dir.parent().unwrap_or(&dir).to_path_buf();
+ let level = |name: &str, at: Vec<i64>| -> R<f64> {
+ let out = base.join(name);
+ let at: Vec<String> = at.iter().map(i64::to_string).collect();
+ draw(Path::new("."), first, flag(args, "--composition").as_deref(), &["--at", &at.join(",")], &[], &out)?;
+ let last = held(&out)?.pop().ok_or(format!("{}: no frame drawn", out.display()))?;
+ let f = metric::load(&last)?;
+ Ok(f.y.iter().map(|&v| v as f64).sum::<f64>() / f.y.len().max(1) as f64)
+ };
+ let energy = (level("run", ((n - m).max(0)..=n).collect())?.max(1e-6) / level("cold", vec![n])?.max(1e-6)).log2();
+ r["energy"] = json!((energy * 1e3).round() / 1e3);
+ r["max_energy"] = json!(MAX_ENERGY);
+ if energy.abs() > MAX_ENERGY {
+ r["steady"] = json!(false);
+ }
+ std::fs::write(dir.join("steady.json"), serde_json::to_string_pretty(&r).unwrap_or_default()).map_err(|e| e.to_string())?;
+ let said = format!("energy {} stops after {m} frames against the frame cold (max {MAX_ENERGY}), {}", r["energy"], line(&r));
+ return if r["steady"] == json!(true) { Ok(format!("STEADY {said}")) } else { Err(format!("the light doesn't hold still: {said}. {WHY}")) };
+ }
if r["steady"] == json!(true) { Ok(format!("STEADY {}", line(&r))) } else { Err(format!("the light doesn't hold still: {}. {WHY}", line(&r))) }
}