mirror of
https://github.com/shinyobjectz/raea.git
synced 2026-12-01 06:53:19 -10:00
Compare commits
55
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
22834de9b1 | ||
|
|
300e094b9d | ||
|
|
7e214fedbb | ||
|
|
280437c111 | ||
|
|
11f28ffc52 | ||
|
|
107b591555 | ||
|
|
b7cc2694aa | ||
|
|
2bd30c5fad | ||
|
|
d169848689 | ||
|
|
0d92089f7d | ||
|
|
5885f86ff3 | ||
|
|
e02151cf49 | ||
|
|
49c2c96a1a | ||
|
|
346cacd71a | ||
|
|
ad766214e0 | ||
|
|
745c5f98c8 | ||
|
|
d36b0604bc | ||
|
|
03c2e2ee15 | ||
|
|
21859a5a31 | ||
|
|
f02348c397 | ||
|
|
64d97bac8f | ||
|
|
b9d1beaa2f | ||
|
|
b1a8d57616 | ||
|
|
9adc87dcd9 | ||
|
|
3a1cff770b | ||
|
|
09d87cfa1c | ||
|
|
afa6702c05 | ||
|
|
38f49d623f | ||
|
|
7ded6a7612 | ||
|
|
6416e4ec1b | ||
|
|
2556f42366 | ||
|
|
f2351359c8 | ||
|
|
7595c81782 | ||
|
|
1926af81a5 | ||
|
|
5d5da4f3d8 | ||
|
|
760d8e53c1 | ||
|
|
40757526f8 | ||
|
|
50a7e94f5e | ||
|
|
6735bd940f | ||
|
|
505103dacb | ||
|
|
8cbf438488 | ||
|
|
4447ff2425 | ||
|
|
b250367b6c | ||
|
|
813bc24097 | ||
|
|
2127b369d3 | ||
|
|
5650d65c65 | ||
|
|
974148442e | ||
|
|
89fd926258 | ||
|
|
dd9be82976 | ||
|
|
784e156895 | ||
|
|
2161fa0ba0 | ||
|
|
e745f91ae4 | ||
|
|
a0f685b043 | ||
|
|
5c4ddb6989 | ||
|
|
17518a3ac1 |
No files matched your search
@@ -118,7 +118,12 @@ jobs:
|
||||
# debug info off: with it the test binaries of the app crates filled 27 GB of a runner's disk (#90)
|
||||
env:
|
||||
CARGO_PROFILE_TEST_DEBUG: "0"
|
||||
run: cargo test --locked -p raea-runtime-plugins -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-bundle -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
# raea-bundle in a call of its own: Rolldown's crates turn on serde_json's arbitrary_precision, features unify
|
||||
# across one cargo call, and with it on an untagged enum can't read a number (raea-core-brief's make dials failed
|
||||
# here from 11-23 while passing alone). raea itself never links Rolldown: it loads it as a library at run time
|
||||
run: |
|
||||
cargo test --locked -p raea-runtime-plugins -p raea-io-media -p raea-core-fonts -p raea-native -p raea-core-brief -p raea-core-k -p raea-app-check -p raea-app-check-flash -p raea-io-ffmpeg -p raea-app-workspace -p raea-app-tools -p raea-app-targets
|
||||
cargo test --locked -p raea-bundle
|
||||
- name: Windows' and Linux's own (#169)
|
||||
# what a Windows or Linux user meets that no other step ran: QuickJS's Intl (raea-runtime-jsengine's
|
||||
# quickjs_formats_as_javascriptcore_does, on Linux), openh264 at --quality master (raea-io-soft), git found or
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# Apple Silicon, Linux on x86_64 and Windows on x86_64 are built from the tag on GitHub's runners, packed by
|
||||
# tools/release.sh, checked by tools/release-check.sh, attested (anyone can check a download with
|
||||
# `gh attestation verify raea-VERSION-macos-arm64.tar.gz -R shinyobjectz/raea`) and attached to the tag's release.
|
||||
# Linux also packages and checks an AppImage from the same verified archive (tools/release-appimage.sh).
|
||||
# The skills gate reads the feed app, which is private, so it runs in a maintainer's checkout first
|
||||
# (tools/skills.sh check), and the tag names the commit it passed on; tools/release.sh checks the gate's inputs haven't
|
||||
# changed since (tools/release/skills-passed.sh):
|
||||
@@ -181,6 +182,11 @@ jobs:
|
||||
v=${TAG#v}
|
||||
if [ "$RUNNER_OS" = Linux ]; then xvfb-run -a -s "-screen 0 1280x1024x24" bash tools/release.sh "$v" ship HEAD
|
||||
else bash tools/release.sh "$v" ship HEAD; fi
|
||||
- name: Package and check the Linux AppImage
|
||||
if: runner.os == 'Linux'
|
||||
env:
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/appimage-check
|
||||
run: xvfb-run -a -s "-screen 0 1280x1024x24" bash tools/release-appimage.sh "${TAG#v}" "dist/raea-${TAG#v}-linux-x86_64.tar.gz"
|
||||
# a failed check's own files (the app check's frames, every step's log), not the unpacked release
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
@@ -189,6 +195,8 @@ jobs:
|
||||
path: |
|
||||
${{ runner.temp }}/release-check/app
|
||||
${{ runner.temp }}/release-check/**/*.log
|
||||
${{ runner.temp }}/appimage-check/app
|
||||
${{ runner.temp }}/appimage-check/**/*.log
|
||||
retention-days: 7
|
||||
if-no-files-found: ignore
|
||||
# the stripped binaries' symbols (#88), for symbolicating a crash report from this release; never published
|
||||
@@ -202,6 +210,10 @@ jobs:
|
||||
if: ${{ !inputs.dry_run }}
|
||||
with:
|
||||
subject-path: dist/raea-*.tar.gz
|
||||
- uses: actions/attest-build-provenance@v2
|
||||
if: ${{ runner.os == 'Linux' && !inputs.dry_run }}
|
||||
with:
|
||||
subject-path: dist/raea-*.AppImage
|
||||
- name: Attach to the release
|
||||
if: ${{ !inputs.dry_run }}
|
||||
env:
|
||||
@@ -209,11 +221,16 @@ jobs:
|
||||
run: |
|
||||
gh release view "$TAG" >/dev/null 2>&1 || gh release create "$TAG" ${{ contains(env.TAG, '-') && '--prerelease' || '' }} --title "raea ${TAG#v}" --notes "Built by .github/workflows/release.yml; notes follow."
|
||||
gh release upload "$TAG" dist/raea-*.tar.gz dist/raea-*.tar.gz.sha256 --clobber
|
||||
if [ "$RUNNER_OS" = Linux ]; then
|
||||
gh release upload "$TAG" dist/raea-*.AppImage dist/raea-*.AppImage.sha256 --clobber
|
||||
fi
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ inputs.dry_run }}
|
||||
with:
|
||||
name: dry-run-${{ runner.os }}
|
||||
path: dist/raea-*.tar.gz*
|
||||
path: |
|
||||
dist/raea-*.tar.gz*
|
||||
dist/raea-*.AppImage*
|
||||
retention-days: 3
|
||||
compression-level: 0
|
||||
|
||||
@@ -223,6 +240,9 @@ jobs:
|
||||
# (tools/release/win-bundle.sh), as Microsoft documents for app-local deployment.
|
||||
windows:
|
||||
runs-on: ${{ (vars.RELEASE_WINDOWS_RUNNER && fromJSON(vars.RELEASE_WINDOWS_RUNNER)) || 'windows-latest' }}
|
||||
# the signing identity's federated credential trusts this repository's environment "signing" and nothing else
|
||||
# (Azure app raea-release-signing); with no identity set there is no environment, and the zip is unsigned
|
||||
environment: ${{ vars.AZURE_SIGN_CLIENT_ID != '' && 'signing' || '' }}
|
||||
timeout-minutes: 350
|
||||
env:
|
||||
# the compile cache, as build's
|
||||
@@ -352,9 +372,24 @@ jobs:
|
||||
run: bash tools/release/lavapipe.sh
|
||||
- name: Where the skills gate passed
|
||||
run: bash tools/release/skills-passed.sh "$TAG" "${{ inputs.skills_passed }}"
|
||||
# raea's own Windows programs signed (#221), once the repository has the signing identity: the variables
|
||||
# AZURE_SIGN_CLIENT_ID, AZURE_SIGN_TENANT_ID and AZURE_SIGN_SUBSCRIPTION_ID name an Azure app whose federated
|
||||
# credential trusts this workflow and which holds the Artifact Signing Certificate Profile Signer role on the
|
||||
# account (no secret is stored: the job's own token is exchanged). Without them the zip is unsigned, as before
|
||||
- name: Sign in to Azure for signing
|
||||
if: ${{ vars.AZURE_SIGN_CLIENT_ID != '' }}
|
||||
uses: azure/login@v2
|
||||
with:
|
||||
client-id: ${{ vars.AZURE_SIGN_CLIENT_ID }}
|
||||
tenant-id: ${{ vars.AZURE_SIGN_TENANT_ID }}
|
||||
subscription-id: ${{ vars.AZURE_SIGN_SUBSCRIPTION_ID }}
|
||||
- name: jsign (signs raea's programs)
|
||||
if: ${{ vars.AZURE_SIGN_CLIENT_ID != '' }}
|
||||
run: choco install jsign -y --no-progress
|
||||
- name: Pack and check (tools/release.sh)
|
||||
env:
|
||||
RAEA_CHECK_DIR: ${{ runner.temp }}/release-check
|
||||
RAEA_WIN_SIGN: ${{ vars.AZURE_SIGN_CLIENT_ID != '' && '1' || '' }}
|
||||
run: bash tools/release.sh "${TAG#v}" target/dist HEAD
|
||||
# live play on Windows (PT20 left it unproven): bevy-ts's play cases, `play --offscreen` with an input script and
|
||||
# a snapshot's pixels probed, run by the raea just built; check.sh reads the pixels with ImageMagick, which the
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
# Code of conduct
|
||||
|
||||
raea's issues, pull requests, reviews and other project-managed community spaces
|
||||
should let people discuss and improve the work without harassment. This applies
|
||||
to maintainers, contributors and people using automated or AI-assisted tools.
|
||||
Participants remain responsible for the material they submit through those tools.
|
||||
|
||||
## Expected behavior
|
||||
|
||||
- Discuss the code, evidence and ideas respectfully. Technical disagreement is
|
||||
welcome; personal attacks and assumptions about another person's motives are not.
|
||||
- Give actionable feedback, accept corrections and respect requests to stop a
|
||||
conversation or move it out of a thread.
|
||||
- Make room for different experience levels, backgrounds and communication styles.
|
||||
- Respect privacy. Share only logs, screenshots and other information you have
|
||||
permission to publish, with credentials and personal information removed.
|
||||
|
||||
Harassment, discriminatory insults, threats, sexual harassment, unwanted repeated
|
||||
contact, disclosure of private information, deliberate disruption and retaliation
|
||||
against someone raising a concern are unacceptable.
|
||||
|
||||
## Reporting a concern
|
||||
|
||||
For content on GitHub, use the content menu's **Report content** action where it
|
||||
is available. Choose **Report to repository admins** if GitHub offers it.
|
||||
Maintainer reporting depends on repository settings and the reporter's access.
|
||||
For abuse covered by GitHub's rules, use **Report abuse to GitHub Support** or
|
||||
[GitHub's abuse-reporting route](https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam).
|
||||
GitHub handles those reports under its own policies; it is not the project's
|
||||
appeal body for every technical or moderation disagreement.
|
||||
|
||||
A separate private maintainer inbox for conduct reports has not been designated
|
||||
in this repository. If GitHub's maintainer-reporting option is unavailable, ask
|
||||
for a private contact without posting the incident, personal information or
|
||||
accusations in a public issue. Maintainers can document an additional contact
|
||||
after confirming who will handle it. Use [the security policy](SECURITY.md) for vulnerabilities,
|
||||
not as a general conduct-report channel.
|
||||
|
||||
Include links, the relevant context and your preferred way to be contacted when
|
||||
reporting privately. Do not retaliate, publicly investigate the reporter or
|
||||
pressure someone to disclose an incident.
|
||||
|
||||
## Moderation
|
||||
|
||||
Repository maintainers may clarify expectations, ask participants to change
|
||||
behavior, close or remove disruptive content, restrict interactions, or block
|
||||
continued participation as appropriate to severity and repetition. A technical
|
||||
disagreement or a rejected contribution alone is not misconduct.
|
||||
|
||||
Maintainers should consider context and available evidence, protect sensitive
|
||||
information, explain decisions when doing so does not compromise privacy, and
|
||||
allow a participant to provide relevant additional context privately through the
|
||||
same reporting route. A maintainer involved in a concern should seek an uninvolved
|
||||
reviewer where one is available. This policy does not promise a response deadline
|
||||
or confidentiality beyond what the chosen reporting service and process provide.
|
||||
Generated
+32
@@ -13896,6 +13896,8 @@ dependencies = [
|
||||
"raea-core-facts",
|
||||
"raea-core-review",
|
||||
"raea-io-home",
|
||||
"raea-runtime-cut-plan",
|
||||
"raea-runtime-lod-plan",
|
||||
"resvg 0.48.1",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -13976,6 +13978,7 @@ dependencies = [
|
||||
"raea-core-scene",
|
||||
"raea-runtime-bundle",
|
||||
"raea-runtime-export",
|
||||
"raea-runtime-lod-plan",
|
||||
"raea-sys-contact",
|
||||
"raea-sys-light-meter",
|
||||
"raea-sys-stage",
|
||||
@@ -14042,6 +14045,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"cpal 0.15.3",
|
||||
"ort",
|
||||
"raea-io-trace",
|
||||
"raea-sys-ml",
|
||||
"raea-sys-speech",
|
||||
"serde_json",
|
||||
@@ -14804,7 +14808,9 @@ name = "raea-light"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-io-home",
|
||||
"raea-io-trace",
|
||||
"raea-runtime-bundle",
|
||||
"serde_json",
|
||||
]
|
||||
@@ -15003,6 +15009,7 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"dunce",
|
||||
"image",
|
||||
"raea-core-facts",
|
||||
"raea-core-program",
|
||||
"raea-core-shape",
|
||||
"raea-gpu-device",
|
||||
@@ -15062,6 +15069,7 @@ dependencies = [
|
||||
"raea-sys-engine-shaders",
|
||||
"raea-sys-post",
|
||||
"raea-sys-rt",
|
||||
"raea-sys-viewbox",
|
||||
"serde_json",
|
||||
"wgpu",
|
||||
]
|
||||
@@ -15288,6 +15296,15 @@ dependencies = [
|
||||
"raea-io-home",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-cut-plan"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-core-brief",
|
||||
"raea-io-soft",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-dom"
|
||||
version = "0.1.0"
|
||||
@@ -15363,6 +15380,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
"raea-runtime-lod-plan",
|
||||
"raea-sys-contact",
|
||||
"raea-sys-stage",
|
||||
"serde_json",
|
||||
@@ -15503,6 +15521,18 @@ dependencies = [
|
||||
"winit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-lod-plan"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"dunce",
|
||||
"raea-core-facts",
|
||||
"raea-core-scene",
|
||||
"raea-sys-stage",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "raea-runtime-look"
|
||||
version = "0.1.0"
|
||||
@@ -16144,6 +16174,7 @@ name = "raea-sys-framepass"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-sys-compose",
|
||||
"raea-sys-frame",
|
||||
"raea-sys-material",
|
||||
"raea-sys-sampler",
|
||||
@@ -16735,6 +16766,7 @@ name = "raea-sys-viewbox"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"raea-sys-compose",
|
||||
"raea-sys-frame",
|
||||
]
|
||||
|
||||
|
||||
@@ -193,6 +193,8 @@ members = [
|
||||
"runtime/canvas",
|
||||
"runtime/export",
|
||||
"runtime/endchecks",
|
||||
"runtime/lod-plan",
|
||||
"runtime/cut-plan",
|
||||
"runtime/live",
|
||||
"runtime/page",
|
||||
"runtime/appscreen",
|
||||
|
||||
@@ -80,6 +80,13 @@ The installer puts the `raea` command under `~/.raea`, links it into `~/.local/b
|
||||
work. Run it again to update. The engine is free and needs no account. Tarballs and checksums are on the
|
||||
[releases page](https://github.com/shinyobjectz/raea/releases).
|
||||
|
||||
Linux release builds also package an x86_64 AppImage of the engine command and
|
||||
attach it and its SHA256 checksum beside the release archives.
|
||||
Make it executable with `chmod +x raea-*.AppImage`, then run
|
||||
`./raea-VERSION-linux-x86_64.AppImage --help` or pass the usual `raea` arguments.
|
||||
See [the AppImage release recipe](tools/release/README.md#linux-appimage) for build
|
||||
instructions, runtime requirements and running without FUSE.
|
||||
|
||||
On Windows 10 or 11, in PowerShell:
|
||||
|
||||
```powershell
|
||||
|
||||
@@ -240,6 +240,16 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], wh
|
||||
None => hows.iter().filter(|(_, h)| matches!(h, How::Named(n) if n.render && n.name != "text-read")).for_each(|(r, _)| needs(&mut waits, r)),
|
||||
}
|
||||
}
|
||||
// traced light held still (raea light steady): with the floor, a composition lit by Solari carries what its newest
|
||||
// hold of each frame found, kept in the project's record; with none yet, it waits for one
|
||||
if floor && traced(tsx) {
|
||||
let held = light_held(tsx, id.as_deref());
|
||||
if held.is_empty() {
|
||||
let c = id.as_ref().map(|i| format!(" --composition {i}")).unwrap_or_default();
|
||||
waits.push(("light-steady".into(), format!("a held frame of its traced light (raea light steady {}{c} --frame N -o DIR)", tsx.display())));
|
||||
}
|
||||
found.extend(held.into_iter().filter(|f| f.level != Level::Note));
|
||||
}
|
||||
// the project's own checks, in one run
|
||||
let mut files: Vec<PathBuf> = Vec::new();
|
||||
let mut plan = Vec::new();
|
||||
@@ -269,6 +279,46 @@ fn check_one(tsx: &Path, id: Option<String>, rules: &[Rule], args: &[String], wh
|
||||
Ok(Checked { file: tsx.to_path_buf(), id, found: finding::ranked(found), waits, render, shots, fps })
|
||||
}
|
||||
|
||||
/// Whether a composition is lit by traced light: its file, or a .tsx beside it or a folder down, names SolariLighting.
|
||||
fn traced(tsx: &Path) -> bool {
|
||||
let mut files = vec![tsx.to_path_buf()];
|
||||
let tsxs = |d: &Path| -> Vec<PathBuf> { std::fs::read_dir(d).into_iter().flatten().flatten().map(|e| e.path()).collect() };
|
||||
if let Some(dir) = tsx.parent() {
|
||||
files.extend(tsxs(dir).into_iter().flat_map(|p| if p.is_dir() { tsxs(&p) } else { vec![p] }).filter(|p| p.extension().is_some_and(|x| x == "tsx")));
|
||||
}
|
||||
for f in files {
|
||||
if let Ok(text) = std::fs::read_to_string(&f) {
|
||||
if text.contains("SolariLighting") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
/// The findings of the newest hold of each frame of a composition (`raea light steady`), from its project's record.
|
||||
fn light_held(tsx: &Path, id: Option<&str>) -> Vec<Finding> {
|
||||
let Some(project) = dunce::canonicalize(tsx).ok().and_then(|t| record::up(t.parent()?, ".raea/project")) else { return Vec::new() };
|
||||
let of = record::rel(&project, tsx);
|
||||
let mut newest: std::collections::BTreeMap<i64, Vec<Finding>> = std::collections::BTreeMap::new();
|
||||
for e in record::read(&project) {
|
||||
if e.by != "raea light steady" || e.of != of {
|
||||
continue;
|
||||
}
|
||||
let mut mine = Vec::new();
|
||||
for f in e.findings {
|
||||
let mut about = f.about.iter().map(|a| a.name.as_str());
|
||||
if id.is_none_or(|id| about.any(|n| n == id)) {
|
||||
mine.push(f);
|
||||
}
|
||||
}
|
||||
if let Some(frame) = mine.first().and_then(|f| f.frames) {
|
||||
newest.insert(frame[0], mine);
|
||||
}
|
||||
}
|
||||
newest.into_values().flatten().collect()
|
||||
}
|
||||
|
||||
/// Where `f` is in `files`, added at the end when it isn't yet: the one run's checks, each file once.
|
||||
fn file_index(files: &mut Vec<PathBuf>, f: &Path) -> usize {
|
||||
if let Some(at) = files.iter().position(|x| x == f) {
|
||||
|
||||
@@ -58,7 +58,7 @@ fn brief_of(path: Option<&str>) -> Result<Value, String> {
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let out = std::process::Command::new(exe).args(["spec", p, "--as", "brief"]).output().map_err(|e| e.to_string())?;
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
let start = text.find('{').ok_or_else(|| format!("judge: {p} didn't read as a brief: {}", String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("")))?;
|
||||
let start = text.find('{').ok_or_else(|| format!("judge: {p} didn't read as a brief: {}", why_refused(&out)))?;
|
||||
let v: Value = serde_json::from_str(&text[start..]).map_err(|e| format!("judge: {p}: {e}"))?;
|
||||
Ok(v.get("brief").cloned().unwrap_or(v))
|
||||
}
|
||||
@@ -226,3 +226,10 @@ fn finish(args: &[String], kind: Option<&str>, dir: &Path, scores: serde_json::M
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
/// Why `raea spec` refused a brief, in its own words: its refusal is the last line it printed, on whichever stream
|
||||
/// (a REFUSED line goes to stdout, a thrown module's error to stderr). Reading stderr alone left the reason empty.
|
||||
pub fn why_refused(out: &std::process::Output) -> String {
|
||||
let last = |b: &[u8]| String::from_utf8_lossy(b).lines().rev().find(|l| !l.trim().is_empty()).map(|l| l.trim().trim_start_matches("REFUSED").trim().to_string());
|
||||
last(&out.stderr).or_else(|| last(&out.stdout)).unwrap_or_else(|| "raea spec printed nothing".into())
|
||||
}
|
||||
@@ -11,6 +11,10 @@ description = "raea make: a scene, kit or shot held to its frozen plan; what's m
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
# the project's record of renders and checks, and the folder it lives in
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# the parts a render showed closer than their planned detail (MK24)
|
||||
raea-runtime-lod-plan = { path = "../../runtime/lod-plan" }
|
||||
# a cut job's gates: its client's brief as rules, held over the delivered files (MK25-MK27)
|
||||
raea-runtime-cut-plan = { path = "../../runtime/cut-plan" }
|
||||
# the judge's rounds, passes and blocking defects, read as it keeps them
|
||||
raea-app-judge = { path = "../judge" }
|
||||
# the make questions, their calibrations and a sheet's ident, as raea ask keeps them (MK4)
|
||||
|
||||
@@ -85,7 +85,7 @@ pub fn floor_svg(m: &Make) -> Result<String, String> {
|
||||
fd * px / 2.0
|
||||
);
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#111\" text-anchor=\"middle\">{}</text>", sx(at[0]), sy(at[2]) - t * 0.25, t, esc(&o.label));
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#555\" text-anchor=\"middle\">{:.2} m</text>", sx(at[0]), sy(at[2]) + t * 0.9, t * 0.8, height(o));
|
||||
s += &format!("<text x=\"{:.1}\" y=\"{:.1}\" font-size=\"{:.0}\" fill=\"#555\" text-anchor=\"middle\">{:.2} m{}</text>", sx(at[0]), sy(at[2]) + t * 0.9, t * 0.8, height(o), o.lod.map(|l| format!(", LOD {l}")).unwrap_or_default());
|
||||
}
|
||||
s += &format!("<line x1=\"20\" y1=\"{0}\" x2=\"{1:.1}\" y2=\"{0}\" stroke=\"#111\" stroke-width=\"5\"/><text x=\"20\" y=\"{2:.0}\" font-size=\"{3:.0}\" fill=\"#111\">1 m</text>", h - 18, 20.0 + px, h as f64 - 26.0, t * 0.9);
|
||||
s += "</svg>";
|
||||
@@ -102,8 +102,10 @@ pub fn blockout_tsx(m: &Make) -> String {
|
||||
let h = height(o);
|
||||
let colour = if o.source == Some(Origin::Invented) { "#b4b0bd" } else { "#bdbdb8" };
|
||||
let a = -o.rot.unwrap_or(0.0).to_radians() / 2.0;
|
||||
let lod = o.lod.map(|l| format!(" lod={{{l}}}")).unwrap_or_default();
|
||||
boxes += &format!(
|
||||
" <Mesh3d transform={{Transform.fromXyz({:.3}, {:.3}, {:.3}).withRotation([0, {:.5}, 0, {:.5}])}}>\n <Cuboid half_size={{[{:.3}, {:.3}, {:.3}]}} />\n <StandardMaterial base_color=\"{colour}\" perceptual_roughness={{0.9}} />\n </Mesh3d>\n",
|
||||
" <Mesh3d name=\"{}\"{lod} transform={{Transform.fromXyz({:.3}, {:.3}, {:.3}).withRotation([0, {:.5}, 0, {:.5}])}}>\n <Cuboid half_size={{[{:.3}, {:.3}, {:.3}]}} />\n <StandardMaterial base_color=\"{colour}\" perceptual_roughness={{0.9}} />\n </Mesh3d>\n",
|
||||
o.id,
|
||||
at[0],
|
||||
at[1] + h / 2.0,
|
||||
at[2],
|
||||
|
||||
@@ -58,7 +58,7 @@ pub fn read_make(brief: &Path) -> Result<Option<Make>, String> {
|
||||
let exe = std::env::current_exe().map_err(|e| e.to_string())?;
|
||||
let out = std::process::Command::new(exe).arg("spec").arg(brief).args(["--as", "brief"]).env("RAEA_RECORD", "off").output().map_err(|e| e.to_string())?;
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
let start = text.find('{').ok_or_else(|| format!("{} didn't read as a brief: {}", brief.display(), String::from_utf8_lossy(&out.stderr).lines().last().unwrap_or("")))?;
|
||||
let start = text.find('{').ok_or_else(|| format!("{} didn't read as a brief: {}", brief.display(), raea_app_judge::why_refused(&out)))?;
|
||||
let v: Value = serde_json::from_str(&text[start..]).map_err(|e| format!("{}: {e}", brief.display()))?;
|
||||
let b = v.get("brief").cloned().unwrap_or(v);
|
||||
match b.get("make") {
|
||||
@@ -88,7 +88,7 @@ pub fn status_of(brief: &Path, make: &Make) -> Value {
|
||||
let record = project.as_deref().map(raea_core_facts::record::read).unwrap_or_default();
|
||||
let (rounds, verdict, judged_at) = judged(dir);
|
||||
let ledger = asked::Ledger::read();
|
||||
let job = status::Job { make, dir, project: project.as_deref(), record: &record, rounds: &rounds, verdict: verdict.as_ref(), judged_at, ledger: &ledger, score_gates: raea_app_judge::kind_gates(status::kind_name(make.kind)) };
|
||||
let job = status::Job { make, dir, project: project.as_deref(), record: &record, rounds: &rounds, verdict: verdict.as_ref(), judged_at, ledger: &ledger, score_gates: raea_app_judge::kind_gates(make.kind.name()) };
|
||||
let mut s = status::status(&job);
|
||||
s["brief"] = Value::String(brief.display().to_string());
|
||||
s
|
||||
|
||||
+16
-12
@@ -59,14 +59,6 @@ pub fn sheets(job: &Job) -> Vec<(&'static str, PathBuf)> {
|
||||
out.into_iter().filter(|(_, f)| f.is_file()).collect()
|
||||
}
|
||||
|
||||
pub(crate) fn kind_name(k: make::Kind) -> &'static str {
|
||||
match k {
|
||||
make::Kind::Scene => "scene",
|
||||
make::Kind::Kit => "kit",
|
||||
make::Kind::Shot => "shot",
|
||||
}
|
||||
}
|
||||
|
||||
/// When a file last changed, and that as seconds since 1970 (a record entry's clock).
|
||||
fn mtime(p: &Path) -> Option<SystemTime> {
|
||||
std::fs::metadata(p).ok()?.modified().ok()
|
||||
@@ -136,15 +128,22 @@ fn checks(job: &Job) -> Vec<Value> {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// MK24: parts a composition's last render showed closer than planned, held until replanned or answered (raea-runtime-lod-plan)
|
||||
fn lods(job: &Job, notes: &str) -> Vec<Value> {
|
||||
let plans = job.make.objects.iter().any(|o| o.lod.is_some());
|
||||
let last = |c: &String| job.record.iter().rev().find(|e| e.of == job.project.map(|p| raea_core_facts::record::rel(p, &job.dir.join(c))).unwrap_or_else(|| c.clone()));
|
||||
job.make.compositions.iter().filter_map(|c| last(c).and_then(|l| raea_runtime_lod_plan::gate(c, &l.id, &l.findings, notes, plans)).map(|(clear, says)| gate("lod", Some(c), clear, says))).collect()
|
||||
}
|
||||
|
||||
/// Tier 3: a fresh critic has judged a round newer than the newest deliverable, and each blocking defect it named is
|
||||
/// fixed (the round passed) or answered in NOTES.md by its name. Its score gates once the judge is calibrated.
|
||||
fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {
|
||||
let Some(last) = job.rounds.last() else {
|
||||
let kind = kind_name(job.make.kind);
|
||||
let kind = job.make.kind.name();
|
||||
let what = match job.make.kind {
|
||||
make::Kind::Kit => "raea render shared/components/KIT/lineup.tsx --review review/r1",
|
||||
make::Kind::Shot => "raea make framing --out review/r1",
|
||||
make::Kind::Scene => "raea render EDIT.tsx --review review/r1",
|
||||
make::Kind::Scene | make::Kind::Cut => "raea render EDIT.tsx --review review/r1",
|
||||
};
|
||||
return vec![gate("critic", None, false, format!("no round yet: {what}, then raea judge review/r1 --kind {kind} --by claude --brief brief.ts"))];
|
||||
};
|
||||
@@ -156,7 +155,7 @@ fn critic(job: &Job, newest: Option<SystemTime>, notes: &str) -> Vec<Value> {
|
||||
};
|
||||
out.push(gate("critic", None, fresh, if fresh { format!("round {} judged after the newest deliverable", job.rounds.len()) } else { "the newest deliverable came after the last round: review and judge it again".into() }));
|
||||
// the kind's own rubric (MK5): a round judged on another's doesn't count
|
||||
let kind = kind_name(job.make.kind);
|
||||
let kind = job.make.kind.name();
|
||||
if last["kind"].as_str() != Some(kind) {
|
||||
let dir = last["dir"].as_str().unwrap_or("review/rN");
|
||||
out.push(gate("rubric", None, false, format!("the last round wasn't judged on the {kind} rubric: raea judge {dir} --kind {kind} --by claude")));
|
||||
@@ -188,7 +187,12 @@ pub fn status(job: &Job) -> Value {
|
||||
missing.push(format!("NOTES.md with a \"{SKILL_HEADING}\" section (one line per thing that cost time; what the guide got wrong for this job)"));
|
||||
}
|
||||
let mut gates = checks(job);
|
||||
gates.extend(critic(job, newest, ¬es));
|
||||
gates.extend(lods(job, ¬es));
|
||||
match (&job.make.cut, job.make.kind) {
|
||||
// a cut job: its brief's rules over every delivered file (MK25-MK27), and the person's review its critic
|
||||
(Some(c), make::Kind::Cut) => gates.extend(raea_runtime_cut_plan::gates(c, job.dir).into_iter().map(|g| gate(g.name, g.of.as_deref(), g.clear, g.says))),
|
||||
_ => gates.extend(critic(job, newest, ¬es)),
|
||||
}
|
||||
let (asks, said) = crate::asked::gates(&sheets(job), job.ledger, ¬es);
|
||||
gates.extend(asks);
|
||||
let cap = job.make.rounds.unwrap_or(make::ROUNDS) as usize;
|
||||
|
||||
@@ -134,6 +134,22 @@ fn a_composition_needs_a_clean_check_newer_than_it() {
|
||||
assert!(s["gates"].to_string().contains("changed since"), "{s:#}");
|
||||
}
|
||||
|
||||
// MK24: a part a render showed closer than planned holds the job until it's replanned or answered in the notes
|
||||
#[test]
|
||||
fn a_part_seen_closer_than_planned_holds_the_job() {
|
||||
let d = dir("lod");
|
||||
delivered(&d);
|
||||
put(&d, "scene.tsx", "x");
|
||||
let mut make = kit();
|
||||
make.compositions = vec!["scene.tsx".into()];
|
||||
let future = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs() + 60;
|
||||
let entry: Entry = serde_json::from_value(json!({"id": "r1", "at": future, "by": "raea render", "of": "scene.tsx", "findings": [{"check": "lod-closer", "level": "warn", "about": [{"name": "kiosk"}], "says": "'kiosk' is planned at LOD 3", "by": "raea render"}]})).unwrap();
|
||||
let s = run(&make, &d, &[entry.clone()], &[round(true, 7.5, json!([]))], later());
|
||||
assert!(s["done"] == false && s["gates"].to_string().contains("seen closer than planned at r1: kiosk"), "{s:#}");
|
||||
put(&d, "NOTES.md", "- lod kiosk: one frame at the cut, left as a box\n## What the skill got wrong\n- nothing\n");
|
||||
assert_eq!(run(&make, &d, &[entry], &[round(true, 7.5, json!([]))], later())["done"], true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_scene_wants_three_stills() {
|
||||
let d = dir("scene");
|
||||
|
||||
@@ -156,7 +156,7 @@ fn a_shot_frames_its_start_middle_and_end() {
|
||||
fn the_plan_draws_a_floor_plan_and_a_blockout() {
|
||||
let m: Make = read("make", r#"{"kind": "scene", "references": ["media/ref.png"], "objects": [
|
||||
{"id": "desk", "label": "Desk", "dims": [1.6, 0.8, 0.75], "at": [2, 0, 3], "rot": 90, "source": "reference", "hero": true},
|
||||
{"id": "plant", "label": "Plant", "h": 1.2, "at": [0.5, 0, 4], "source": "invented"},
|
||||
{"id": "plant", "label": "Plant", "h": 1.2, "at": [0.5, 0, 4], "source": "invented", "lod": 3},
|
||||
{"id": "pen", "label": "Pen", "max": 0.14}]}"#)
|
||||
.unwrap();
|
||||
let (placed, b) = crate::floor::extent(&m);
|
||||
@@ -172,6 +172,7 @@ fn the_plan_draws_a_floor_plan_and_a_blockout() {
|
||||
let t = crate::floor::blockout_tsx(&m);
|
||||
assert_eq!(t.matches("<Cuboid").count(), 3, "the floor and two boxes");
|
||||
assert!(t.contains("half_size={[0.800, 0.375, 0.400]}"), "{t}");
|
||||
assert!(t.contains("<Mesh3d name=\"plant\" lod={3} transform=") && svg.contains("1.20 m, LOD 3<"), "MK22, each box named with its planned detail: {t}");
|
||||
let none: Make = read("make", r#"{"kind": "scene", "objects": [{"id": "pen", "label": "Pen"}]}"#).unwrap();
|
||||
assert!(crate::floor::floor_svg(&none).unwrap_err().contains("no object has an `at`"));
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "raea scene lint|explain|light|stage: a composition's frames stepped without drawing and held to the contact, light and stage checks"
|
||||
description = "raea scene lint|explain|light|stage|lod: a composition's frames stepped without drawing and held to the contact, light and stage checks"
|
||||
|
||||
[dependencies]
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
@@ -12,6 +12,8 @@ raea-runtime-export = { path = "../../runtime/export" }
|
||||
raea-sys-contact = { path = "../../systems/contact" }
|
||||
raea-sys-light-meter = { path = "../../systems/light-meter" }
|
||||
raea-sys-stage = { path = "../../systems/stage" }
|
||||
# each part's planned detail beside how large the frames show it (MK21, MK23)
|
||||
raea-runtime-lod-plan = { path = "../../runtime/lod-plan" }
|
||||
# its results as Findings (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# camera clearance (MK16): the parts, their models' triangles, and the camera's point in space
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//! `raea scene lint|explain|light|stage`: a composition's frames stepped without drawing and handed to raea-sys-contact
|
||||
//! `raea scene lint|explain|light|stage|lod`: a composition's frames stepped without drawing and handed to raea-sys-contact
|
||||
//! (what each part rests on, and parts that clip), raea-sys-light-meter (the light on a subject) and raea-sys-stage (3D
|
||||
//! type that can't be read, parts that snap, a camera that lurches, empty frames: docs/stage-guards.feature).
|
||||
//! type that can't be read, parts that snap, a camera that lurches, empty frames: docs/stage-guards.feature). `lod` is
|
||||
//! each part's planned detail beside how large the frames show it (docs/make.feature MK23).
|
||||
|
||||
use serde_json::json;
|
||||
|
||||
@@ -10,9 +11,11 @@ use raea_runtime_export::{frame_of, items};
|
||||
// how near the camera passes to each solid part, every frame (`--clearance M`, MK16)
|
||||
pub mod clearance;
|
||||
mod light;
|
||||
// each part's planned detail beside how large the frames show it (MK23)
|
||||
pub mod lod;
|
||||
mod stage;
|
||||
|
||||
pub const USAGE: &str = "raea scene lint|explain|light|stage EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json]";
|
||||
pub const USAGE: &str = "raea scene lint|explain|light|stage|lod EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json]";
|
||||
|
||||
/// `raea scene lint|explain EDIT.tsx [--composition ID] [--frame N] [--json]`: the frame's parts measured
|
||||
/// (frame 0 by default). `lint` says the faults (errors fail it: floating, sunk, clipping; warnings: in the air,
|
||||
@@ -24,6 +27,7 @@ pub fn cli(args: &[String]) -> Result<String, String> {
|
||||
match mode {
|
||||
"light" => return light::cli(args),
|
||||
"stage" => return stage::cli(args),
|
||||
"lod" => return lod::cli(args),
|
||||
"lint" | "explain" => {}
|
||||
_ => return Err(usage.into()),
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
//! `raea scene lod EDIT.tsx [--composition ID] [--from N] [--to N] [--json]` (docs/make.feature MK23): every part's
|
||||
//! planned detail beside how large the frames show it. A part's plan is its own `lod` (0 the hero to 4 far), else its
|
||||
//! name's on the job's plan (`lod` on brief.ts's make objects); what a frame shows is how much of it the part's box
|
||||
//! spans (raea-runtime-lod-plan). The table lists the planned parts first, the ones seen closer than planned on top,
|
||||
//! then the parts nobody planned by how large they get, so a part forgotten since the plan was written is found by
|
||||
//! reading down it. A part seen two or more levels finer than planned fails it, as it fails a render.
|
||||
|
||||
use raea_core_facts::{Finding, Level, finding};
|
||||
use raea_runtime_lod_plan::{ordered, table};
|
||||
use serde_json::json;
|
||||
|
||||
pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let crate::stage::Stepped { items, nums, size: (w, h, fps), dir } = crate::stage::stepped(args, "raea scene lod EDIT.tsx [--composition ID] [--from N] [--to N] [--json]")?;
|
||||
let (first, last) = (nums[0], nums[nums.len() - 1]);
|
||||
let plan = raea_runtime_lod_plan::plan::lods(&dir);
|
||||
let mut unseen: Vec<String> = plan.keys().cloned().collect();
|
||||
let (seen, fs) = raea_runtime_lod_plan::lods(&items, &nums, w, h, fps, "raea scene lod", plan);
|
||||
let seen = ordered(seen);
|
||||
// a level the plan gives a name no part in these frames goes by holds nothing: said, so the part gets its name
|
||||
unseen.retain(|n| !seen.iter().any(|s| s.planned.is_some() && (s.name == *n || s.name.starts_with(&format!("{n} (lod ")))));
|
||||
unseen.sort();
|
||||
let text = if args.iter().any(|a| a == "--json") {
|
||||
let parts: Vec<_> = seen.iter().map(|s| json!({"part": s.name, "planned": s.planned, "seen": s.level(), "largest": s.finest.map(|f| f.1), "at": s.finest.map(|f| f.0), "frames": s.frames, "closer": s.closer})).collect();
|
||||
serde_json::to_string_pretty(&json!({"frames": [first, last], "parts": parts, "unseen": unseen, "findings": fs})).unwrap_or_default()
|
||||
} else {
|
||||
let levels = "levels, by how much of the frame a part spans: 0 hero 50%+, 1 featured 20%+, 2 dressing 8%+, 3 background 2%+, 4 far";
|
||||
let none = seen.iter().filter(|s| s.planned.is_none()).count();
|
||||
let missing = (!unseen.is_empty()).then(|| format!("planned in brief.ts, but no part of that name is in these frames (name the part as its object's id, or its plan holds nothing): {}", unseen.join(", ")));
|
||||
let sum = format!("frames {first} to {last}: {} parts, {none} with no plan; {}", seen.len(), finding::count(&fs));
|
||||
table(&seen).into_iter().chain(fs.iter().map(Finding::line)).chain(missing).chain([levels.to_string(), sum]).collect::<Vec<_>>().join("\n")
|
||||
};
|
||||
if fs.iter().any(|f| f.level == Level::Error) {
|
||||
println!("{text}");
|
||||
std::process::exit(1);
|
||||
}
|
||||
Ok(text)
|
||||
}
|
||||
+23
-6
@@ -1,7 +1,7 @@
|
||||
//! `raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--json]`: every frame's scene stepped without
|
||||
//! drawing and held to the stage checks a render runs at its end (raea-sys-stage, docs/stage-guards.feature SG10-SG14):
|
||||
//! 3D type that can't be read, parts that snap, a camera that lurches or reverses, frames with nothing composed in
|
||||
//! them. Errors fail it, as they fail a render, so it's the cheap look before one. It lays out no page, so what the
|
||||
//! them, a part shown closer than its planned detail (MK21). Errors fail it, as they fail a render, so it's the cheap look before one. It lays out no page, so what the
|
||||
//! page holds waits for a render: its words over the parts (type-over-part), a Label's part as the shot's subject, and
|
||||
//! a frame its words or pictures fill, which reads empty here and is said as a warning, not failed (SG11).
|
||||
//! `--clearance M` holds the camera M metres off every solid part on every frame (0.45 for a carried camera, MK16).
|
||||
@@ -12,8 +12,16 @@ use raea_core_facts::{Level, finding};
|
||||
use raea_runtime_bundle::{bundle_composition, comp_opts, flag};
|
||||
use raea_runtime_export::{all_items, scene_frames_to};
|
||||
|
||||
pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let usage = "raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--clearance M] [--json]";
|
||||
/// A composition's frames stepped without drawing, for `stage` and `lod`: each frame's parts from --from to --to (every
|
||||
/// frame before is still stepped), their numbers, the frame's size and rate, and the composition's folder.
|
||||
pub(crate) struct Stepped {
|
||||
pub items: Vec<Vec<raea_core_scene::Item>>,
|
||||
pub nums: Vec<i64>,
|
||||
pub size: (u32, u32, f64),
|
||||
pub dir: std::path::PathBuf,
|
||||
}
|
||||
|
||||
pub(crate) fn stepped(args: &[String], usage: &str) -> Result<Stepped, String> {
|
||||
let Some(edit) = args.get(2) else { return Err(usage.into()) };
|
||||
let tsx = dunce::canonicalize(&std::path::PathBuf::from(edit)).map_err(|e| format!("{edit}: {e}"))?;
|
||||
let dir = tsx.parent().unwrap().to_path_buf();
|
||||
@@ -25,10 +33,19 @@ pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let _ = std::fs::remove_file(&js);
|
||||
let (frames, w, h, fps) = got?.ok_or("the composition has no 3D")?;
|
||||
let frames: Vec<_> = frames.into_iter().filter(|(f, _)| *f >= from && to.is_none_or(|t| *f <= t)).collect();
|
||||
let (Some(first), Some(last)) = (frames.first().map(|f| f.0), frames.last().map(|f| f.0)) else { return Err(format!("no frames from {from}")) };
|
||||
let nums: Vec<i64> = frames.iter().map(|(f, _)| *f).collect();
|
||||
let items = all_items(&frames);
|
||||
if frames.is_empty() {
|
||||
return Err(format!("no frames from {from}"));
|
||||
}
|
||||
Ok(Stepped { nums: frames.iter().map(|(f, _)| *f).collect(), items: all_items(&frames), size: (w, h, fps), dir })
|
||||
}
|
||||
|
||||
pub(crate) fn cli(args: &[String]) -> Result<String, String> {
|
||||
let Stepped { items, nums, size: (w, h, fps), dir } = stepped(args, "raea scene stage EDIT.tsx [--composition ID] [--from N] [--to N] [--clearance M] [--json]")?;
|
||||
let (first, last) = (nums[0], nums[nums.len() - 1]);
|
||||
let mut fs = raea_sys_stage::check(&items, &nums, w, h, fps, "raea scene stage");
|
||||
// and each part held to its planned detail (its own `lod`, or its name's on the plan above it: MK21), as a render does
|
||||
fs.extend(raea_runtime_lod_plan::lods(&items, &nums, w, h, fps, "raea scene stage", raea_runtime_lod_plan::plan::lods(&dir)).1.into_iter().filter(|f| f.check == "lod-closer"));
|
||||
fs = raea_core_facts::finding::ranked(fs);
|
||||
// the camera held off every solid part, when asked: the number after the flag, else a carried camera's 0.45 m
|
||||
if let Some(v) = flag(args, "--clearance") {
|
||||
let min = v.parse::<f32>().ok().filter(|m| *m >= 0.0).ok_or_else(|| format!("--clearance takes metres (0.45 for a carried camera), got {v:?}"))?;
|
||||
|
||||
@@ -12,6 +12,7 @@ path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
# Pocket TTS and its word clock
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
raea-sys-speech = { path = "../../systems/speech" }
|
||||
# ort sessions the way raea builds them, and the model cache
|
||||
raea-sys-ml = { path = "../../systems/ml" }
|
||||
|
||||
@@ -108,7 +108,7 @@ pub fn microphone(tx: Sender<Vec<f32>>) -> anyhow::Result<cpal::Stream> {
|
||||
rs.push(&mono, &mut out);
|
||||
let _ = tx.send(out);
|
||||
};
|
||||
let bad = |e| eprintln!("raea voice: the microphone: {e}");
|
||||
let bad = raea_io_trace::once::said_once::<cpal::StreamError>("raea voice: the microphone");
|
||||
let stream = match cfg.sample_format() {
|
||||
cpal::SampleFormat::F32 => {
|
||||
dev.build_input_stream(&cfg.config(), move |d: &[f32], _: &cpal::InputCallbackInfo| take(mono(d, ch)), bad, None)
|
||||
@@ -242,7 +242,7 @@ impl Speaker {
|
||||
f.fill(ready.pop_front().unwrap_or(0.0));
|
||||
}
|
||||
};
|
||||
let stream = dev.build_output_stream(&cfg.config(), play, |e| eprintln!("raea voice: the speakers: {e}"), None).map_err(|e| anyhow!("the speakers didn't open: {e}"))?;
|
||||
let stream = dev.build_output_stream(&cfg.config(), play, raea_io_trace::once::said_once::<cpal::StreamError>("raea voice: the speakers"), None).map_err(|e| anyhow!("the speakers didn't open: {e}"))?;
|
||||
stream.play().map_err(|e| anyhow!("the speakers didn't start: {e}"))?;
|
||||
Ok(Speaker { line, rate, to, _stream: Some(stream) })
|
||||
}
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
# Two paint bugs, each held to what Chrome draws. Exits 1 on a failure.
|
||||
# #241 z.html: a stacking context's z-index: -1 child goes under its text. White pixels (the word) must be there:
|
||||
# before the fix the box covered the word and the frame had none.
|
||||
# #240 miter.html: a stroked rounded rect under a negative viewBox origin. Nothing blue left of the outline (x 0-60,
|
||||
# y 84-130: the outline starts at x 92), and the outline's top-left corner is round (dark at its square corner).
|
||||
# bench/paint-order/check.sh (RAEA_BIN: the raea to run, default target/release/raea)
|
||||
cd "$(dirname "$0")/../.." || exit 2
|
||||
BIN=${RAEA_BIN:-$PWD/target/release/raea}
|
||||
export RAEA_SIGN=0 RAEA_MARK=0 RAEA_EXPORT_CACHE=0
|
||||
OUT=$(mktemp -d "${TMPDIR:-/tmp}/raea-paint-order.XXXXXX")
|
||||
trap 'rm -rf "${OUT:?}"' EXIT
|
||||
status=0
|
||||
for p in z miter; do
|
||||
"$BIN" render "bench/paint-order/$p.html" -o "$OUT/$p.png" > "$OUT/$p.log" 2>&1 || { echo "FAIL render $p (log below)"; sed 's/^/ /' "$OUT/$p.log"; exit 1; }
|
||||
done
|
||||
# how many pixels of a region are near a colour
|
||||
count() { magick "$OUT/$1.png" -alpha off -crop "$2" +repage -fuzz "${4:-6}%" -fill black +opaque "$3" -fill white -opaque "$3" -colorspace Gray -format "%[fx:int(mean*w*h+0.5)]" info:; }
|
||||
white=$(count z 600x300+0+0 "#ffffff")
|
||||
(( white > 2000 )) || { echo "FAIL #241: $white white pixels, the word is under its z-index: -1 child"; status=1; }
|
||||
box=$(count z 600x300+0+0 "#10203C" 3)
|
||||
(( box > 3000 )) || { echo "FAIL #241: $box pixels of the box behind the word"; status=1; }
|
||||
bar=$(count miter 60x46+0+84 "#3c82f0")
|
||||
(( bar == 0 )) || { echo "FAIL #240: $bar blue pixels left of the outline (the miter join's bar)"; status=1; }
|
||||
corner=$(count miter 6x6+91+99 "#3c82f0")
|
||||
(( corner == 0 )) || { echo "FAIL #240: the outline's top-left corner is square ($corner blue pixels at its corner)"; status=1; }
|
||||
edge=$(count miter 200x6+400+97 "#3c82f0")
|
||||
(( edge > 300 )) || { echo "FAIL #240: the outline's top edge isn't drawn ($edge pixels)"; status=1; }
|
||||
[ $status = 0 ] && echo "PASS paint order: #241 text over a negative z-index child, #240 a miter join after an arc"
|
||||
exit $status
|
||||
@@ -0,0 +1,7 @@
|
||||
<!doctype html>
|
||||
<!-- #240: a thin rounded outline, nothing left of it (896 wide under a viewBox that starts at -20 drew a bar from x=0) -->
|
||||
<html><body style="margin:0;background:#111">
|
||||
<div data-composition-id="main" data-start="0" data-duration="1" data-width="1080" data-height="600" style="position:relative;width:1080px;height:600px;background:#111">
|
||||
<svg width="936" height="440" viewBox="-20 -20 936 440" style="position:absolute;left:72px;top:80px"><rect x="0" y="0" width="896" height="400" rx="24" fill="none" stroke="#3c82f0" stroke-width="3"/></svg>
|
||||
</div>
|
||||
</body></html>
|
||||
@@ -0,0 +1,7 @@
|
||||
<!doctype html>
|
||||
<!-- #241: white "Hollow" over a blue box that is its own z-index: -1 child -->
|
||||
<html><body style="margin:0;background:#111">
|
||||
<div data-composition-id="main" data-start="0" data-duration="1" data-width="600" data-height="300" style="position:relative;width:600px;height:300px;background:#111;display:flex;align-items:center;justify-content:center">
|
||||
<span style="position:relative;display:inline-block;z-index:1;color:#fff;font:700 80px sans-serif"><div style="position:absolute;inset:0;z-index:-1;background:#10203C;border:3px solid #3474D6"></div>Hollow</span>
|
||||
</div>
|
||||
</body></html>
|
||||
@@ -0,0 +1,235 @@
|
||||
//! A cut job's contract (docs/make.feature MK25): `make: cut({...})` on brief.ts, the client's brief made into rules
|
||||
//! before anything is planned or cut. A brief read as context gets lost (11-25, Shane, on StreetTalk's street interview
|
||||
//! ads: "you need to make the process of ingesting the brief more direct, or else it's just context that gets lost. It
|
||||
//! needs to be written as a brief typescript rule that is then enforced"). Every rule quotes the brief line it came
|
||||
//! from (`from`), and `raea make status` (apps/make cut.rs) finds each quote in the brief's text, so a rule can't be
|
||||
//! invented and a brief line can't drift; then it holds every delivered file to the rules, from what's on disk.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakeCut")]
|
||||
pub struct Cut {
|
||||
/// the brief as text, relative to brief.ts (`pdftotext -layout brief.pdf media/brief.txt`): every `from` is found in it
|
||||
pub brief: String,
|
||||
/// how many cuts the brief asks for; fewer planned is held open until an answered `open` item about "count" says why
|
||||
pub count: Option<Quoted<u32>>,
|
||||
/// a cut's length when its own `seconds` says none: [least, most]
|
||||
pub seconds: Option<[f64; 2]>,
|
||||
/// the formats every cut is delivered in when its own `formats` says none: "9:16", "16:9", "1:1", "4:5"
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
pub formats: Vec<String>,
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<CutPlan>>", optional)]
|
||||
pub cuts: Vec<CutPlan>,
|
||||
/// what is said or shown: in every cut unless `every: false` (then in one or more)
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Phrase>>", optional)]
|
||||
pub say: Vec<Phrase>,
|
||||
/// what no cut says or shows: a banned claim, a word, a name
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Phrase>>", optional)]
|
||||
pub never: Vec<Phrase>,
|
||||
/// the line every cut ends on, heard or on screen in its last `within` seconds
|
||||
pub cta: Option<Cta>,
|
||||
/// the brief's open items ([TO CONFIRM]): each holds the job open until it has an answer
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<Open>>", optional)]
|
||||
pub open: Vec<Open>,
|
||||
/// every face whole and every text big enough, by the frames check of each file (true when left out)
|
||||
pub frames: Option<bool>,
|
||||
}
|
||||
|
||||
/// A value with the brief's words for it.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
#[ts(rename = "MakeQuoted")]
|
||||
pub struct Quoted<T: TS> {
|
||||
pub value: T,
|
||||
/// the brief's own words, as they are in its text
|
||||
pub from: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakeCutPlan")]
|
||||
pub struct CutPlan {
|
||||
/// [a-z0-9_], unique: each format lands as out/cuts/<id>_<W>x<H>.mp4 ("a1_s1_9x16.mp4")
|
||||
pub id: String,
|
||||
pub angle: Option<String>,
|
||||
/// solo or mashup
|
||||
pub kind: Option<String>,
|
||||
/// one of the brief's hook types ("Direct Problem", "Reaction")
|
||||
pub hook: Option<String>,
|
||||
/// captions, hook (a text hook) or none
|
||||
pub text: Option<String>,
|
||||
#[serde(default)]
|
||||
#[ts(as = "Option<Vec<String>>", optional)]
|
||||
pub formats: Vec<String>,
|
||||
pub seconds: Option<[f64; 2]>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakePhrase")]
|
||||
pub struct Phrase {
|
||||
/// as it's said or shown; compared in lower case, by letters and digits ("24/7" and "24-7" are the same)
|
||||
pub text: String,
|
||||
pub from: String,
|
||||
/// `say` only: false when one cut saying it is enough
|
||||
pub every: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakeCta")]
|
||||
pub struct Cta {
|
||||
pub text: String,
|
||||
pub from: String,
|
||||
/// how near the end it must land, in seconds (8 when left out)
|
||||
pub within: Option<f64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
#[serde(rename_all = "camelCase", deny_unknown_fields)]
|
||||
#[ts(optional_fields)]
|
||||
#[ts(rename = "MakeOpen")]
|
||||
pub struct Open {
|
||||
pub question: String,
|
||||
pub from: String,
|
||||
/// what it decides: "count", "cta", "offer", a cut's id...
|
||||
pub about: Option<String>,
|
||||
/// the person's answer, as they gave it, and who gave it: until then the job can't be done
|
||||
pub answer: Option<String>,
|
||||
pub by: Option<String>,
|
||||
}
|
||||
|
||||
/// How near the end the CTA lands when the contract says nothing.
|
||||
pub const CTA_WITHIN: f64 = 8.0;
|
||||
|
||||
/// A format's frame shape, "9:16" -> (9, 16).
|
||||
pub fn ratio(f: &str) -> Option<(u32, u32)> {
|
||||
let (w, h) = f.split_once(':')?;
|
||||
Some((w.trim().parse().ok().filter(|&w| w > 0)?, h.trim().parse().ok().filter(|&h| h > 0)?))
|
||||
}
|
||||
|
||||
/// A cut's formats and its length: its own, else the contract's.
|
||||
pub fn formats<'a>(c: &'a Cut, p: &'a CutPlan) -> &'a [String] {
|
||||
if p.formats.is_empty() { &c.formats } else { &p.formats }
|
||||
}
|
||||
pub fn seconds(c: &Cut, p: &CutPlan) -> Option<[f64; 2]> {
|
||||
p.seconds.or(c.seconds)
|
||||
}
|
||||
|
||||
/// Where a cut's format lands, relative to the brief: out/cuts/a1_s1_9x16.mp4.
|
||||
pub fn file(p: &CutPlan, format: &str) -> String {
|
||||
format!("out/cuts/{}_{}.mp4", p.id, format.replace(':', "x"))
|
||||
}
|
||||
|
||||
/// Every file the contract asks for.
|
||||
pub fn deliverables(c: &Cut) -> Vec<String> {
|
||||
c.cuts.iter().flat_map(|p| formats(c, p).iter().map(move |f| file(p, f))).collect()
|
||||
}
|
||||
|
||||
/// Every `from` in the contract, with what it backs: the quotes `raea make status` finds in the brief's text.
|
||||
pub fn quotes(c: &Cut) -> Vec<(String, &str)> {
|
||||
let mut q: Vec<(String, &str)> = Vec::new();
|
||||
if let Some(n) = &c.count {
|
||||
q.push(("count".into(), &n.from));
|
||||
}
|
||||
for (what, list) in [("say", &c.say), ("never", &c.never)] {
|
||||
for p in list {
|
||||
q.push((format!("{what} \"{}\"", p.text), &p.from));
|
||||
}
|
||||
}
|
||||
if let Some(cta) = &c.cta {
|
||||
q.push(("cta".into(), &cta.from));
|
||||
}
|
||||
for o in &c.open {
|
||||
q.push((format!("open \"{}\"", o.question), &o.from));
|
||||
}
|
||||
q
|
||||
}
|
||||
|
||||
/// What the contract lacks before it can be cut against, each with what to do.
|
||||
pub fn doctor(c: &Cut) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
if c.brief.trim().is_empty() {
|
||||
out.push("no `brief`: the brief as text beside brief.ts (pdftotext -layout BRIEF.pdf media/brief.txt), which every `from` quotes".into());
|
||||
}
|
||||
if c.cuts.is_empty() {
|
||||
out.push("no cuts: list every cut the brief asks for, with its id, angle, hook and formats".into());
|
||||
}
|
||||
if c.count.is_none() {
|
||||
out.push("no `count`: how many cuts the brief asks for, with its words".into());
|
||||
}
|
||||
if c.cta.is_none() {
|
||||
out.push("no `cta`: the line the brief says every cut ends on (or an `open` item asking for it)".into());
|
||||
}
|
||||
let mut seen = std::collections::BTreeSet::new();
|
||||
for p in &c.cuts {
|
||||
if !seen.insert(p.id.as_str()) {
|
||||
out.push(format!("cut `{}` is listed twice", p.id));
|
||||
}
|
||||
if !crate::make::is_name(&p.id) {
|
||||
out.push(format!("cut `{}`: ids are [a-z0-9_], the file it lands as", p.id));
|
||||
}
|
||||
let fs = formats(c, p);
|
||||
if fs.is_empty() {
|
||||
out.push(format!("cut `{}` has no formats: give it `formats`, or the contract's", p.id));
|
||||
}
|
||||
for f in fs.iter().filter(|f| ratio(f).is_none()) {
|
||||
out.push(format!("cut `{}`: format `{f}` isn't W:H (\"9:16\", \"16:9\", \"1:1\", \"4:5\")", p.id));
|
||||
}
|
||||
match seconds(c, p) {
|
||||
None => out.push(format!("cut `{}` has no length: `seconds: [least, most]`, its own or the contract's", p.id)),
|
||||
Some([a, b]) if !(a > 0.0 && a <= b) => out.push(format!("cut `{}`: seconds [{a}, {b}] isn't [least, most]", p.id)),
|
||||
_ => {}
|
||||
}
|
||||
if let Some(t) = &p.text
|
||||
&& !matches!(t.as_str(), "captions" | "hook" | "none")
|
||||
{
|
||||
out.push(format!("cut `{}`: text is captions, hook or none, not `{t}`", p.id));
|
||||
}
|
||||
}
|
||||
for (what, from) in quotes(c) {
|
||||
if from.trim().is_empty() {
|
||||
out.push(format!("{what} has no `from`: the brief's own words for it"));
|
||||
}
|
||||
}
|
||||
for p in c.say.iter().chain(&c.never) {
|
||||
if norm(&p.text).is_empty() {
|
||||
out.push(format!("phrase `{}` has no letters or digits to find", p.text));
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Text as it's compared: lower case, letters and digits, one space between words ("24/7" -> "24 7").
|
||||
pub fn norm(s: &str) -> String {
|
||||
let mut out = String::with_capacity(s.len());
|
||||
let mut gap = false;
|
||||
for ch in s.chars().flat_map(char::to_lowercase) {
|
||||
// a curly apostrophe or a plain one joins its word ("it's" is one word, "its" is another)
|
||||
if ch == '\'' || ch == '\u{2019}' {
|
||||
continue;
|
||||
}
|
||||
if ch.is_alphanumeric() {
|
||||
if gap && !out.is_empty() {
|
||||
out.push(' ');
|
||||
}
|
||||
gap = false;
|
||||
out.push(ch);
|
||||
} else {
|
||||
gap = true;
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
//! types (`declarations`), so what tsc checks is exactly what this crate reads.
|
||||
|
||||
pub mod brief;
|
||||
pub mod cut;
|
||||
pub mod make;
|
||||
pub mod parts;
|
||||
pub mod script;
|
||||
@@ -39,6 +40,7 @@ pub fn declarations() -> String {
|
||||
taste::Taste, taste::TasteSection, taste::Rule, taste::RuleCheck, taste::RuleLevel, taste::Check,
|
||||
parts::Parts, parts::Concept, parts::Level, parts::Count, parts::Part,
|
||||
make::Make, make::Kind, make::Source, make::DialValue, make::Dial, make::Route, make::Origin, make::Pick, make::Object, make::Shot,
|
||||
cut::Cut, cut::Quoted<u32>, cut::CutPlan, cut::Phrase, cut::Cta, cut::Open,
|
||||
));
|
||||
out.join("\n\n") + "\n"
|
||||
}
|
||||
|
||||
+33
-1
@@ -19,6 +19,8 @@ pub enum Kind {
|
||||
Kit,
|
||||
/// stills or camera moves of a built scene, from words
|
||||
Shot,
|
||||
/// ads cut from footage to a client's brief: its deliverables, phrases, claims and CTA as rules (cut.rs, MK25)
|
||||
Cut,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)]
|
||||
@@ -52,6 +54,8 @@ pub struct Make {
|
||||
pub deliverables: Vec<String>,
|
||||
/// the most critic rounds the job gets; at the cap it is delivered with what's still missing (8 by default)
|
||||
pub rounds: Option<u32>,
|
||||
/// a cut job's contract: the brief as rules (cut.rs)
|
||||
pub cut: Option<crate::cut::Cut>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, TS)]
|
||||
@@ -150,6 +154,10 @@ pub struct Object {
|
||||
pub at: Option<[f64; 3]>,
|
||||
pub rot: Option<f64>,
|
||||
pub hero: Option<bool>,
|
||||
/// how large it is planned to be seen, which is how much of it gets built: 0 the hero (half the frame or more),
|
||||
/// 1 featured (under 50%), 2 dressing (under 20%), 3 background (under 8%: a grey box reads), 4 far (under 2%: a
|
||||
/// silhouette). A render that shows it finer than this says so (`lod-closer`; `raea scene lod` lists every part)
|
||||
pub lod: Option<u8>,
|
||||
pub pick: Option<Pick>,
|
||||
/// what was fixed by script ("glass made transmissive, label kept opaque")
|
||||
#[serde(default)]
|
||||
@@ -182,12 +190,21 @@ pub struct Shot {
|
||||
pub fps: Option<f64>,
|
||||
}
|
||||
|
||||
impl Kind {
|
||||
/// as brief.ts writes it, and as raea judge's rubrics are named
|
||||
pub fn name(self) -> &'static str {
|
||||
// in the enum's order
|
||||
["scene", "kit", "shot", "cut"][self as usize]
|
||||
}
|
||||
}
|
||||
|
||||
/// Each kind's dials: what may be set, and what an unset one is read from the references as.
|
||||
pub fn dials(kind: Kind) -> &'static [&'static str] {
|
||||
match kind {
|
||||
Kind::Scene => &["density", "tidiness", "wear", "wetness", "time_of_day", "weather", "atmosphere", "power", "warmth", "look"],
|
||||
Kind::Kit => &["count", "variety", "detail", "wear", "wetness", "warmth", "look"],
|
||||
Kind::Shot => &["res", "seconds", "lens", "handheld", "look"],
|
||||
Kind::Cut => &["look"],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,9 +231,15 @@ pub fn deliverables(m: &Make) -> Vec<String> {
|
||||
}
|
||||
// a shot is a still or a move, so either file answers; apps/make reads `a|b`
|
||||
Kind::Shot => m.shots.iter().map(|s| format!("out/shots/{0}.png|out/shots/{0}.mp4", s.name)).collect(),
|
||||
Kind::Cut => m.cut.as_ref().map(crate::cut::deliverables).unwrap_or_default(),
|
||||
}
|
||||
}
|
||||
|
||||
/// A name a file lands as: [a-z0-9_], not empty.
|
||||
pub fn is_name(s: &str) -> bool {
|
||||
!s.is_empty() && s.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_')
|
||||
}
|
||||
|
||||
/// What the plan still lacks before it can be built against, each with what to do. Empty when it's ready.
|
||||
pub fn doctor(m: &Make) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
@@ -229,6 +252,12 @@ pub fn doctor(m: &Make) -> Vec<String> {
|
||||
Kind::Scene | Kind::Kit if m.objects.is_empty() => out.push("no objects: list every object with its real size and route".into()),
|
||||
_ => {}
|
||||
}
|
||||
match (&m.cut, m.kind) {
|
||||
(Some(c), Kind::Cut) => out.extend(crate::cut::doctor(c)),
|
||||
(None, Kind::Cut) => out.push("no `cut`: the brief as rules (count, cuts, say, never, cta, open), each quoting it".into()),
|
||||
(Some(_), k) => out.push(format!("`cut` is for a cut job, not a {k:?}: drop it, or make this `cut({{...}})`")),
|
||||
_ => {}
|
||||
}
|
||||
if m.kind == Kind::Kit && m.style.is_none() {
|
||||
out.push("no `style`: one paragraph (era, palette, materials, wear, one fictional maker) every reference carries".into());
|
||||
}
|
||||
@@ -240,6 +269,9 @@ pub fn doctor(m: &Make) -> Vec<String> {
|
||||
if o.h.is_none() && o.dims.is_none() && o.max.is_none() {
|
||||
out.push(format!("object `{}` has no size: give `h` (metres), `dims` for boxy things or `max` for flat ones", o.id));
|
||||
}
|
||||
if o.lod.is_some_and(|l| l > 4) {
|
||||
out.push(format!("object `{}` has lod {}: 0 (the hero, half the frame or more) to 4 (far, under 2% of it)", o.id, o.lod.unwrap_or(0)));
|
||||
}
|
||||
if o.route.is_none() && m.kind == Kind::Scene {
|
||||
out.push(format!("object `{}` has no route: solid, rule, gen, library or picture", o.id));
|
||||
}
|
||||
@@ -254,7 +286,7 @@ pub fn doctor(m: &Make) -> Vec<String> {
|
||||
if !names.insert(s.name.as_str()) {
|
||||
out.push(format!("shot `{}` is listed twice", s.name));
|
||||
}
|
||||
if !s.name.chars().all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || c == '_') {
|
||||
if !is_name(&s.name) {
|
||||
out.push(format!("shot `{}`: names are [a-z0-9_], the file it lands as", s.name));
|
||||
}
|
||||
if s.composition.is_none() {
|
||||
|
||||
@@ -117,6 +117,17 @@ fn a_make_plan_reads_and_its_doctor_names_what_it_lacks() {
|
||||
assert!(want.contains(&"out/kit/phone/phone_lod1.glb".to_string()) && want.contains(&"out/kit/kit.json".to_string()), "{want:?}");
|
||||
}
|
||||
|
||||
// MK22: an object's planned detail, 0 (the hero) to 4 (far)
|
||||
#[test]
|
||||
fn an_object_plans_its_detail_and_the_doctor_holds_it_to_five_levels() {
|
||||
let m: make::Make = read("make", r#"{"kind": "scene", "objects": [
|
||||
{"id": "kiosk", "label": "Kiosk", "h": 2.4, "route": "solid", "lod": 3},
|
||||
{"id": "tower", "label": "Tower", "h": 40, "route": "picture", "lod": 7}]}"#).unwrap();
|
||||
assert_eq!(m.objects[0].lod, Some(3));
|
||||
let d = make::doctor(&m);
|
||||
assert!(d.iter().any(|x| x.contains("`tower` has lod 7")) && !d.iter().any(|x| x.contains("`kiosk`")), "{d:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_shot_plan_wants_a_still_or_a_move_per_shot() {
|
||||
let m: make::Make = read("make", r#"{"kind": "shot", "shots": [{"name": "counter_push", "move": "push_in"}, {"name": "Bad Name"}]}"#).unwrap();
|
||||
|
||||
@@ -224,3 +224,131 @@ pub fn ray_tri(o: Vec3, d: Vec3, [a, b, c]: [Vec3; 3]) -> Option<f32> {
|
||||
let t = e2.dot(q) / det;
|
||||
(t >= 0.0).then_some(t)
|
||||
}
|
||||
|
||||
/// The part's lowest points (its feet): its vertices within a millimetre (or 2% of its height) of its lowest, and
|
||||
/// points across the faces lying there (a slab's corners overhang what holds it up; its middle doesn't), about 4 n at most.
|
||||
pub fn feet(p: &Part, n: usize) -> Vec<Vec3> {
|
||||
let tol = (0.02 * (p.hi.y - p.lo.y)).clamp(0.0005, 0.003);
|
||||
let low = |q: &Vec3| q.y <= p.lo.y + tol;
|
||||
let mut v: Vec<Vec3> = p.tris.iter().flatten().filter(|q| low(q)).copied().collect();
|
||||
let bases: Vec<&[Vec3; 3]> = p.tris.iter().filter(|t| t.iter().all(low)).collect();
|
||||
let area: f32 = bases.iter().map(|t| 0.5 * (t[1] - t[0]).cross(t[2] - t[0]).length()).sum();
|
||||
if area > 0.0 {
|
||||
// about n points over the base, spread by area
|
||||
let step = (area / n as f32).sqrt();
|
||||
for t in bases {
|
||||
let long = (t[1] - t[0]).length().max((t[2] - t[1]).length()).max((t[0] - t[2]).length());
|
||||
let m = ((long / step).ceil() as usize).clamp(1, 32);
|
||||
for i in 0..=m {
|
||||
for j in 0..=(m - i) {
|
||||
let (a, b) = (i as f32 / m as f32, j as f32 / m as f32);
|
||||
v.push(t[0] + (t[1] - t[0]) * a + (t[2] - t[0]) * b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
v.sort_by(|a, b| (a.x, a.z, a.y).partial_cmp(&(b.x, b.z, b.y)).unwrap_or(std::cmp::Ordering::Equal));
|
||||
v.dedup_by(|a, b| (*a - *b).length() < 1e-4);
|
||||
if v.len() > 4 * n {
|
||||
let k = v.len() as f32 / (4 * n) as f32;
|
||||
v = (0..4 * n).map(|i| v[(i as f32 * k) as usize]).collect();
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// A wall, or a piece of one (the strip of wall over a window, the window in it): no thicker than WALL_THICK, at least
|
||||
/// WALL_WIDE across and WALL_TALL high (metres; the kitchen's strip over its back window is 9.6 cm).
|
||||
const WALL_THICK: f32 = 0.35;
|
||||
const WALL_WIDE: f32 = 0.8;
|
||||
const WALL_TALL: f32 = 0.05;
|
||||
/// Whether a part is a wall or a piece of one: thin, wide and high.
|
||||
pub fn wall(p: &Part) -> bool {
|
||||
let e = p.hi - p.lo;
|
||||
e.y >= WALL_TALL && e.x.min(e.z) <= WALL_THICK && e.x.max(e.z) >= WALL_WIDE
|
||||
}
|
||||
|
||||
/// A wall's face area, for which of two is set into the other.
|
||||
pub fn face(p: &Part) -> f32 {
|
||||
let e = p.hi - p.lo;
|
||||
e.y * e.x.max(e.z)
|
||||
}
|
||||
|
||||
/// Whether a part's own material gives off light (a lamp's panel, a neon tube): any of its emissive's red, green or
|
||||
/// blue above zero. A model's materials are in its file and aren't read here.
|
||||
pub fn glows(it: &Item) -> bool {
|
||||
it.material.as_ref().and_then(|m| m.props.get("emissive")).is_some_and(glows_in)
|
||||
}
|
||||
|
||||
fn above_zero(v: &Value) -> bool {
|
||||
v.as_f64().unwrap_or(0.0) > 0.0
|
||||
}
|
||||
|
||||
/// A colour as the SDK writes one: [r, g, b, a], { red, green, blue, alpha }, a tagged one ({ LinearRgba: {...} }) or a
|
||||
/// CSS string.
|
||||
fn glows_in(v: &Value) -> bool {
|
||||
match v {
|
||||
Value::Array(a) => a.iter().take(3).any(above_zero),
|
||||
Value::Object(o) => {
|
||||
let own = ["red", "green", "blue", "r", "g", "b"].iter().filter_map(|k| o.get(*k)).any(above_zero);
|
||||
own || o.values().any(|v| (v.is_object() || v.is_array()) && glows_in(v))
|
||||
}
|
||||
Value::String(c) => !matches!(c.trim_start_matches('#').to_ascii_lowercase().as_str(), "000" | "000000" | "black" | ""),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// How far from the scene a part is parked: a piece swaps a flipbook's frames (MALL RAT's fountain, 88 water models) by
|
||||
/// moving the ones not shown hundreds of metres away, where they lie in one another and read as faces fighting.
|
||||
const PARKED: f32 = 500.0;
|
||||
|
||||
/// The parts in the scene, without those parked far from it (further than PARKED from the median of every part's
|
||||
/// centre), each of those said once as not checked.
|
||||
pub fn unparked<T>(parts: Vec<Part>, items: Vec<T>, skipped: &mut Vec<String>) -> (Vec<Part>, Vec<T>) {
|
||||
if parts.len() < 3 {
|
||||
return (parts, items);
|
||||
}
|
||||
let mid = |k: usize| {
|
||||
let mut v: Vec<f32> = parts.iter().map(|p| ((p.lo + p.hi) * 0.5)[k]).collect();
|
||||
v.sort_by(f32::total_cmp);
|
||||
v[v.len() / 2]
|
||||
};
|
||||
let centre = Vec3::new(mid(0), mid(1), mid(2));
|
||||
let mut parked = 0;
|
||||
let kept: (Vec<Part>, Vec<T>) = parts.into_iter().zip(items).filter(|(p, _)| {
|
||||
let far = ((p.lo + p.hi) * 0.5).distance(centre) > PARKED;
|
||||
parked += far as usize;
|
||||
!far
|
||||
}).unzip();
|
||||
if parked > 0 {
|
||||
skipped.push(format!("{parked} part{} parked over {PARKED} m from the scene (a flipbook's frames not shown)", if parked == 1 { "" } else { "s" }));
|
||||
}
|
||||
kept
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_flipbooks_frames_parked_far_away_are_left_out() {
|
||||
let part = |name: &str, c: Vec3, s: Vec3| Part { label: name.into(), tris: Vec::new(), node: Vec::new(), nodes: Vec::new(), lo: c - s / 2.0, hi: c + s / 2.0, excused: false, moving: false };
|
||||
let mut parts = vec![part("floor", Vec3::ZERO, Vec3::new(20.0, 0.1, 20.0)), part("bench", Vec3::new(1.0, 0.3, 0.0), Vec3::new(1.5, 0.5, 0.4)), part("water0", Vec3::new(0.0, 0.5, 3.0), Vec3::ONE)];
|
||||
for i in 1..4 {
|
||||
parts.push(part(&format!("water{i}"), Vec3::new(0.0, -900.0, 3.0), Vec3::ONE));
|
||||
}
|
||||
let mut skipped = Vec::new();
|
||||
let (kept, _) = unparked(parts, vec![(); 6], &mut skipped);
|
||||
assert_eq!(kept.iter().map(|p| p.label.as_str()).collect::<Vec<_>>(), ["floor", "bench", "water0"]);
|
||||
assert!(skipped[0].starts_with("3 parts parked"), "{skipped:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_colour_with_any_light_in_it_glows() {
|
||||
use serde_json::json;
|
||||
assert!(glows_in(&json!({"red": 0.0, "green": 120.0, "blue": 0.0, "alpha": 1.0})));
|
||||
assert!(glows_in(&json!([2200.0, 120.0, 80.0, 1.0])));
|
||||
// black with an alpha of 1 doesn't
|
||||
assert!(!glows_in(&json!({"red": 0.0, "green": 0.0, "blue": 0.0, "alpha": 1.0})));
|
||||
assert!(!glows_in(&json!([0.0, 0.0, 0.0, 1.0])));
|
||||
}
|
||||
}
|
||||
+149
-14
@@ -22,7 +22,6 @@ struct Face {
|
||||
n: Vec3,
|
||||
d: f32,
|
||||
tri: [Vec3; 3],
|
||||
area: f32,
|
||||
}
|
||||
|
||||
fn face(t: &[Vec3; 3]) -> Option<Face> {
|
||||
@@ -32,7 +31,7 @@ fn face(t: &[Vec3; 3]) -> Option<Face> {
|
||||
return None;
|
||||
}
|
||||
let n = c / l;
|
||||
Some(Face { n, d: n.dot(t[0]), tri: *t, area: 0.5 * l })
|
||||
Some(Face { n, d: n.dot(t[0]), tri: *t })
|
||||
}
|
||||
|
||||
type Key = (i32, i32, i32, i64);
|
||||
@@ -46,11 +45,17 @@ fn near(k: Key) -> impl Iterator<Item = Key> {
|
||||
(-1..=1).flat_map(move |a| (-1..=1).flat_map(move |b| (-1..=1).flat_map(move |c| (-1..=1).map(move |e| (k.0 + a, k.1 + b, k.2 + c, k.3 + e as i64)))))
|
||||
}
|
||||
|
||||
/// A point of a plane with normal `n` as two numbers, in an orthonormal frame of the plane.
|
||||
fn flat_in(n: Vec3) -> impl Fn(Vec3) -> Vec2 {
|
||||
let u = n.any_orthonormal_vector();
|
||||
let v = n.cross(u);
|
||||
move |p| Vec2::new(p.dot(u), p.dot(v))
|
||||
}
|
||||
|
||||
/// Whether two coplanar faces overlap by more than INSIDE: separating axes in the plane, in an orthonormal frame.
|
||||
fn overlap(a: &Face, b: &Face) -> bool {
|
||||
let u = a.n.any_orthonormal_vector();
|
||||
let v = a.n.cross(u);
|
||||
let flat = |t: &[Vec3; 3]| t.map(|p| Vec2::new(p.dot(u), p.dot(v)));
|
||||
let point = flat_in(a.n);
|
||||
let flat = |t: &[Vec3; 3]| t.map(&point);
|
||||
let (p, q) = (flat(&a.tri), flat(&b.tri));
|
||||
for tri in [&p, &q] {
|
||||
for k in 0..3 {
|
||||
@@ -73,24 +78,119 @@ fn overlap(a: &Face, b: &Face) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// What two coplanar faces share: its area, and its middle. One triangle cut by the other's three edges.
|
||||
fn shared(a: &Face, b: &Face) -> (f32, Vec3) {
|
||||
// the same frame flat_in makes, to carry the middle back into the world
|
||||
let u = a.n.any_orthonormal_vector();
|
||||
let v = a.n.cross(u);
|
||||
let flat = flat_in(a.n);
|
||||
let mut poly: Vec<Vec2> = a.tri.iter().map(|p| flat(*p)).collect();
|
||||
let q = b.tri.map(flat);
|
||||
// b's winding in this frame, so its inside is on one known side of each edge
|
||||
let turn = (q[1] - q[0]).perp_dot(q[2] - q[0]).signum();
|
||||
for k in 0..3 {
|
||||
let (e0, e1) = (q[k], q[(k + 1) % 3]);
|
||||
let side = |p: Vec2| (e1 - e0).perp_dot(p - e0) * turn;
|
||||
let mut cut = Vec::with_capacity(poly.len() + 2);
|
||||
for i in 0..poly.len() {
|
||||
let (p0, p1) = (poly[i], poly[(i + 1) % poly.len()]);
|
||||
let (s0, s1) = (side(p0), side(p1));
|
||||
if s0 >= 0.0 {
|
||||
cut.push(p0);
|
||||
}
|
||||
if (s0 > 0.0 && s1 < 0.0) || (s0 < 0.0 && s1 > 0.0) {
|
||||
cut.push(p0 + (p1 - p0) * (s0 / (s0 - s1)));
|
||||
}
|
||||
}
|
||||
poly = cut;
|
||||
if poly.len() < 3 {
|
||||
return (0.0, Vec3::ZERO);
|
||||
}
|
||||
}
|
||||
let mut area = 0.0;
|
||||
let mut mid = Vec2::ZERO;
|
||||
for i in 1..poly.len() - 1 {
|
||||
let t = 0.5 * (poly[i] - poly[0]).perp_dot(poly[i + 1] - poly[0]).abs();
|
||||
area += t;
|
||||
mid += (poly[0] + poly[i] + poly[i + 1]) / 3.0 * t;
|
||||
}
|
||||
if area <= 0.0 {
|
||||
return (0.0, Vec3::ZERO);
|
||||
}
|
||||
let mid = mid / area;
|
||||
(area, u * mid.x + v * mid.y + a.n * a.d)
|
||||
}
|
||||
|
||||
fn same_plane(a: &Face, b: &Face) -> bool {
|
||||
a.n.dot(b.n) >= PARALLEL && (a.n.dot(b.tri[0]) - a.d).abs() <= PLANE
|
||||
}
|
||||
|
||||
/// One face over another: how many pairs, about how much area (the smaller face of each pair, summed: an upper
|
||||
/// bound), and where the first is. `b` None: within `a` itself.
|
||||
/// One face over another: how many pairs, the area they share, and the middle of the largest shared patch. `b` None: within `a` itself.
|
||||
pub fn overlaps(a: &[[Vec3; 3]], b: Option<&[[Vec3; 3]]>) -> Option<(usize, f32, Vec3)> {
|
||||
let o = sorted(a, b);
|
||||
o.fight.or(o.twins).or(o.bases)
|
||||
}
|
||||
|
||||
/// Faces in one plane over each other, by whether they show.
|
||||
#[derive(Default, Debug)]
|
||||
pub struct Overlaps {
|
||||
/// One face over a different one: the picture flickers between them.
|
||||
pub fight: Option<(usize, f32, Vec3)>,
|
||||
/// Between two parts, the same triangle in both (a slab built into two neighbouring chunks): nothing to see where
|
||||
/// they look alike, since either draws the same.
|
||||
pub twins: Option<(usize, f32, Vec3)>,
|
||||
/// Between two parts, faces looking straight down in the plane both parts stand on (two boxes on one floor, one
|
||||
/// set into the other): their undersides, which the floor hides.
|
||||
pub bases: Option<(usize, f32, Vec3)>,
|
||||
}
|
||||
|
||||
/// Corners this close (metres) are one corner.
|
||||
const CORNER: f32 = 0.0005;
|
||||
|
||||
fn twin(a: &Face, b: &Face) -> bool {
|
||||
a.tri.iter().all(|p| b.tri.iter().any(|q| p.distance(*q) <= CORNER))
|
||||
}
|
||||
|
||||
/// The lowest corner of a part's faces.
|
||||
fn low(faces: &[Face]) -> f32 {
|
||||
let mut y = f32::INFINITY;
|
||||
for f in faces {
|
||||
for p in &f.tri {
|
||||
y = y.min(p.y);
|
||||
}
|
||||
}
|
||||
y
|
||||
}
|
||||
|
||||
/// As `overlaps`, with the pairs that don't show kept apart (between two parts only: inside one model every pair counts).
|
||||
pub fn sorted(a: &[[Vec3; 3]], b: Option<&[[Vec3; 3]]>) -> Overlaps {
|
||||
if b.is_none() && a.len() > SELF_MAX {
|
||||
return None;
|
||||
return Overlaps::default();
|
||||
}
|
||||
let fa: Vec<Face> = a.iter().filter_map(face).collect();
|
||||
let fb: Vec<Face> = b.map(|b| b.iter().filter_map(face).collect()).unwrap_or_default();
|
||||
let others = if b.is_some() { &fb } else { &fa };
|
||||
let (low_a, low_b) = (low(&fa), low(&fb));
|
||||
let mut buckets: HashMap<Key, Vec<usize>> = HashMap::new();
|
||||
for (i, f) in others.iter().enumerate() {
|
||||
buckets.entry(key(f.n, f.d)).or_default().push(i);
|
||||
}
|
||||
let (mut count, mut area, mut at) = (0usize, 0f32, None);
|
||||
let mut out = Overlaps::default();
|
||||
// the largest patch each kind has seen, for where to point
|
||||
let mut most = [0.0f32; 3];
|
||||
let mut add = |kind: usize, to: &mut Option<(usize, f32, Vec3)>, f: &Face, g: &Face| {
|
||||
let (area, mid) = shared(f, g);
|
||||
if area <= 0.0 {
|
||||
return;
|
||||
}
|
||||
let e = to.get_or_insert((0, 0.0, mid));
|
||||
e.0 += 1;
|
||||
e.1 += area;
|
||||
if area > most[kind] {
|
||||
most[kind] = area;
|
||||
e.2 = mid;
|
||||
}
|
||||
};
|
||||
for (i, f) in fa.iter().enumerate() {
|
||||
let mut seen: Vec<usize> = Vec::new();
|
||||
for k in near(key(f.n, f.d)) {
|
||||
@@ -102,14 +202,20 @@ pub fn overlaps(a: &[[Vec3; 3]], b: Option<&[[Vec3; 3]]>) -> Option<(usize, f32,
|
||||
seen.push(j);
|
||||
let g = &others[j];
|
||||
if same_plane(f, g) && overlap(f, g) {
|
||||
count += 1;
|
||||
area += f.area.min(g.area);
|
||||
at.get_or_insert((f.tri[0] + f.tri[1] + f.tri[2]) / 3.0);
|
||||
let y = f.tri[0].y;
|
||||
let base = b.is_some() && f.n.y <= -0.999 && (y - low_a).abs() <= 0.001 && (y - low_b).abs() <= 0.001;
|
||||
if base {
|
||||
add(0, &mut out.bases, f, g);
|
||||
} else if b.is_some() && twin(f, g) {
|
||||
add(1, &mut out.twins, f, g);
|
||||
} else {
|
||||
add(2, &mut out.fight, f, g);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
at.map(|at| (count, area, at))
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -127,7 +233,12 @@ mod tests {
|
||||
let floor = quad(0.0, -1.0, 1.0, true);
|
||||
let rug = quad(0.0001, 0.0, 0.5, true);
|
||||
let (n, area, _) = overlaps(&rug, Some(&floor)).expect("the rug's top fights the floor's");
|
||||
assert!(n >= 2 && area > 0.1, "{n} {area}");
|
||||
// the rug's whole top, 0.5 m², and no more (the floor's triangles are bigger); pointed at inside the rug
|
||||
let at = overlaps(&rug, Some(&floor)).unwrap().2;
|
||||
assert!(n >= 2 && (area - 0.5).abs() < 1e-4 && at.x > 0.0 && at.x < 0.5 && at.z > 0.0 && at.z < 1.0, "{n} {area} {at}");
|
||||
// a strip 2 mm wide along a metre: 20 cm²
|
||||
let (_, strip, _) = overlaps(&quad(0.0, 0.998, 2.0, true), Some(&floor)).expect("a strip over the floor's edge");
|
||||
assert!((strip - 0.002).abs() < 1e-5, "{strip}");
|
||||
// 1 cm above it, it doesn't
|
||||
assert!(overlaps(&quad(0.01, 0.0, 0.5, true), Some(&floor)).is_none());
|
||||
// back to back (a box resting on another: one top up, the other's bottom down) doesn't fight
|
||||
@@ -140,4 +251,28 @@ mod tests {
|
||||
assert_eq!(overlaps(&doubled, None).map(|o| o.0), Some(1));
|
||||
assert!(overlaps(&quad(0.5, 0.0, 1.0, true), None).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_same_faces_in_two_parts_and_undersides_on_one_floor_are_kept_apart_from_a_fight() {
|
||||
// a slab built into two chunks: the same triangles in both
|
||||
let slab = quad(8.8, 0.0, 4.0, true);
|
||||
let o = sorted(&slab, Some(&slab));
|
||||
assert!(o.fight.is_none() && o.twins.map(|t| t.0) == Some(2), "{o:?}");
|
||||
// a rug's top in the floor's is a different face over it: a fight
|
||||
let o = sorted(&quad(0.0001, 0.0, 0.5, true), Some(&quad(0.0, -1.0, 1.0, true)));
|
||||
assert!(o.fight.is_some() && o.twins.is_none() && o.bases.is_none(), "{o:?}");
|
||||
// a door set into a wall, both standing on the floor: their undersides overlap in the floor's plane
|
||||
let mut wall = quad(0.0, -1.0, 1.0, false);
|
||||
wall.extend(quad(2.0, -1.0, 1.0, true));
|
||||
let mut door = quad(0.0, -0.4, 0.4, false);
|
||||
door.extend(quad(1.0, -0.4, 0.4, true));
|
||||
let o = sorted(&door, Some(&wall));
|
||||
assert!(o.fight.is_none() && o.bases.is_some(), "{o:?}");
|
||||
// the same underside held up off the ground (a soffit under a beam's) still fights
|
||||
let mut beam = quad(2.0, -1.0, 1.0, false);
|
||||
beam.extend(quad(0.0, -1.0, 1.0, true));
|
||||
let mut soffit = quad(2.0, -0.4, 0.4, false);
|
||||
soffit.extend(quad(1.5, -0.4, 0.4, true));
|
||||
assert!(sorted(&soffit, Some(&beam)).fight.is_some());
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@ Feature: Make: scenes, kits and shots built to a frozen plan and held to a revie
|
||||
once each is calibrated on the person's labels; a fresh critic's fixes always (fixed or answered), its score
|
||||
once `raea judge calibrate` agrees with the person's eye.
|
||||
5. Every job ends with its notes, including what the skill got wrong for it, so the next job starts from them.
|
||||
6. Every object is planned at a level of detail, by how large it is meant to be seen, and every render says
|
||||
when a shot shows one closer than that (MK21-MK24).
|
||||
|
||||
Background:
|
||||
Given raea's scene loop as advice (sdk/guides/craft/bevy/scenes.md, from the 11-06 research): brief, routing,
|
||||
@@ -194,6 +196,96 @@ Feature: Make: scenes, kits and shots built to a frozen plan and held to a revie
|
||||
plan from the entrance (blockout.tsx, and `raea render --review` sheets of it) and puts the reference, the
|
||||
blockout and the floor plan on comparison.png, for the person to approve before anything is generated
|
||||
|
||||
Rule: planned detail (MK21-MK24)
|
||||
Shane, 2026-11-24: "define objects at an LOD level based on either us grayboxing or thinking of them as generally
|
||||
distant objects and alert agents when an LOD that was at 3 or 4 for example is now appearing in frame at LOD 2
|
||||
level or 1, or 0 ... helpful for planning objects as generally distant and unseen objects versus close ones and
|
||||
knowing if we forgot about something over time". A level is how large a part is planned to be seen, which is how
|
||||
much of it gets built; the frames are measured against it on every render, so a camera move added later, or a
|
||||
box that was meant to be replaced, is said the next time anything is drawn.
|
||||
|
||||
@done
|
||||
Scenario: MK21. A part shown closer than its planned detail is said
|
||||
Given a level is how much of the frame a part's box spans through the frame's camera, the larger of its width's
|
||||
and its height's share: 0 the hero (50% or more), 1 featured (20%), 2 dressing (8%), 3 background (2%), 4 far
|
||||
And a part's plan is its own `lod` (Mesh3d, Model, and every part inside an Entity with a transform or a Group
|
||||
that has one), else the `lod` of the plan's object of its name
|
||||
When a frame shows a planned part at a finer level than its plan (raea-runtime-lod-plan)
|
||||
Then the render's end checks, `raea scene stage` and `raea check --quick` say `lod-closer`: the part, its plan,
|
||||
the level it is seen at, how much of the frame it spans at its largest and on which frame, how many frames it
|
||||
is closer on, and the fix (build it for that level and plan it there, or keep the camera off it)
|
||||
And one level finer is a warning, two or more an error, which fails the render as any error does
|
||||
And a part out of the frame, behind the camera, or with another mesh's box across every line to it isn't seen;
|
||||
a part the camera stands in or beside is measured at its nearest point; RAEA_LOD_CHECK=0 leaves the check out
|
||||
|
||||
@needs:MK21 @done
|
||||
Scenario: MK22. The plan carries each object's level
|
||||
Given `lod: 0..4` on an object of `make` in brief.ts (core/brief make.rs; `doctor` refuses a level past 4)
|
||||
Then a render of a composition under that brief holds the parts named as the objects' ids to those levels
|
||||
(runtime/lod-plan plan.rs reads the brief only when its words plan a level, once a version)
|
||||
And `raea make plan` labels each footprint with its level and writes each grey box with its object's id as its
|
||||
name and its `lod`, so the blockout is held to the plan it draws
|
||||
|
||||
@needs:MK21 @done
|
||||
Scenario: MK23. `raea scene lod`: every part's plan beside what the frames show
|
||||
When `raea scene lod EDIT.tsx [--from N] [--to N] [--json]` steps the frames without drawing
|
||||
Then it lists every part: its planned level, the finest level a frame shows it at, how much of the frame it
|
||||
spans there, on which frame, and how many frames it is in; parts seen closer than planned first (the widest
|
||||
gap on top), then the rest of the planned, then the parts with no plan by how large they get
|
||||
And a planned part no frame shows as close as its plan says so (built finer than it is ever seen)
|
||||
And a level the plan gives a name that no part in the frames goes by is listed, since it holds nothing
|
||||
And it exits 1 when a part is seen two or more levels finer than planned
|
||||
|
||||
@needs:MK22 @done
|
||||
Scenario: MK24. A job is held at a part seen closer than planned
|
||||
Given a job whose composition's last render or check found `lod-closer`
|
||||
Then `raea make status` has a `lod` gate for that composition, open with the parts' names, until each is built
|
||||
for the level it is seen at and replanned, kept out of the camera's way, or answered in NOTES.md on a line
|
||||
with `lod` and its name; the Stop hook holds the agent there as at any open gate
|
||||
And a job that plans a level and whose render found none shows the gate clear
|
||||
|
||||
Rule: cuts from a client's brief (MK25-MK27)
|
||||
Shane, 11-25, on StreetTalk's street interview ads, cut by raea cloud agents from three clients' PDF briefs: "you
|
||||
need to make the process of ingesting the brief more direct, or else it's just context that gets lost. It needs to
|
||||
be written as a brief typescript rule that is then enforced ... I need raea make to be the standard". The agents had
|
||||
read the briefs and still shipped what a contract catches: held to one written from Elfster's brief, Gemini's four
|
||||
delivered solos (eight files) had "free, fun, and easy" missing from three, the CTA rewritten in one ("Download
|
||||
Elfster for free in the App Store") and missing from another, no frames check on any final file, and four of the
|
||||
ten cuts the brief asks for in its out/ folder.
|
||||
|
||||
@needs:MK0
|
||||
Scenario: MK25. The brief as rules: `make: cut({...})`
|
||||
Given a client's brief as text beside brief.ts (pdftotext -layout BRIEF.pdf media/brief.txt)
|
||||
When the agent writes `make: cut({ cut: {...} })` before it plans a single cut
|
||||
Then core/brief reads `cut` (cut.rs): `brief` (that text), `count` (how many cuts the brief asks for), `seconds`
|
||||
and `formats`, each cut (id, angle, solo or mashup, hook, captions or a text hook, its own formats and length),
|
||||
`say` (phrases every cut says or shows, or one cut with `every: false`), `never` (phrases no cut says or
|
||||
shows), `cta` (the line every cut ends on, within its last 8 s) and `open` (the brief's [TO CONFIRM] items)
|
||||
And every rule has `from`: the brief's own words for it
|
||||
And each cut lands at a fixed path, out/cuts/<id>_<W>x<H>.mp4 for each of its formats
|
||||
And `doctor` names what the contract still lacks: no count, no cta, an id that isn't [a-z0-9_], a format that
|
||||
isn't W:H, a cut with no length, a rule with no `from`
|
||||
|
||||
@needs:MK25
|
||||
Scenario: MK26. Held to the brief's own words, its count and its open items
|
||||
Given a cut contract
|
||||
Then `raea make status` finds every `from` in the brief's text, compared by letters and digits: a rule the brief
|
||||
doesn't say, or says in other words, holds the job ("quotes")
|
||||
And fewer cuts than `count` hold it, unless an `open` item about "count" has the person's answer ("count")
|
||||
And every `open` item without an answer holds it, so the agent stops at a review to ask ("open")
|
||||
|
||||
@needs:MK25
|
||||
Scenario: MK27. Every delivered file held to the rules, from what's on disk
|
||||
Given a cut's file at its path
|
||||
Then its shape and length are read from its own MP4 boxes, so a file re-encoded after its render is read as it is
|
||||
now ("shape")
|
||||
And its words must be heard after its last change (FILE.words.json, `raea words`), and in them or its render's
|
||||
text (FILE.render.json): every `say` phrase ("say"), no `never` phrase, with the second it's heard ("never"),
|
||||
and the CTA in its last `within` seconds, 85% of its words in order ("cta")
|
||||
And its frames check must have run after its last change (FILE.frames-check.json, `raea frames check`) with no
|
||||
error: no face cut by the frame or a seam, no text under the size floor ("frames")
|
||||
And the cut job has no critic tier yet: the person's review is its critic
|
||||
|
||||
Rule: raea cloud (MK19-MK20)
|
||||
|
||||
@needs:MK2 @done
|
||||
|
||||
@@ -68,7 +68,7 @@ What's wrong before anyone watches it.
|
||||
| [`raea make`](make.md) | A scene, kit or shot made to its plan: the plan stop, the kit's references, generators, pick, prep and landing, a shot list's framing and lens charts, and whether it's done, decided in code; the agent's Stop hook holds it there. |
|
||||
| [`raea fingerprint`](fingerprint.md) | A person's sense of good work, learned on this Mac: axes with small heads over on-device encoders that score a render moment by moment and say what they can't judge yet. |
|
||||
| [`raea findings`](findings.md) | What each render and check found, read back from the project's record: fixed, new and carried since the one before. |
|
||||
| [`raea scene`](scene.md) | Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, and hold every frame to the stage checks a render runs. |
|
||||
| [`raea scene`](scene.md) | Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, hold every frame to the stage checks a render runs, and list each part's planned detail beside how large the frames show it. |
|
||||
| [`raea light`](light.md) | Measure a scene's light on each light path against its path-traced reference: distance in stops, the worst tile, flicker and cost. |
|
||||
| [`raea bench`](bench.md) | Each case on each denoiser against its converged truth: FLIP, RMSE, bias, flicker, blotches, lag after a disocclusion or a light going out, a frame's cost, and how many of MetalFX's numbers each meets. |
|
||||
| [`raea world`](world.md) | A frame as one world: its layers, text, 3D parts, camera, shots, clips, cues and lines as entities, queried across media. |
|
||||
|
||||
@@ -12,6 +12,11 @@ sources: ["apps/make/src/lib.rs", "apps/make/src/status.rs", "apps/make/src/aske
|
||||
and kit.json; a shot's still or move per shot), or the plan's own `deliverables`;
|
||||
- NOTES.md, ending with a "What the skill got wrong" section;
|
||||
- each composition the plan names has a render or check newer than it that found no error (the project's record);
|
||||
- no part is seen closer than its planned detail. An object's `lod` (0 the hero to 4 far; the levels are in
|
||||
[raea scene](scene.md)) says how large it is planned to be seen, so a grey box or a far backdrop is planned at 3
|
||||
or 4. A render that shows it two levels finer is an error, held by the line above; one level finer holds the job
|
||||
until the part is built for that level and replanned, the camera keeps off it, or NOTES.md answers it on a line
|
||||
with `lod` and its name. `raea scene lod` lists every part;
|
||||
- a fresh critic (`raea judge --kind KIND`) has judged a round newer than the newest deliverable on the job's own
|
||||
kind's rubric, and each blocking defect it named is fixed or answered in NOTES.md by its name; once the judge is
|
||||
calibrated against your eye, two passes in a row as well;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
---
|
||||
title: "raea scene"
|
||||
summary: "Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, and hold every frame to the stage checks a render runs."
|
||||
summary: "Find floating, sunk and clipping 3D parts, say what each part rests on, meter a shot's light, hold every frame to the stage checks a render runs, and list each part's planned detail beside how large the frames show it."
|
||||
order: 47
|
||||
sources: ["apps/scene/src/lib.rs", "apps/scene/src/light.rs", "apps/scene/src/stage.rs", "systems/stage/src/lib.rs", "systems/stage/src/clearance.rs", "systems/contact/src/lint.rs", "systems/contact/src/zfight.rs"]
|
||||
sources: ["apps/scene/src/lib.rs", "apps/scene/src/light.rs", "apps/scene/src/stage.rs", "apps/scene/src/lod.rs", "runtime/lod-plan/src/lib.rs", "runtime/lod-plan/src/report.rs", "runtime/lod-plan/src/plan.rs", "systems/stage/src/lib.rs", "systems/stage/src/clearance.rs", "systems/contact/src/lint.rs", "systems/contact/src/zfight.rs"]
|
||||
---
|
||||
|
||||
`raea scene` steps a composition's frames and measures its 3D scene without rendering pictures. `lint` reports
|
||||
@@ -21,6 +21,28 @@ also holds the camera M metres off every solid part on every frame (0.45 for a c
|
||||
part it comes closer to, the frames and the nearest it gets, or that it's inside the part. Glass, decals, volumes and
|
||||
parts under 5 cm are passed over.
|
||||
|
||||
`lod` lists every part's planned detail beside what the frames show. A part's plan is how large it is meant to be
|
||||
seen, which is how much of it gets built:
|
||||
|
||||
| lod | for | across the frame |
|
||||
| --- | --- | --- |
|
||||
| 0 | the hero | 50% or more |
|
||||
| 1 | featured | 20% to 50% |
|
||||
| 2 | set dressing | 8% to 20% |
|
||||
| 3 | background: a grey box reads | 2% to 8% |
|
||||
| 4 | far: a silhouette | under 2% |
|
||||
|
||||
The plan is the part's own `lod` prop (`<Mesh3d lod={3}>`, `<Model lod={4}>`, or a parent `<Entity transform lod>`
|
||||
or `<Group lod>` for every part inside), else the `lod` of the object with the part's name in the job's plan (`make`
|
||||
on the brief.ts above the composition). What a frame shows is how much of it the part's box spans through that
|
||||
frame's camera, the larger of its width's and its height's share. The table puts parts seen closer than planned
|
||||
first, then the rest of the planned parts, then the parts nobody planned by how large they get, so a part forgotten
|
||||
since the plan was written is found by reading down it. Under it: each `lod-closer` finding, and any level the plan
|
||||
gives a name that no part in the frames goes by. A part seen one level finer than planned is a warning; two or more
|
||||
is an error, and `lod` exits 1. `raea render`, `raea scene stage` and `raea check --quick` say the same finding, and
|
||||
`raea make status` holds a job at it. A part hidden behind other meshes isn't counted as seen; RAEA_LOD_CHECK=0
|
||||
leaves the check out of a render.
|
||||
|
||||
```sh
|
||||
raea scene lint room.tsx
|
||||
raea scene explain room.tsx --frame 90 --json
|
||||
@@ -28,6 +50,7 @@ raea scene light room.tsx --part hero
|
||||
raea scene light film.tsx --composition shot1,shot2,shot3 # the light across the cuts
|
||||
raea scene stage film.tsx --from 1800 --to 2400 # the stage checks on 20 s of it
|
||||
raea scene stage walk.tsx --clearance 0.45 # and the camera kept off the set
|
||||
raea scene lod walk.tsx # every part's planned detail against the frames
|
||||
```
|
||||
|
||||
<!-- generated:begin by tools/manual-ref/cli.ts from `raea help --json`; edit only the flag descriptions -->
|
||||
@@ -36,7 +59,7 @@ raea scene stage walk.tsx --clearance 0.45 # and the camera
|
||||
|
||||
```sh
|
||||
raea scene export EDIT.tsx -o DIR [--composition ID] [--frame N | --at A-B] (the composition's 3D as data other tools build: DIR/scene.json, each part placed (y up, metres) with its shape, material or light, and the camera; meshes/ and models/ beside it)
|
||||
raea scene lint|explain|light|stage EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json] (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)
|
||||
raea scene lint|explain|light|stage|lod EDIT.tsx [--composition ID] [--frame N] [--part NAME] [--from N] [--to N] [--clearance M] [--json] (what each 3D part rests on: floating, sunk and clipping parts; light: the scene's lighting)
|
||||
```
|
||||
|
||||
Headless: it needs nothing running and opens no window. Takes up to 2 arguments besides its flags.
|
||||
@@ -49,10 +72,10 @@ Headless: it needs nothing running and opens no window. Takes up to 2 arguments
|
||||
| `--clearance` | `M` | `stage`: every run of frames where the camera is nearer a solid part than M metres (0.45 carried, 0.15 on a rig). |
|
||||
| `--composition` | `ID` | Which composition to measure. `light` takes several, comma-separated, to compare the light across their cuts. |
|
||||
| `--frame` | `N` | The frame to measure (0 by default; `light` also takes `last`). |
|
||||
| `--from` | `N` | With `stage`: the first frame held to the checks (0 when left out). Every frame before it is still stepped, so a scene that builds over time is as it would render. |
|
||||
| `--json` | – | Print as JSON: `lint` its findings (check, level, the parts they are about, frames, says, measure, fix), `explain` every part with its support, gap and box. |
|
||||
| `--from` | `N` | With `stage` and `lod`: the first frame held to the checks (0 when left out). Every frame before it is still stepped, so a scene that builds over time is as it would render. |
|
||||
| `--json` | – | Print as JSON: `lint` its findings (check, level, the parts they are about, frames, says, measure, fix), `explain` every part with its support, gap and box, `lod` every part's row (planned, seen, largest, at, frames, closer), the plan's names no part goes by, and its findings. |
|
||||
| `--part` | `NAME` | With `light`: the part to meter, in place of the shot's subject. |
|
||||
| `--to` | `N` | With `stage`: the last frame held to the checks (the composition's last when left out). |
|
||||
| `--to` | `N` | With `stage` and `lod`: the last frame held to the checks (the composition's last when left out). |
|
||||
| `-o` | `DIR` | `export`: the folder scene.json is written to, with meshes/ and models/ beside it. |
|
||||
|
||||
<!-- generated:end -->
|
||||
|
||||
@@ -279,6 +279,7 @@ hand-written element.
|
||||
| `scale` | `Vec3 \| number` | one number, or x, y and z |
|
||||
| `transform` | `{ translation?: Vec3; rotation?: [number, number, number, number]; scale?: Vec3 }` | Bevy's Transform (Transform.fromXyz(..).withRotation(..)), in place of position, rotation and scale: the entity is then a parent whose children (meshes, lights, models, other entities) move with it, as Bevy's ChildOf children do (the old Group) |
|
||||
| `pass` | `string` | with `transform`: the composition pass of every part inside that doesn't name its own (Mesh's `pass`) |
|
||||
| `lod` | `PlannedLod` | with `transform`: the planned detail of every part inside that plans none of its own, 0 (the hero) to 4 (far) |
|
||||
| `children` | `ReactNode` | its Bevy components (<BevyComponent>, or the generated wrappers in raea/bevy-own); with `transform`, also the parts it carries |
|
||||
|
||||
Used in: [ui/widgets/viewport_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/widgets/viewport_node.tsx), [3d/3d_shapes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/3d_shapes.tsx), [3d/atmospheric_fog](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/atmospheric_fog.tsx), [3d/3d_scene](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/3d_scene.tsx), [3d/parenting](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/parenting.tsx), [stress_tests/many_foxes](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/stress_tests/many_foxes.tsx), [camera/projection_zoom](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/camera/projection_zoom.tsx), [animation/animated_transform](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/animation/animated_transform.tsx), and 5 more.
|
||||
@@ -554,6 +555,7 @@ Bevy: `bevy_pbr::mesh_material::MeshMaterial3d<raea_render::engine::look::LookMa
|
||||
| `scale` | `number \| Vec3` | one number, or x, y and z |
|
||||
| `allowOverlap` | `boolean` | it may pass through other parts on purpose (a blade into a body, a ghost through a wall): raea's clipping check leaves it out |
|
||||
| `posed` | `boolean` | set at an angle on purpose (a bowl knocked over, a mug on its side): `raea scene lint` doesn't call it tilted |
|
||||
| `floating` | `boolean` | it hangs in the air on purpose, touching nothing (a balloon, a sign on wires that aren't modelled): `raea scene lint` doesn't call it left in the air |
|
||||
| `animation` | `string \| number` | a clip to play: its name in the file, or its index |
|
||||
| `screens` | `ModelScreens` | live pictures on its materials, by the glTF material's name: `{ monitor_screen: <Screen resolution={[384, 272]}> <Game /></Screen> }` (or a bare `<Game />` for the defaults). Each mesh with that material shows the screen, the picture fitted to the mesh's texture coordinates and stood upright |
|
||||
| `hide` | `string[]` | nodes of the glTF hidden, by name (a robot's painted-on eyes under the screen that replaces them) |
|
||||
@@ -569,6 +571,7 @@ Bevy: `bevy_pbr::mesh_material::MeshMaterial3d<raea_render::engine::look::LookMa
|
||||
| `flat` | `boolean` | its surfaces without light: shape and colour alone, like a drawing (the site look keeps the light: its grain is made of it) |
|
||||
| `shadow` | `boolean` | false: its meshes cast no shadow (true by default) |
|
||||
| `detail` | `Detail` | where it's drawn: its distances or sizes on screen, cross-faded, and its shadow (Detail; raea-sys-lod) |
|
||||
| `lod` | `PlannedLod` | its planned detail, 0 (the hero) to 4 (far): how large it is meant to be seen. A render that shows it finer says so (`lod-closer`); a stand-in or a far backdrop is planned at 3 or 4 (PlannedLod) |
|
||||
| `receiveShadow` | `boolean` | false: no shadow falls on its meshes, its own included (true by default): a furry coat of many cards that would otherwise speckle itself in the shadow maps |
|
||||
| `pixelSize` | `number` | a cell's size in frame pixels for the pixel and site looks (6 by default) |
|
||||
| `edgeColor` | `string` | the pixel look's one-cell outline, a hex colour ("#000000" by default), or "none" |
|
||||
|
||||
@@ -30,10 +30,10 @@ See [Workspaces and projects](../../concepts/workspaces.md) for where each spec
|
||||
<!-- generated:begin by tools/manual-ref/sdk.ts from the SDK's exports and doc comments; edit outside this block -->
|
||||
|
||||
```ts
|
||||
import { brief, fingerprint, kit, parts } from "raea/brief"
|
||||
import { brief, cut, fingerprint, kit } from "raea/brief"
|
||||
```
|
||||
|
||||
`raea/brief` exports 8 functions, 34 types. Source: [sdk/raea/src/brief.ts](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/brief.ts).
|
||||
`raea/brief` exports 9 functions, 40 types. Source: [sdk/raea/src/brief.ts](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/src/brief.ts).
|
||||
|
||||
## Functions
|
||||
|
||||
@@ -46,6 +46,14 @@ the project's plan.org.
|
||||
function brief(b: Brief): Brief
|
||||
```
|
||||
|
||||
### `cut`
|
||||
|
||||
ads cut from footage to a client's brief: `cut: {...}` is the brief as rules, each quoting it
|
||||
|
||||
```ts
|
||||
function cut(m: Omit<Make, "kind">): Make
|
||||
```
|
||||
|
||||
### `fingerprint`
|
||||
|
||||
A fingerprint (fingerprint.ts): its axes and the encoders its heads were trained on.
|
||||
@@ -205,6 +213,24 @@ type Line = { /** * a character, or "narrator" */ who: string, says: string, /**
|
||||
type Make = { kind: MakeKind, /** * the pictures the job answers to (paths beside the brief): what is in it and where for a scene, the style for a kit */ references?: Array<string>, /** * one paragraph every reference prompt carries: era, palette, materials, wear, and one fictional maker */ style?: string, /…
|
||||
```
|
||||
|
||||
### `MakeCta`
|
||||
|
||||
```ts
|
||||
type MakeCta = { text: string, from: string, /** * how near the end it must land, in seconds (8 when left out) */ within?: number, }
|
||||
```
|
||||
|
||||
### `MakeCut`
|
||||
|
||||
```ts
|
||||
type MakeCut = { /** * the brief as text, relative to brief.ts (`pdftotext -layout brief.pdf media/brief.txt`): every `from` is found in it */ brief: string, /** * how many cuts the brief asks for; fewer planned is held open until an answered `open` item about "count" says why */ count?: MakeQuoted<number>, /**…
|
||||
```
|
||||
|
||||
### `MakeCutPlan`
|
||||
|
||||
```ts
|
||||
type MakeCutPlan = { /** * [a-z0-9_], unique: each format lands as out/cuts/<id>_<W>x<H>.mp4 ("a1_s1_9x16.mp4") */ id: string, angle?: string, /** * solo or mashup */ kind?: string, /** * one of the brief's hook types ("Direct Problem", "Reaction") */ hook?: string, /** * captions, hook (a text hook) or none */ tex…
|
||||
```
|
||||
|
||||
### `MakeDial`
|
||||
|
||||
```ts
|
||||
@@ -220,7 +246,7 @@ type MakeDialValue = number | string
|
||||
### `MakeKind`
|
||||
|
||||
```ts
|
||||
type MakeKind = "scene" | "kit" | "shot"
|
||||
type MakeKind = "scene" | "kit" | "shot" | "cut"
|
||||
```
|
||||
|
||||
### `MakeObject`
|
||||
@@ -229,18 +255,36 @@ type MakeKind = "scene" | "kit" | "shot"
|
||||
type MakeObject = { /** * snake_case, unique in the job */ id: string, label: string, /** * real height in metres */ h?: number, /** * [width, depth, height] in metres, for boxy things (generators invent depth) */ dims?: [number, number, number], /** * largest extent in metres, for things that lie flat (tools, pap…
|
||||
```
|
||||
|
||||
### `MakeOpen`
|
||||
|
||||
```ts
|
||||
type MakeOpen = { question: string, from: string, /** * what it decides: "count", "cta", "offer", a cut's id... */ about?: string, /** * the person's answer, as they gave it, and who gave it: until then the job can't be done */ answer?: string, by?: string, }
|
||||
```
|
||||
|
||||
### `MakeOrigin`
|
||||
|
||||
```ts
|
||||
type MakeOrigin = "reference" | "invented"
|
||||
```
|
||||
|
||||
### `MakePhrase`
|
||||
|
||||
```ts
|
||||
type MakePhrase = { /** * as it's said or shown; compared in lower case, by letters and digits ("24/7" and "24-7" are the same) */ text: string, from: string, /** * `say` only: false when one cut saying it is enough */ every?: boolean, }
|
||||
```
|
||||
|
||||
### `MakePick`
|
||||
|
||||
```ts
|
||||
type MakePick = { /** * "tripo-h31", "meshy", ... */ generator: string, /** * one line: why this one ("sharper dial numerals; Tripo fused the handset to the cradle") */ why: string, }
|
||||
```
|
||||
|
||||
### `MakeQuoted`
|
||||
|
||||
```ts
|
||||
type MakeQuoted = { value: T, /** * the brief's own words, as they are in its text */ from: string, }
|
||||
```
|
||||
|
||||
### `MakeRoute`
|
||||
|
||||
```ts
|
||||
|
||||
@@ -33,7 +33,7 @@ The composition, the app, and the specs and notes an agent writes.
|
||||
| --- | --- | --- |
|
||||
| [`raea`](raea.md) | The main entry: compositions, sequences, time, interpolation, springs, footage, sound and words. | 21 components, 9 hooks, 65 functions, 11 values, 109 types |
|
||||
| [`raea/app`](app.md) | The App, its plugins and schedules, and the registry a video's compositions are kept in. | 1 component, 1 hook, 5 functions, 3 classes, 17 values, 18 types |
|
||||
| [`raea/brief`](brief.md) | The specs an agent writes as data: brief, script, taste and an object's parts, checked against raea's schemas. | 8 functions, 34 types |
|
||||
| [`raea/brief`](brief.md) | The specs an agent writes as data: brief, script, taste and an object's parts, checked against raea's schemas. | 9 functions, 40 types |
|
||||
| [`raea/note`](note.md) | A person's note as a file in the project: their words kept as written, and the asks the agent restates it as. | 1 function, 4 types |
|
||||
|
||||
## Time and motion
|
||||
|
||||
@@ -207,6 +207,8 @@ raster-lit: Bevy 0.20's Solari can't trace it, unless `dynamic` gives a skinned
|
||||
| `primarySamples` | `number` | direct light samples at the camera's first hit, a pixel a frame (Bevy's 8). After MetalFX's denoiser 4 bought the window scene nothing over 8 and saved 1.5 ms at 1080p's pixels |
|
||||
| `secondarySamples` | `number` | direct light samples at each bounce (Bevy's 4) |
|
||||
| `firstBounce` | `number` | the chance a pixel traces its first bounce this frame, its light divided by it (Russian roulette): 0.5 halves the bounce's tracing, most of a dense forest's (1, every pixel every frame) |
|
||||
| `paths` | `number` | initial paths a pixel a frame (1 to 16, 1 by default): N cut the noise of one path N times, at N times its rays. A sunlit room seen through bounces (MALL RAT's court) needs 4 or more to hold still |
|
||||
| `firefly` | `number` | the firefly filter: a sample over this many times the mean of its 8x8 pixels is cut back to that after temporal reuse (off by default; 2 and up). One very bright sample otherwise lingers and spreads: a patch jumps brighter and takes a second to fall back. Lower holds stiller and loses more light (a room lit by small bulbs: 6 holds still and reads 0.3 stops darker, 12 half of both; 32 loses nothing and gains little) |
|
||||
| `cache` | `{ /** frames a cell's light is gathered over: steadier and slower to follow a change (B…` | Solari's world cache, the bounce light it keeps in cells across the scene |
|
||||
| `scale` | `number` | draw the view at this fraction of its size a side (a third to 1) and let MetalFX's temporal scaler bring it up to the full size, so a game traces fewer pixels: 0.67 traces 45% of them. On the Mac; elsewhere it draws at the full size and raea says so. 1 (or left out): the full size; RAEA_SOLARI_SCALE overrides it |
|
||||
| `denoise` | `boolean` | MetalFX's temporal denoiser on the lighting. false shows Solari's raw noise. Default true; RAEA_SOLARI_DENOISE=0 overrides it |
|
||||
@@ -215,11 +217,14 @@ raster-lit: Bevy 0.20's Solari can't trace it, unless `dynamic` gives a skinned
|
||||
| `emissive` | `"taa" \| "split" \| "mask"` | an emissive surface's own light: "taa" taken out before the denoiser and gathered over frames (RT11, RT32), "split" each frame's alone, "mask" left in for the denoiser. Default "taa"; RAEA_SOLARI_EMISSIVE overrides it |
|
||||
| `upscale` | `"one" \| "two"` | a view drawn small (scale below 1): denoised and brought up in "one" pass, or denoised small and scaled in "two". Default "one"; RAEA_SOLARI_UPSCALE overrides it |
|
||||
| `preexposure` | `number` | what MetalFX divides the light by before it denoises and multiplies it by after. Higher keeps more of a rare bright sample (a lamp found by one path in many) and lets more fireflies through: 1 kept 0.74 of the desk's light, 16 0.86, 64 0.91. Default 16; RAEA_METALFX_PREEXPOSURE overrides it |
|
||||
| `knee` | `number` | where the denoiser's soft knee starts, in its white (1 by default; 0 off). Light above it is denoised as its log and restored after, so a silhouette against bright sky or a lit doorway doesn't step with the camera's jitter. RAEA_METALFX_KNEE overrides it |
|
||||
| `late` | `boolean` | denoise after the forward meshes and the sky, so their edges are gathered over frames too instead of stepping with the camera's jitter. RAEA_SOLARI_DENOISE_LATE overrides it |
|
||||
| `aa` | `boolean` | jitter a full-size view too, so the denoiser anti-aliases its edges as it gathers frames. Default true; RAEA_SOLARI_AA=0 overrides it |
|
||||
| `jitter` | `"denoiser" \| "scaler" \| "both" \| "flip" \| "none"` | which of MetalFX's passes is told the camera's jitter: "denoiser", "scaler", "both", "flip" (the denoiser, negated), "none" (and the view isn't jittered). For A/Bs of RT9; default "denoiser"; RAEA_SOLARI_JITTER ("" the denoiser, "0" none) overrides it |
|
||||
| `emissiveSharpness` | `number` | how fast a sample's weight falls with its distance from a pixel's centre in the emission's history, exp(-k d²) in output pixels: lower is softer. Default 6; RAEA_EMIT_TAA_SHARP overrides it |
|
||||
| `jitterFrames` | `number` | the jitter's cycle at the full size, in frames: a view drawn at s of its size a side cycles through jitterFrames / s² offsets, and an emissive twig glimpsed through it may stay away that long. Default 8 (DLSS's) |
|
||||
| `dynamic` | `boolean` | the traced scene follows what moves (a trial, false by default): a skinned character's traced twin is posed each frame, so it casts traced shadows and bounces light. Decided as each mesh is first traced, so set it from the first frame. (A hidden part, or one a frame leaves out, leaves the traced scene with or without it.) |
|
||||
| `overscan` | `number` | overscan (off by default): the view is traced this much wider on every side (0.05 is a twentieth of its width and height) and the middle cropped back out, so the frame's border has light to gather from as the camera moves. For a moving shot whose edges crawl (`raea light steady` passing everywhere but the border). It costs (1 + 2 x overscan)² the tracing, the picture is drawn at 1 / (1 + 2 x overscan) of its size at most and brought up, and depth of field, motion blur and `--aov` read the wider view. Mac only (it rides MetalFX's denoiser) |
|
||||
| `constants` | `{ /** how far ReSTIR looks for a neighbour's light samples, pixels (30): smaller keeps …` | constants in Solari's and the denoiser's shaders, compiled in when the scene loads (a value changed later in the composition isn't drawn); each left out keeps the shader's own, given in brackets. <ShaderConstants> reaches the rest |
|
||||
|
||||
### `SpotLight`
|
||||
|
||||
@@ -114,7 +114,7 @@ One part, so a curve that grows is solid at every frame (never a chain of parts:
|
||||
| `normal` | `Vec3` | the way its face looks: the normal of the plane it lies in (left out: the plane of its points, else +z) |
|
||||
| `children` | `ReactNode` | its material (a white StandardMaterial when left out) |
|
||||
|
||||
Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).
|
||||
Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `floating`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).
|
||||
|
||||
### `Mesh2d`
|
||||
|
||||
@@ -139,7 +139,7 @@ shadow="only" draws it with the shadow-only material (engine/render shadow_only.
|
||||
| `detail` | `Detail` | where it's drawn: its distances or sizes on screen, cross-faded, and its shadow (Detail; raea-sys-lod) |
|
||||
| `children` | `ReactNode` | its material and child entities |
|
||||
|
||||
Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`).
|
||||
Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `floating`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`).
|
||||
|
||||
Used in: [ui/render_ui_to_texture](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/render_ui_to_texture.tsx), [ui/widgets/viewport_node](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/ui/widgets/viewport_node.tsx), [3d/fog](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/fog.tsx), [3d/vertex_colors](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/vertex_colors.tsx), [3d/rotate_environment_map](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/rotate_environment_map.tsx), [3d/transparency_3d](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/transparency_3d.tsx), [3d/spherical_area_lights](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/spherical_area_lights.tsx), [3d/animated_material](https://github.com/shinyobjectz/raea/blob/main/sdk/raea/bench/bevy-parity/3d/animated_material.tsx), and 54 more.
|
||||
|
||||
@@ -181,7 +181,7 @@ A line through points in 3D with a round section (a pipe, a wire): one mesh, dra
|
||||
| `radius` | `number` | its radius in metres (0.025) |
|
||||
| `sides` | `number` | sides around its section (12) |
|
||||
|
||||
Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).
|
||||
Also takes the props of `MeshProps` (`animate`, `name`, `read`, `pass`, `quaternion`, `allowOverlap`, `posed`, `floating`, `lod`, `shape`, `driven`, `shadow`, `material`, `castShadow`, `surface`, `receiveShadow`, `attributes`, `compressed`, `layers`); `PointerHandlers3d` (`onClick`, `onDrag`, `onDragEnd`, `onDragEnter`, `onDragLeave`, `onDragOver`, `onDragStart`, `onDrop`, `onPointerDown`, `onPointerMove`, `onPointerUp`, `onPointerEnter`, `onPointerLeave`, `onPointerOver`, `onPointerOut`, `onWheel`); [`Mesh3dProps`](#mesh3dprops) (`visibility`, `transform`, `detail`).
|
||||
|
||||
## Functions
|
||||
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
---
|
||||
title: "raea 0.1.10"
|
||||
version: "0.1.10"
|
||||
date: "2026-11-26"
|
||||
summary: "The app is raea cloud on your own computer, in the system's own window on the Mac, Windows and Linux. Publishing is a project's delivery, raea make holds a 3D scene to its plan, Solari's light boils less, and a long 3D film renders whole with each frame's own light."
|
||||
sources: ["https://github.com/shinyobjectz/raea/releases/tag/v0.1.10"]
|
||||
---
|
||||
|
||||
raea 0.1.10 makes the app raea cloud on your own computer. It is the same dashboard, with projects that run here on
|
||||
the AI you already use, in the system's own window on the Mac, Windows and Linux. A finished video is published from
|
||||
its project. In the engine, `raea make` holds a 3D scene, kit or shot to its plan until every check passes, Solari's
|
||||
light boils less and can be measured holding still, and a long 3D film that switches scenes renders whole with the
|
||||
same light as each frame alone.
|
||||
|
||||
**Get the app at [raea.io](https://raea.io)** (a Mac with Apple silicon, Windows 10 or 11, or Linux on x86_64).
|
||||
|
||||
The engine alone:
|
||||
|
||||
```sh
|
||||
curl -fsSL https://raea.io/install | sh
|
||||
```
|
||||
|
||||
On Windows, in PowerShell: `irm https://raea.io/install.ps1 | iex`.
|
||||
|
||||
## What changed since 0.1.9
|
||||
|
||||
### In the app
|
||||
|
||||
**The app is laid out like raea cloud.** Its rail is Inbox, Projects, Agents, Workflows, Libraries and Fingerprints,
|
||||
with your workspace above New, and Connections and Settings at the foot. Projects you start run on this computer, in a
|
||||
raea cloud of its own, on the AI you already use: Claude Code unless you pick another in Settings → General. Cloud
|
||||
workspaces sit in the same menu once you sign in. The first time it opens, the welcome and sign-in come first, then
|
||||
your projects, agents, library and fingerprints from the earlier app move in. The files are cloned, not copied, and the
|
||||
old folders are only read.
|
||||
|
||||
**In the system's own window.** The app now draws in the webview each system already has: WebKit on the Mac, WebView2
|
||||
on Windows and WebKitGTK on Linux. Links open in your browser, Copy reaches the clipboard, the folder chooser is the
|
||||
system's own on every system, and a `raea://` link brings the running app forward on Windows and Linux as on the Mac.
|
||||
|
||||
**Publishing is a project's delivery.** A workflow can end in a post: pick the accounts it posts to in its editor. When
|
||||
a project delivers its video, it waits in Needs you at Publish, with the caption its agent wrote and the account it
|
||||
goes to. Change the caption if you like, press Publish, and the project shows "Published" with the post's views once
|
||||
the network answers. On a plan that doesn't publish, Publish says which plan does and the project stays where it was.
|
||||
The separate Publishing page is gone.
|
||||
|
||||
**Ask a workflow to change.** In a workflow's editor, say what you want ("add a legal review before it posts") and
|
||||
your AI changes the workflow. When it needs to know more, it asks first.
|
||||
|
||||
**Agents and chats are one place.** Each agent is listed with its conversations under it, the busiest first. Click an
|
||||
agent to start a new chat with it, or its gear for its settings.
|
||||
|
||||
**The Inbox counts what you haven't seen.** Its number drops as cards come into view, and colour is kept for what needs
|
||||
you: what's running, done or stopped is grey.
|
||||
|
||||
**Projects belong to clients.** As in raea cloud, a project is filed under its client, and the client's board gathers
|
||||
its projects. Projects from the earlier app that sat inside another one join its client. In a terminal,
|
||||
`raea project new NAME --client CLIENT` names one, and `raea project tag --client CLIENT` changes it.
|
||||
|
||||
**`raea show` waits in your Inbox.** What an agent shows you from a terminal session is a card waiting for you, with
|
||||
its files, filed under its project's client. Your approval, or your notes and comments, go back to the session that
|
||||
asked.
|
||||
|
||||
**Mark up a picture.** The editor's picture toolbar has Pen (P), Arrow (A) and Box (B) beside Comment, in red, yellow
|
||||
or white, with Undo.
|
||||
|
||||
**A review link for work done here.** On Pro and Studio, a project in a workspace on this computer can hand out one of
|
||||
raea's review links for what it delivered.
|
||||
|
||||
**Ideate's voice is your raea plan's.** Talking an idea through in Ideate uses your plan's voice minutes: 30 a month on
|
||||
Pro, 300 on Studio, and no limit on Enterprise.
|
||||
|
||||
**Choose where your work is kept.** Settings → General → Where raea keeps your work: pick a folder on any drive, and from the next
|
||||
start raea keeps your work there, once what's already there has been copied and counted. The old folder stays as it
|
||||
was (#233).
|
||||
|
||||
**Light and dark.** The app follows your system, or stays light or dark: Settings → General → Theme.
|
||||
|
||||
### In the engine
|
||||
|
||||
**raea make.** `raea make status` holds a 3D scene, kit or shot written as `make` in a `brief.ts` to its plan: what's
|
||||
missing, each gate (its renders and checks, and raea ask's questions), and whether it's done. An agent's turn can't
|
||||
end until it is. Around it: `raea make plan` draws the floor plan and a grey-box blockout to review first, `raea make
|
||||
refs` makes every object's reference in one style, kits land as a component set with a lineup, and shots come from
|
||||
words or a path through the floor plan. A client's brief can be its rules (`make: cut({...})`), and each object and
|
||||
part can name its planned detail, from `lod={0}` (the hero) to `lod={4}` (far away), checked against how big it is on
|
||||
the frame.
|
||||
|
||||
**Solari's light boils less.** `<SolariLighting paths={N}>` starts N paths a pixel and merges them, which cuts the
|
||||
crawling patches on sunlit floors and reflections in held interiors by nearly half. `firefly={6}` cuts back a bright
|
||||
sample that stands far above its neighbours, and `overscan={0.05}` traces a little past the frame's edge so its border
|
||||
lights like its middle (on the Mac, where it rides the denoiser). Both are off unless set.
|
||||
|
||||
**Light you can measure holding still.** `raea render --hold FRAME` draws one frame again and again, and
|
||||
`raea light steady` says whether its light holds still, and if not, how it moves: settling, boiling, jitter or flicker.
|
||||
`raea light check` runs it on every traced scene.
|
||||
|
||||
**A 3D film renders whole.** In 0.1.9 a long film that switched scenes under Solari could draw its later shots darker
|
||||
than the same frames rendered alone: a part a scene had left stayed in the traced scene and kept shading the next one.
|
||||
It leaves now, and a film rendered whole matches each frame alone.
|
||||
|
||||
**raea render and raea scene check more.**
|
||||
- Words in the world that sit behind a part, so a viewer can't read them, are an error that names the part in front.
|
||||
Text3D is checked as RichText is.
|
||||
- A part a `<Label>` points at is the shot's subject: cutting it off at the frame's edge is an error.
|
||||
- A part left in the air touching nothing is an error in `raea scene lint`, unless it's marked `floating`.
|
||||
- A render whose shader didn't compile ends on an error, where before the frame came out without that pass.
|
||||
- `raea check`'s contrast reads a moving text where it is on its middle frame, not where it ends (#236).
|
||||
|
||||
**raea fix.** `raea fix "the error text"` looks a problem up before it's guessed at: what others found and did about
|
||||
the same symptom.
|
||||
|
||||
**raea/story.** A story as a typed program instead of a document: a premise, the values at stake, a cast with wants
|
||||
and needs, who knows what and when, and beats that each turn a value. It reads a story through twelve lenses (McKee,
|
||||
the Pixar spine, Campbell, Storynomics and others, plus a launch lens for product films), samples new stories from a
|
||||
seed, compiles to a `script.ts`, storylets, Ink or Yarn, and `raea check` holds a script's scenes to their beats.
|
||||
Measured against plain prompts, it works best as the editor of a draft rather than as the language a first draft is
|
||||
written in.
|
||||
|
||||
**New in raea render and raea media.**
|
||||
- `raea render --props JSON|FILE.json` hands a composition its inputs (`getInputProps()`), and `calculateMetadata` on
|
||||
a `<Composition>` sets its size and length from them (#176).
|
||||
- `raea render --scale S` draws a composition at S times its size: 0.5 for a quick look, 2 for a bigger master (#175).
|
||||
- `raea media share FILE -o OUT.mp4` makes the copy to send: any player takes it, and it's held to a bitrate (#219).
|
||||
|
||||
**The engine as a Linux AppImage.** Each release also carries `raea-VERSION-linux-x86_64.AppImage` and its checksum:
|
||||
make it executable and run it as `raea` (#226). The project has a [code of conduct](https://github.com/shinyobjectz/raea/blob/main/CODE_OF_CONDUCT.md) too
|
||||
(#228).
|
||||
|
||||
**Fixes.**
|
||||
- On Windows, a long chat scrolled in jerks, on fast graphics cards too (#215). In the system's own window a chat of
|
||||
160 turns scrolls at the display's rate, with or without the graphics card.
|
||||
- Two paint bugs, each held to what Chrome draws: a box behind a word with `z-index: -1` covered the word (#241), and
|
||||
a rounded rectangle's stroke could draw a bar across the page from its left edge at some widths (#240).
|
||||
- An Opus file couldn't be read back on Linux and Windows (#242).
|
||||
- A failing audio device printed its error on every callback, and on Linux the app's log reached 40 GB in two days.
|
||||
The error is said once, then how often it came back, and the app's log is kept to two files of 32 MB (#239).
|
||||
- An `<R3F>` over another layer cut a box out of the layer under it. The layer shows around the scene now (#235).
|
||||
- A WebM with alpha that another tool had remuxed drew opaque. Its alpha is read whatever the tag's case (#224).
|
||||
- `<Mix lufs>` could land a decibel off its target with flat-topped peaks. It lands on the target (#220).
|
||||
- `raea sounds get` of a second instrument into one folder replaced the first one's notes and licence. Each
|
||||
instrument keeps its own folder (#217).
|
||||
- `raea media sheet $FILES` in zsh, which passes every name as one argument, failed with "File name too long" (#218).
|
||||
- A song's bars are the same on every platform: a 12 ms difference between decoders moved them (#49).
|
||||
- A 3D scene with thousands of parts re-sent every part each frame. Parts whose props didn't change are skipped:
|
||||
a 3000-part scene went from 103 to 78 ms a frame (#160).
|
||||
- On Linux, signing in failed with "spawn /usr/bin/security ENOENT". The app keeps the sign-in in the desktop's
|
||||
keyring, or in a file only you can read where there is none (#216, #222).
|
||||
- `staticFile` from a composition in `compositions/` finds the project's `assets/`.
|
||||
- A composition with the word "import" in a comment above its imports failed before its first frame with "Can't find
|
||||
variable: raea". It renders.
|
||||
- A still of a page (`raea render --frame N`, or `--at` that doesn't start at 0) drew its CSS animations from the
|
||||
wrong time, so every animation showed its first keyframe. Each now runs from the composition's start, or from its
|
||||
own `<Sequence>`'s, as in the video.
|
||||
|
||||
**Known**
|
||||
- On Linux, raea needs a processor with AVX (most from 2011 on) and glibc 2.39 or newer (Ubuntu 24.04, Debian 13,
|
||||
Fedora 40 and later).
|
||||
- On Windows, TokenSynth runs on the CPU, so each note takes a minute or more to make.
|
||||
- A CSS transition that a style change starts depends on the frames before it, so a still of that frame shows it
|
||||
finished. Animate with `@keyframes` or `interpolate` for a still that matches the video.
|
||||
- A seek while a film plays in the timeline can show one frame from before the seek (about 33 ms) before it jumps.
|
||||
- Characters (the Character SDK) come in a later release.
|
||||
- R3F's pointer input has no double click yet, and touches don't arrive as pointers.
|
||||
- postprocessing's Outline, TextureEffect, DepthEffect and LUT1D, and TSL's OutlineNode, are skipped, with one
|
||||
warning that names them.
|
||||
- On a long held shot of an interior, Solari's light can still crawl in a few patches, most along the frame's edge.
|
||||
`raea light steady` shows where; `<SolariLighting overscan={0.05}>` lights the edge as it lights the middle (Mac
|
||||
only, about 1.2 times the tracing).
|
||||
- The Windows app and engine are unsigned, as before: Windows asks once whether to run them, and with Smart App
|
||||
Control on, the engine can't bundle a composition (#221).
|
||||
@@ -0,0 +1,283 @@
|
||||
# Solari, forked: where MALL RAT's frame time goes (11-25)
|
||||
|
||||
Measured on MALL RAT's own takes (Raea/anchor-tenant, `tools/solari-sweep.sh`, scored by `out/lab/pf/score.sh`): each
|
||||
lever moved alone from the take's settings, 240 frames, wall time a frame, scored SSIM/PSNR against the take as it
|
||||
renders (pf0) on the finished VHS look at 1440 x 1080. pfR is pf0 drawn again: its numbers are the noise floor (and wall
|
||||
time itself moves about 10% run to run). The sweep stopped partway: t8 has four levers.
|
||||
|
||||
| lever | t2 ms (pf0 204) | t2 ssim / psnr | t4 ms (pf0 82) | t4 ssim / psnr |
|
||||
|---|---|---|---|---|
|
||||
| pfR, the floor | 185 | 0.991 / 37.2 | 80 | 0.989 / 42.6 |
|
||||
| pfB, 1 bounce | 186 | 0.990 / 36.2 | **64** | 0.988 / 41.0 |
|
||||
| pfS, half the samples (8/4) | 194 | 0.988 / 32.6 | 75 | 0.987 / 40.5 |
|
||||
| pfF, firstBounce 0.5 | 161 | 0.989 / 35.8 | 61 | 0.984 / 38.8 |
|
||||
| pfC, Solari at 0.67 scale | 149 | 0.986 / 35.8 | 52 | 0.964 / 34.3 |
|
||||
| pfH, Solari at 0.5 | 154 | 0.984 / 35.1 | 33 | 0.959 / 35.0 |
|
||||
| pfT, Solari at 0.35 | 153 | 0.980 / 33.8 | 25 | 0.950 / 33.1 |
|
||||
| pfD, whole frame 720 x 540 | 180 | 0.983 / 33.4 | 25 | 0.967 / 34.2 |
|
||||
| pfE, whole frame 960 x 720 | 165 | **0.987 / 36.6** | **37** | **0.978 / 38.6** |
|
||||
|
||||
Solari's own GPU time (RAEA_SOLARI_TIMES) on t2: 18.5 ms at 0.5 scale (initial path 14.6, spatial and shade 2.7, world
|
||||
cache 1.1, light tiles 0.1), 31.7 ms at 960 x 720; by pixel count about 70 ms at full size.
|
||||
|
||||
## What it says
|
||||
|
||||
1. **t2 is not Solari's.** At 0.35 scale Solari takes 11 ms and the frame still takes 153. About 140 ms a frame in the
|
||||
mall court goes to the rest: the composition's scene each frame (hundreds of LOD pieces, 88 baked water frames, the
|
||||
arcade), raster, the look's FramePass chain and the encode. That is the biggest saving left, and it needs a CPU
|
||||
and GPU profile of one t2 frame (xctrace), not a Solari change.
|
||||
2. **Render the tape at 960 x 720.** The VHS look keeps about 320 x 240 a field, so the whole frame at 960 x 720 (pfE)
|
||||
is the best lever measured: t4 55% faster at SSIM 0.978, t2 about 15% faster, nearly at the floor. It beats scaling
|
||||
Solari alone (pfC) on both time and picture, because raster and the look shrink with it.
|
||||
3. **One bounce is free in picture.** pfB sits at the floor on all three takes and saves 20% on t4: the world cache
|
||||
already carries the light past the first bounce.
|
||||
4. **Fewer samples are not.** Halving spp saves little time (the cost is per pixel, not per sample, at these counts)
|
||||
and costs PSNR (t2 37.2 to 32.6). The other way round, the noise notes on v3 (21, 22) are answered with more samples
|
||||
on t5 and t8 only.
|
||||
5. t8's pfS and pfF score PSNR 19.8. Frame by frame it isn't a timing slip: pfS starts at 10 dB and climbs steadily to
|
||||
39 over the 240 frames (pfR holds 35-42 throughout). With fewer samples t8's light starts far off and takes about
|
||||
4 s to settle, most likely through its short world-cache life (`cache: { frames: 6 }`, set so the power cut drops
|
||||
the light at once). In a take with a short cache, cutting samples costs seconds of wrong light, not noise.
|
||||
|
||||
## The quality fix: light selection by power, not by count
|
||||
|
||||
`generate_random_light_sample` (scene/sampling.wesl) picks a light source uniformly: `light_id = rand_range_u(light_count)`,
|
||||
and every pdf divides by `light_count` (sampling.wesl 131-175, realtime/restir.wesl 330, realtime/initial_path.wesl 370).
|
||||
Each emissive mesh, each directional light and each sky portal is one source. So:
|
||||
- a dim exit sign gets as many samples as the sun, and a scene with 300 emissive pieces gives the sun 1/300 of them:
|
||||
noise where the sun matters (v3 notes 7, 21, 22);
|
||||
- a LOD swap or a set mounted mid-shot changes the count, so the sun's share jumps and the denoiser shows a one-frame
|
||||
2-5x brightness step (t2 v3: frames 1042, 2263, 3960, 4315, each a LOD swap). The composition now holds LOD levels a
|
||||
take and mounts sets for the whole take, which works round it, not through it.
|
||||
|
||||
Two ways to fix it in the fork, smallest first:
|
||||
- **A fixed share for the sky.** Directional lights and portals get a fixed probability q (0.5) split among them,
|
||||
emissive meshes share 1 - q. The count of emissive pieces then never moves the sun's share. Needs the two counts in
|
||||
a uniform and the sources kept in two runs (LightIndex's swap_remove keeps no order today), and the five pdf sites
|
||||
changed to read the share by kind.
|
||||
- **Power-weighted (an alias table).** Each source weighted by its power (emissive luminance x area; a directional
|
||||
light's illuminance; a portal's sky radiance x area), sampled in O(1) through an alias table rebuilt when the light
|
||||
set changes. GpuLightSource grows from {kind, id} to {kind, id, pmf, threshold, alias}. The emissive-hit pdf (MIS in
|
||||
the path tracer and initial_path) needs the hit's source pmf, so the instance needs its light index. ReSTIR DI's
|
||||
light tiles inherit it for free, since they draw from generate_random_light_sample.
|
||||
|
||||
Either needs a release build and a check on t2's four swap frames and t8; neither was built while MALL RAT v4 held the
|
||||
GPU.
|
||||
|
||||
## The splotches: the world cache's history, and a bake (11-25)
|
||||
|
||||
Shane on v4: "noisy splotchy thing in the lights and reflections ... it's definitely the world cache, can we bake it?"
|
||||
Each cell takes one bounce ray an update and blends it over a history capped at 32, but the adaptive cut
|
||||
(`alpha = |lum delta| / lum`, world_cache_update.wesl blend_new_samples) reads a cell's own noise as the light changing
|
||||
and holds the history near 10. Ten one-ray samples is the blotch: cell-sized patches that crawl.
|
||||
|
||||
Built in the fork (vendor/bevy_solari, uncommitted, lane solari-bake to come):
|
||||
- `world_cache_steady`: the blend keeps the whole history up to `cache.frames`, with no adaptive cut, and each update's
|
||||
ray seeded by the cell's sample count, so one cell's rays don't repeat. `cache.steady` in the SDK.
|
||||
- `world_cache_update_iterations`: N cache updates a frame. `cache.iterations` in the SDK.
|
||||
- `world_cache_keep`: no decay, so cells never die. `world_cache_save` / `world_cache_load`: the cache buffer
|
||||
written to a file (bake.rs: a copy to a MAP_READ buffer, mapped and written before the next frame's pipelines) or
|
||||
read into it and held (the whole world-cache stage skipped). `cache.bake: { iterations, save }` and
|
||||
`cache.load` in the SDK.
|
||||
|
||||
The bake doesn't fit. A cell's key holds its LOD band (stochastic between bands), its quantised position after a
|
||||
±half-cell jitter and a plane slice along the normal, so one surface seen from a moving camera makes many keys. With
|
||||
nothing decaying, t2's whole take filled all 2^20 slots, and so did each 6 s window of it (13 windows, each 100%).
|
||||
A cache that is full loses cells, and a loaded cache missing cells has holes. A bake would need larger cells, no
|
||||
jitter, or a cache sized to the take. So the live steady history is tried first: it gives the same convergence on
|
||||
the cells the camera sees (they are read each frame, so never die) with no file and no capacity limit. It costs a lag
|
||||
on light that moves, as long as the history: t8's power cut needs a short `frames`, as it has today.
|
||||
|
||||
## The cache's level does not drift: a pass's uniforms stood still (11-25)
|
||||
|
||||
An earlier reading here was wrong. The same t2 frame (1188) read 0.0189 cold at 1440 x 1080 and 0.0177 at 160 x 240,
|
||||
but 7x that inside the long view render and 0.2x inside the long meter render, and it looked as if the world cache's
|
||||
level depended on time and on how many pixels fed it. It doesn't. With the tape's exposure held constant, a 520-frame
|
||||
moving run and a held frame agree (ratio 1.04), at any size.
|
||||
|
||||
What moved was the passes over the frame. A video's 3D is made live, and when a part is dropped mid-render the live
|
||||
rows move up; a <FramePass>'s and a <Compute>'s `follow` found their row by the order the scene opened with, so from
|
||||
the first drop on they read another row and kept the uniforms they opened with. The view's exposure stayed at its
|
||||
first value (64 against 7.6 at t2's frame 720), the meter's passes kept their first camera, and the auto-exposure
|
||||
built on that meter set the final 14 to 40x too bright: Shane's overexposed daylight. Fixed in the engine
|
||||
(engine/render spawn.rs `name_rows`; docs/shaders.feature SH6). After it, t2's meter reads 3 to 4.6x higher than
|
||||
before, a held meter frame and the moving one agree (0.89), and the take's white share fell from a median of 19.9%
|
||||
to 3.7%.
|
||||
|
||||
How it was found, for the next time a sequence and a still disagree: hold the frame (`raea render --hold N:40`) and
|
||||
compare it with frame N of the sequence; then make one input constant at a time (here the exposure uniform) until
|
||||
they agree. The frame-purity check (`raea render`, every 300th frame drawn again alone) catches this class, and
|
||||
MALL RAT renders with it off (RAEA_FRAME_PURE=0), because Solari's history makes a still differ from a sequence anyway.
|
||||
|
||||
## What fixes the patches, measured (11-25)
|
||||
|
||||
The patches are **boiling**, the industry's word for denoised traced light's soft patches crawling over still surfaces
|
||||
(NRD, RTXDI, GI-1.0, the ReSTIR papers, Lumen). raea now uses it (docs/skills.glossary.md, the Solari guide's "Boiling");
|
||||
`raea light steady`'s blotch is its size in one held frame.
|
||||
|
||||
What others do about it that raea hasn't tried yet:
|
||||
- a longer denoiser history: NRD says history "can be bumped up to 60 frames relatively safely" to suppress residual
|
||||
boiling, and Lumen's guides raise `MaxFramesAccumulated` (10 -> 16) before adding rays. MetalFX's history is the
|
||||
next lever here;
|
||||
- blue-noise sampling (NRD: "reduced residual boiling in areas with acceptable sampling quality"), against Solari's white
|
||||
hash noise;
|
||||
- a larger ReSTIR temporal cap with decorrelating mutations (Sawhney et al. 2024: boiling from hard indirect light is
|
||||
resolved by a greater M cap, and mutations remove the blotches a larger cap brings), or RTXDI's boiling filter
|
||||
(which loses energy);
|
||||
- for an offline render, a noise pattern held still across frames (Octane's "static noise"): a held shot can't boil,
|
||||
though its grain stops moving.
|
||||
|
||||
Measured with `raea light steady` (frame held, its light's movement over time; limit 1.5% blotch, worst tile 4.5%) on
|
||||
MALL RAT t2 frame 1188 (150 held, 75 measured), and the bench kitchen (STEADY 0.63 today). t2's runs of one setup spread
|
||||
by 0.1-0.4, so each setup that matters was run twice.
|
||||
|
||||
| setup on t2 | blotch | verdict |
|
||||
|---|---|---|
|
||||
| today (1 path, ReSTIR, live cache) | 2.84-3.09 | fails |
|
||||
| the controls: raster, and the look's passes off | 0.0, 3.04 | the patches are Solari's |
|
||||
| world cache baked and frozen | 2.55 | the cache is not the main cause |
|
||||
| denoiser off / its guides off | grain 17.6, 2.9 | MetalFX passes the patches, doesn't make them |
|
||||
| ReSTIR off; its confidence cap 32; spatial radius 8 | 2.13; 3.03; 2.98 | ReSTIR adds, its settings don't fix |
|
||||
| 2x/4x direct-light samples; 64 small emissives removed; light selection by a sky share | no change | not the direct light |
|
||||
| denoiser and ReSTIR off, cache frozen: the raw light | 98% per-pixel grain, white in space and time | one path's bounce has a sd as large as its mean |
|
||||
| **paths 4 / 8** (new: N initial paths a pixel, RIS-merged) | **1.89 / 2.10** | halves it |
|
||||
| paths 8 + frozen cache | 1.45, 1.53 | on the line |
|
||||
| paths 8 + steady cache (1024 history, 8 updates) | 1.65, 1.69 | |
|
||||
| paths 4-8 + steady + still-camera query (no jitter, one LOD) | 1.66-1.88 | no better |
|
||||
| paths 8, ReSTIR off, steady / frozen | 1.60, 1.69 / 1.54 | |
|
||||
| paths 8 + frozen, camera jitter off | 1.31 (the one pass) | jitter isn't the floor |
|
||||
|
||||
Bias: the kitchen's mean at 4 paths against 1 is +0.0015 stops (per-pixel median 0); with the steady cache and still
|
||||
query +0.0013. Glade's moving shot (the still query off while it moves): flicker 0.708 against 0.702. Cost on t2: a
|
||||
150-frame hold 50 s at 1 path, 82-94 s at 4, 112 s at 8; glade 1.72 -> 2.47 s a still at 4.
|
||||
|
||||
So: `paths` is the lever that ships (default 1; MALL RAT's takes set it). It takes t2 from about 3.0 to 1.6-1.9, which
|
||||
still fails the gate. The rest is the world cache: a frozen one reads 0.1-0.3 lower than any live one at the same paths,
|
||||
and the live cache made to converge (steady history, more updates, the still-camera query) doesn't close the gap. Left
|
||||
for the next release: a cache that converges like the frozen one (cells kept for a held shot without the 2^20 overflow:
|
||||
a bigger or per-take cache, or ReSTIR GI's reservoirs carrying the cache's light), then t2 again.
|
||||
|
||||
Built in the fork, all off unless asked: `paths` (SolariLighting::paths_per_pixel, RAEA_SOLARI_PATHS), `cache.steady`
|
||||
and `cache.iterations`, the still-camera query (with `cache.steady`, RAEA_SOLARI_STEADY=1), `cache.bake`/`cache.load`
|
||||
(experimental: a whole take overflows 2^20 cells), light selection by a fixed sky share (RAEA_SOLARI_SKY_SHARE, 0 =
|
||||
upstream), ReSTIR's spatial radius (RAEA_SOLARI_SPATIAL_RADIUS, 30).
|
||||
|
||||
## Telling the movement apart, and what each kind was (11-25, afternoon)
|
||||
|
||||
`raea light steady` now tells the kinds of movement in a held frame apart (engine/light/src/kinds.rs). It
|
||||
reads each 32 px square over the last 75 held frames and splits its light four ways:
|
||||
- **settling**: the square's straight-line trend over the window. The light is still building, which a real render's
|
||||
lead-in covers. It's reported as "unsettled" over p95 5%, not failed;
|
||||
- **boiling**: what's left once the trend is removed, where it's slow (lag-1 correlation 0.5 or more);
|
||||
- **jitter**: what repeats on a 2-16 frame cycle, the camera's sub-pixel jitter showing through;
|
||||
- **flicker**: what is fast with no cycle, such as a firefly, a sparkle in a reflection, or two faces at one depth.
|
||||
|
||||
Each kind has its own limit: boiling rms 1.5% with its worst square under three times that, jitter and flicker worst
|
||||
5%, and drift 0.05 stops. steady-kinds.png maps them: red is jitter or flicker, green is boiling, blue is settling.
|
||||
Before, a single number mixed them, and the fixes differ.
|
||||
|
||||
What each turned out to be on MALL RAT:
|
||||
|
||||
| hold | before | change | after |
|
||||
|---|---|---|---|
|
||||
| t1 1699 (silhouettes against the sky) | jitter worst 73%, all 3.73 | the denoiser after the sky and forward meshes (`late`) | jitter worst 3.8%, all 0.76: STEADY |
|
||||
| t2 1188 (the court, 4 paths) | jitter worst 10% on the shop signs | `late` + emissive "taa" | jitter 0.09%, worst 2.8% |
|
||||
| t2 1188 | boiling 1.27%, worst 5-7% at the frame's right edge | ReSTIR's spatial neighbours reflected back into the frame, not clamped to its border (restir.wesl) | boiling 1.21%, worst 4.25%: STEADY (t1 425: 0.58) |
|
||||
| kitchen | 0.63 all, grain 1.38 | `late` | 0.40 all, grain 0.55 |
|
||||
|
||||
- **The edges stepping with the jitter: the sky and forward meshes were drawn after the denoiser.** MetalFX ran
|
||||
before Bevy's main opaque pass (metalfx.rs `denoise`). That pass then drew the Environment's background and every
|
||||
forward mesh with the jittered camera, and nothing resolved them. Each silhouette against the sky stepped a pixel
|
||||
a frame on the 8-frame Halton cycle. `SolariSettings.late` (TSX `late`, RAEA_SOLARI_DENOISE_LATE) runs it after
|
||||
the main pass instead. The guides pass already marks a pixel with no G-buffer (sky, forward meshes) undenoised
|
||||
(mask 1) but still gathered.
|
||||
- **The shop signs' edges: MALL RAT's `emissive="split"`** puts each emitter's light back after the denoiser frame by
|
||||
frame, so emissive edges keep the jitter. The default "taa" mode gathers them over frames.
|
||||
- **A soft knee around MetalFX** (`knee`, RAEA_METALFX_KNEE; logarithmic above the white at preexposure/16) was
|
||||
tried first, on the theory that the resolve averaged bright edges in linear light. It changed nothing at t1 1699
|
||||
(73% either way), because the sky wasn't going through the resolve at all. It keeps the kitchen's mean within
|
||||
0.004 stops. It's kept for now, default 1.
|
||||
- **Not the cache's update rate or cell life.** Every cell updated every frame (`cache.updates` 2,000,000) read 1.98
|
||||
and 1.88 against 1.89. Cells kept for 600 frames unqueried (`cache.life`, RAEA_SOLARI_CELL_LIFE) read 1.34 against
|
||||
1.27. A 600-frame hold settles by about frame 300-450, but over a longer window the boiling reads higher, so the
|
||||
detector now fixes its window at 75 frames.
|
||||
- **Offline, a 64-frame average of a frozen cache's frames reads 0.50**, the kitchen's level. Of a live cache's, it
|
||||
reads no better than as rendered. So what boils is slow: the light wanders over tens of frames, longer than
|
||||
MetalFX's history.
|
||||
|
||||
## Fireflies that linger, the frame's border, and dark squares (11-25, evening)
|
||||
|
||||
A baseline of every MALL RAT take at three frames (27 holds) had the frame-wide boiling under 1.5% on all but one,
|
||||
and still failed most of them on a single worst square of 5 to 25%. Three different things were in that number.
|
||||
|
||||
- **A firefly that lingers.** A hot square's level is flat for 40 frames, jumps 30% in one frame, and takes about 30
|
||||
frames to fall back. One very bright sample (a bounce landing beside a small lamp) gets a large weight, temporal
|
||||
reuse keeps it, and spatial reuse spreads it to its neighbours. Whether a hold passed depended on whether one
|
||||
landed in its 75 frames: t7 187 read 0.88% (worst 10.1%) and, minutes later with nothing changed, 0.39% (worst
|
||||
2.0%). The party room (t5 1440), lit by small bulbs, has them all the time. This is the case RTXDI's boiling filter
|
||||
is for, and ReSTIR PT Enhanced (2026) describes the cause. raea's version is `SolariLighting.firefly_cap` (TSX
|
||||
`firefly`, RAEA_SOLARI_FIREFLY): after temporal reuse, a reservoir whose contribution is over N times the mean of
|
||||
its 8x8 block has its weight cut to that (restir.wesl, a `var<workgroup>` array and a barrier). On t5 1440:
|
||||
|
||||
| firefly | boiling | worst square | frame's mean |
|
||||
|---|---|---|---|
|
||||
| off | 1.63% | 7.4% | 0 stops |
|
||||
| 32 | 1.42% | 4.9% | -0.003 |
|
||||
| 12 | 1.06% | 6.3% | -0.15 |
|
||||
| 6 | 0.73% | 3.0% | -0.29: STEADY |
|
||||
| 3 | 0.69% | 3.9% | -0.38 |
|
||||
|
||||
It costs the light those samples carried, so it is off by default and a composition asks for it. Cutting the
|
||||
sample's confidence, not its weight (ReSTIR PT Enhanced's adaptive cap), lost nearly as much light (-0.22 at 6) and
|
||||
held less still (0.89%).
|
||||
- **The frame's border boils more, in a band as wide as the spatial reuse radius.** By distance from the border, in
|
||||
8 px steps: 0.94, 0.79, 0.67, 0.62, 0.57, then 0.5 from 48 px in (t7 187). A border pixel has half a disc of
|
||||
neighbours to reuse from. Reflecting the neighbours into the frame helped the first few pixels (above); permuting
|
||||
the 3 px border strip that `permute_pixel` leaves unpermuted changed nothing (kept, it is harmless). What production
|
||||
renderers do is overscan: render a margin and crop it. raea has no overscan yet.
|
||||
- **Dark squares read high as a plain ratio.** The detector divided each square's deviation by its level, so the
|
||||
darkest corners led (12% of nearly nothing). The eye's contrast threshold is constant in bright light (Weber) and
|
||||
rises as the square root of falling luminance in dim light (de Vries-Rose; Barten's model has both). kinds.rs now
|
||||
divides by sqrt(level x 0.05) below a level of 0.05 (linear; about 5 cd/m2 on a 100 cd/m2 display). t5 1440 read
|
||||
2.03% before and 1.59% after on the same frames.
|
||||
|
||||
What was looked up and already there: the world cache's lookups are jittered in the tangent plane (GI-1.0 and
|
||||
world-space ReSTIR name hash-cell blotches and this cure), and its blend is the adaptive one (Boissé's, in Bevy 0.18).
|
||||
|
||||
For moving shots, ReVQ (No-Reference Rendered Video Quality Assessment, arXiv 2510.13349) is the design to follow:
|
||||
windows of 5 frames warped onto their last with motion vectors, pixels without a correspondence masked, differences
|
||||
over spans of 1 to 4 frames. A first try that chained 32 frames of motion vectors read 10% on a clean shot from the
|
||||
warp's own error.
|
||||
|
||||
With the firefly filter at 6 on every take, 19 of 24 holds read STEADY (8 of 22 before). What was left, by cause:
|
||||
|
||||
- **Emitters thinner than a pixel flickered: the emitter history's clamp.** MALL RAT's ceiling tubes seen edge-on are
|
||||
1 to 3 px tall and changed shape every frame (t6 211 and t8 204: jitter 7.7% and 7.0% in their squares). With the
|
||||
history always taken (RAEA_EMIT_TAA_DEBUG=3) the jitter read 0.01%. emit_taa.wgsl held a still pixel's history
|
||||
inside the range of this frame's samples about it, so a lamp switched off goes dark at once; a tube that some of the
|
||||
jitter's positions miss altogether was cut to black on those frames. Eased (a quarter of the way to those bounds a
|
||||
frame) both holds read STEADY (jitter 2.2% and 1.2%), but lightbench's orb switched off then left +2.52 stops on its
|
||||
tile where it left +0.17 (RT32). Eased only where the history is thin (dark two pixels to both sides, across or
|
||||
down) the tubes read 3.6% and 2.1% and the orb +0.30, its rim. Two stricter tests of "thin" kept the rim out and
|
||||
lost the tubes (5.2 to 6.5%). So the engine's default is as it was (STILL_HOLD 1) and MALL RAT asks for it
|
||||
(`constants={{ emissiveClamp: { stillHold: 0.25 } }}`); the fix for every scene is a count, kept with the history,
|
||||
of the frames a pixel was missed. A softer gather kernel made it worse (11 to 13% at emissiveSharpness 3 and 1.5).
|
||||
- **The border** (above): t3 1320's wall at the frame's right edge is lit in 8 px blocks that change each frame, and
|
||||
the corner squares of t5 900 and the court boil past the worst-square limit on some runs. Overscan
|
||||
(docs/raytracing.feature RT40) is built, off by default: `<SolariLighting overscan={k}>` (RAEA_SOLARI_OVERSCAN) widens
|
||||
the camera's sub view by k a side (raea-sys-viewbox), the main pass draws that at 1 / (1 + 2k) of the view's size at
|
||||
most, MetalFX's denoiser brings it up to a texture (1 + 2k) the view's size, the emission goes back in there, and the
|
||||
middle is copied over the colour; FramePass's depth() and normal() read the middle of the wider prepass (and now read
|
||||
the right texels under a render scale below 1, which they didn't). Measured 11-25: lightbench's window draws the
|
||||
same picture with and without it (no shift, no zoom, mean difference 0.006). t3 1320 held: jitter's worst square
|
||||
16.06% without, 5.61% at 0.05 and 6.07% at 0.08 (limit 5), boiling's worst 2.32%, 3.51% and 6.1%. So it takes most
|
||||
of the border's share away and no margin clears this hold: what's left in the last two columns isn't the border.
|
||||
- A hold near the limit passes on one run and fails on the next (t2 922 and t2 2304 failed in the baseline and read
|
||||
STEADY minutes later): what's left there is chance, a firefly landing in the 75 frames or not.
|
||||
|
||||
The moving detector (scratch moving3.py, ReVQ's design on raea's own motion vectors and depth) reads 0.5% a frame on
|
||||
the court's door swing where the 32-frame chain read 10%, and tells one path a pixel from four (worst square 9.3%
|
||||
against 5.8% over 4 frames). It did not tell `late` and emissive "taa" from the settings before them on that shot,
|
||||
which has no sky edge or sign in it and whose light changes as the doors open. It needs a moving shot under steady
|
||||
light to be judged on before it gates anything.
|
||||
|
||||
@@ -13,3 +13,7 @@ serde_json = "1"
|
||||
raea-runtime-bundle = { path = "../../runtime/bundle" }
|
||||
# the home folder on every OS (HOME, then USERPROFILE)
|
||||
raea-io-home = { path = "../../io/home" }
|
||||
# a held frame's findings kept in its project's record, where raea check and raea findings read them
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# the record's UTC stamp, as raea render's
|
||||
raea-io-trace = { path = "../../io/trace" }
|
||||
@@ -0,0 +1,176 @@
|
||||
//! What moves in a held frame, told apart (steady.rs measures how much). One number hid four things that have
|
||||
//! different causes and different fixes (MALL RAT, 11-25: take 1 failed on edges, take 2 on patches):
|
||||
//!
|
||||
//! - **settling**: a square whose level climbs or falls steadily through the window. The light is still building (a
|
||||
//! world cache lit a ray a cell a frame takes hundreds of frames in a closed court): hold longer before measuring,
|
||||
//! and give a render the same lead-in.
|
||||
//! - **boiling**: a square that wanders slowly about its level (each frame close to the last: lag-1 correlation over
|
||||
//! SLOW). Traced light's patches: too few rays behind a denoiser. More paths, a cache that converges.
|
||||
//! - **jitter**: a square that repeats on a short cycle (the camera's sub-pixel jitter is 8 frames long). An edge the
|
||||
//! temporal resolve isn't holding: a silhouette against the sky or a clipped-bright doorway steps a pixel a frame.
|
||||
//! Doors, walls and beams look as if they shake.
|
||||
//! - **flicker**: fast and without a cycle. A firefly, a sparkle in a reflection, two faces fighting for one depth.
|
||||
//!
|
||||
//! Each is each LARGE square's deviation in time over its mean, with its straight-line trend taken out first, counted
|
||||
//! to the kind the square's own series shows, and reported as the rms over every lit square (the others counting as
|
||||
//! zero, so the four add in squares to the whole), with the worst square and where it is.
|
||||
|
||||
use crate::metric::Luma;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
/// A square whose deviation is under this (a fraction of its level) isn't moving: no kind.
|
||||
const QUIET: f64 = 0.0015;
|
||||
/// Lag-1 correlation from which a square's movement is slow.
|
||||
const SLOW: f64 = 0.5;
|
||||
/// The correlation with itself a cycle later from which a square repeats.
|
||||
const REPEATS: f64 = 0.6;
|
||||
/// The longest cycle looked for, frames (the jitter's is 8; a 16-frame sequence is the longest raea uses).
|
||||
const CYCLE: usize = 16;
|
||||
|
||||
/// Below this level (linear, a twentieth of white: about 5 cd/m2 on a 100 cd/m2 display) a change shows less than its
|
||||
/// ratio to the level says. The eye's contrast threshold is constant in bright light (Weber) and rises as the square
|
||||
/// root of falling luminance in dim light (de Vries-Rose; Barten's contrast sensitivity model has both). Measured as a
|
||||
/// plain ratio, MALL RAT's worst squares were its darkest corners (t5 1440, t8 510: 12% and 6% of nearly nothing).
|
||||
const DIM: f64 = 0.05;
|
||||
|
||||
/// The level a square's deviation is a fraction of: its mean in bright light, and sqrt(mean x DIM) below DIM, so a
|
||||
/// dark square's movement counts by how much of it shows.
|
||||
pub fn shown_level(mean: f64, lit: f64) -> f64 {
|
||||
let m = mean.max(lit);
|
||||
if m >= DIM { m } else { (m * DIM).sqrt() }
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Debug)]
|
||||
pub enum Kind {
|
||||
Still,
|
||||
Boiling,
|
||||
Jitter,
|
||||
Flicker,
|
||||
}
|
||||
|
||||
/// One square's series read: its kind, its deviation over its level (trend out), its trend across the window over its
|
||||
/// level, and the cycle it repeats on (0: none).
|
||||
pub fn read(series: &[f64], lit: f64) -> (Kind, f64, f64, usize) {
|
||||
let n = series.len();
|
||||
let mean = series.iter().sum::<f64>() / n as f64;
|
||||
let mid = (n as f64 - 1.0) / 2.0;
|
||||
let slope = series.iter().enumerate().map(|(t, v)| (t as f64 - mid) * v).sum::<f64>() / (0..n).map(|t| (t as f64 - mid).powi(2)).sum::<f64>().max(1e-12);
|
||||
let r: Vec<f64> = series.iter().enumerate().map(|(t, v)| v - mean - slope * (t as f64 - mid)).collect();
|
||||
let var = r.iter().map(|v| v * v).sum::<f64>() / n as f64;
|
||||
let level = shown_level(mean, lit);
|
||||
let (dev, trend) = (var.sqrt() / level, slope.abs() * (n as f64 - 1.0) / level);
|
||||
if dev < QUIET {
|
||||
return (Kind::Still, dev, trend, 0);
|
||||
}
|
||||
// the series against itself p frames later, as a correlation
|
||||
let corr = |p: usize| r[p..].iter().zip(&r).map(|(a, b)| a * b).sum::<f64>() / (n - p) as f64 / var.max(1e-18);
|
||||
let slow = corr(1) >= SLOW;
|
||||
let (mut cycle, mut best) = (0, 0.0);
|
||||
for p in 2..=CYCLE.min(n / 3) {
|
||||
let c = corr(p);
|
||||
if c > best {
|
||||
(cycle, best) = (p, c);
|
||||
}
|
||||
}
|
||||
if !slow && best >= REPEATS {
|
||||
(Kind::Jitter, dev, trend, cycle)
|
||||
} else if slow {
|
||||
(Kind::Boiling, dev, trend, 0)
|
||||
} else {
|
||||
(Kind::Flicker, dev, trend, 0)
|
||||
}
|
||||
}
|
||||
|
||||
/// The kinds of a window of held frames: the report's fields, and a picture at the frame's size (red: jitter and
|
||||
/// flicker, green: boiling, blue: settling; each white at `shown` percent).
|
||||
pub fn kinds(frames: &[Luma], k: usize, lit: f64, shown: f64) -> (Value, image::RgbImage) {
|
||||
let blocks: Vec<Luma> = frames.iter().map(|f| f.blocks(k)).collect();
|
||||
let (w, h) = (blocks[0].w, blocks[0].h);
|
||||
let pct = |v: f64| (v * 1e4).round() / 100.0;
|
||||
let mut sums = [0.0f64; 4];
|
||||
let mut counts = [0usize; 4];
|
||||
let mut worst = [(0.0f64, 0usize); 4];
|
||||
let mut cycles = vec![0usize; CYCLE + 1];
|
||||
let (mut trends, mut lit_n) = (Vec::new(), 0usize);
|
||||
let mut px = vec![[0u8; 3]; w * h];
|
||||
let level = |v: f64| (v * 100.0 / shown * 255.0).min(255.0) as u8;
|
||||
for i in 0..w * h {
|
||||
let series: Vec<f64> = blocks.iter().map(|b| b.y[i] as f64).collect();
|
||||
if series.iter().sum::<f64>() / series.len() as f64 <= lit {
|
||||
continue;
|
||||
}
|
||||
lit_n += 1;
|
||||
let (kind, dev, trend, cycle) = read(&series, lit);
|
||||
trends.push(trend);
|
||||
let j = kind as usize;
|
||||
sums[j] += dev * dev;
|
||||
counts[j] += 1;
|
||||
if dev > worst[j].0 {
|
||||
worst[j] = (dev, i);
|
||||
}
|
||||
cycles[cycle] += usize::from(kind == Kind::Jitter);
|
||||
px[i] = match kind {
|
||||
Kind::Still => [0, 0, level(trend)],
|
||||
Kind::Boiling => [0, level(dev), level(trend)],
|
||||
Kind::Jitter | Kind::Flicker => [level(dev), 0, level(trend)],
|
||||
};
|
||||
}
|
||||
trends.sort_by(|a, b| a.total_cmp(b));
|
||||
let at = |q: f64| trends.get(((trends.len() as f64 - 1.0) * q).round() as usize).copied().unwrap_or(0.0);
|
||||
let one = |j: usize| json!({ "rms": pct((sums[j] / lit_n.max(1) as f64).sqrt()), "squares": counts[j], "worst": pct(worst[j].0), "worst_at": [worst[j].1 % w * k, worst[j].1 / w * k] });
|
||||
let cycle = cycles.iter().enumerate().max_by_key(|c| *c.1).filter(|c| *c.1 > 0).map_or(0, |c| c.0);
|
||||
let report = json!({
|
||||
"boiling": one(Kind::Boiling as usize), "jitter": one(Kind::Jitter as usize), "flicker": one(Kind::Flicker as usize),
|
||||
"cycle": cycle, "settling": { "median": pct(at(0.5)), "p95": pct(at(0.95)) },
|
||||
});
|
||||
let picture = image::RgbImage::from_fn((w * k) as u32, (h * k) as u32, |x, y| image::Rgb(px[y as usize / k * w + x as usize / k]));
|
||||
(report, picture)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn rnd(seed: &mut u32) -> f64 {
|
||||
*seed = seed.wrapping_mul(1664525).wrapping_add(1013904223);
|
||||
(*seed >> 8) as f64 / (1u32 << 24) as f64 * 2.0 - 1.0
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn each_kind_of_movement_is_told_from_the_others() {
|
||||
let mut s = 3u32;
|
||||
// a level that climbs 10% and nothing else: still, with its trend
|
||||
let climb: Vec<f64> = (0..75).map(|t| 0.3 * (1.0 + 0.1 * t as f64 / 74.0)).collect();
|
||||
let (kind, dev, trend, _) = read(&climb, 0.004);
|
||||
assert_eq!(kind, Kind::Still);
|
||||
assert!(dev < 1e-6 && (trend - 0.0952).abs() < 0.01, "{dev} {trend}");
|
||||
// a slow wander: each frame a small step from the last
|
||||
let mut v = 0.0;
|
||||
let wander: Vec<f64> = (0..75).map(|_| { v = 0.92 * v + 0.01 * rnd(&mut s); 0.3 * (1.0 + v) }).collect();
|
||||
assert_eq!(read(&wander, 0.004).0, Kind::Boiling);
|
||||
// the jitter's cycle: eight levels, again and again, with a little grain on top
|
||||
let phase = [7.5, 1.7, 2.6, 10.4, 1.7, 5.6, 11.3, 1.7];
|
||||
let cycle: Vec<f64> = (0..75).map(|t| 0.02 * phase[t % 8] * (1.0 + 0.02 * rnd(&mut s))).collect();
|
||||
let (kind, dev, _, p) = read(&cycle, 0.004);
|
||||
assert_eq!((kind, p), (Kind::Jitter, 8));
|
||||
assert!(dev > 0.5, "{dev}");
|
||||
// new every frame: flicker
|
||||
let fast: Vec<f64> = (0..75).map(|_| 0.3 * (1.0 + 0.05 * rnd(&mut s))).collect();
|
||||
assert_eq!(read(&fast, 0.004).0, Kind::Flicker);
|
||||
// and a climb under a wander is still boiling, its trend kept apart
|
||||
let both: Vec<f64> = wander.iter().enumerate().map(|(t, v)| v + 0.03 * t as f64 / 74.0).collect();
|
||||
let (kind, _, trend, _) = read(&both, 0.004);
|
||||
assert_eq!(kind, Kind::Boiling);
|
||||
assert!(trend > 0.05, "{trend}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_dark_squares_movement_counts_for_less_than_its_ratio() {
|
||||
let mut s = 5u32;
|
||||
let series = |level: f64, s: &mut u32| -> Vec<f64> { (0..75).map(|_| level * (1.0 + 0.05 * rnd(s))).collect() };
|
||||
let (lit, dark) = (read(&series(0.3, &mut s), 0.004).1, read(&series(0.005, &mut s), 0.004).1);
|
||||
// the same 5% ratio: counted whole at a lit level, and by sqrt(0.005 / 0.05) at a dark one
|
||||
assert!((dark / lit - (0.005f64 / 0.05).sqrt()).abs() < 0.05, "{dark} {lit}");
|
||||
assert_eq!(shown_level(0.05, 0.004), 0.05);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@
|
||||
//! live stage, 1920x1080 by default) }.
|
||||
|
||||
pub mod metric;
|
||||
mod kinds;
|
||||
pub mod steady;
|
||||
|
||||
use raea_runtime_bundle::{flag, R};
|
||||
@@ -114,9 +115,10 @@ pub fn render_with(scene: &Scene, label: &str, env: &[(&str, String)], at: &[i64
|
||||
let run = cmd
|
||||
.args(["render", &scene.file, "--composition", &scene.composition, "--at", &at.join(","), "-o"])
|
||||
.arg(format!("{}/", out.display()))
|
||||
// a light check measures light, not placement: a set's clip (11-24: FLOOR3's fit-2 1 cm into grid-bay) is the
|
||||
// set's to fix and stays in its record, but doesn't stop the measure
|
||||
.args(["--despite", "clips", "raea light check measures light, not placement"])
|
||||
// a light check measures light, not placement or camera: a set's clip (11-24: FLOOR3's fit-2 1 cm into
|
||||
// grid-bay) and a contact sheet's cuts read as a lurching camera (11-25: gambit-street refused, every scene
|
||||
// after it unmeasured) are the piece's to fix and stay in its record, but don't stop the measure
|
||||
.args(["--despite", "all", "raea light check measures light, not placement or camera"])
|
||||
.output()
|
||||
.map_err(|e| e.to_string())?;
|
||||
if !run.status.success() {
|
||||
@@ -351,7 +353,7 @@ pub fn light(args: &[String]) -> R<String> {
|
||||
// won't be the same the next time
|
||||
let moved: Vec<String> = reports.iter().flat_map(|r| r["paths"].as_object().into_iter().flatten().filter(|(_, p)| p["steady"]["steady"] == json!(false)).map(|(path, p)| format!("{} on {path}: {}", r["name"].as_str().unwrap_or(""), steady::line(&p["steady"])))).collect();
|
||||
if !moved.is_empty() {
|
||||
return Err(format!("{said}\nthe light doesn't hold still ({}). {}", moved.join("; "), steady::WHY));
|
||||
return Err(format!("{said}\nthe light boils ({}). {}", moved.join("; "), steady::WHY));
|
||||
}
|
||||
Ok(said)
|
||||
}
|
||||
|
||||
+125
-12
@@ -35,6 +35,15 @@ const MAX: f64 = 1.5;
|
||||
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;
|
||||
/// The frames measured: the last WINDOW of a hold (or its second half, if that's shorter). Fixed, because a slow
|
||||
/// wander reads larger over a longer window, so two holds of different lengths wouldn't compare.
|
||||
const WINDOW: usize = 75;
|
||||
/// What the worst square that moves with the jitter, or flickers, may show, percent: an edge stepping a pixel a frame
|
||||
/// reads 20 to 70; a resolved one under 2.
|
||||
const MAX_FAST: f64 = 5.0;
|
||||
/// The trend across the window a hold's squares may still have (the 95th percentile), percent: over it the light was
|
||||
/// still building when it was measured, and what reads as boiling is partly that.
|
||||
const MAX_SETTLING: f64 = 5.0;
|
||||
|
||||
/// Each square's mean and deviation in time over `frames`, side `k`: (w, h, [(mean, deviation / mean)]).
|
||||
fn squares(frames: &[Luma], k: usize) -> (usize, usize, Vec<(f64, f64)>) {
|
||||
@@ -57,7 +66,7 @@ fn rms(v: impl Iterator<Item = f64>) -> f64 {
|
||||
}
|
||||
|
||||
/// The measure of held frames (the module's doc), and steady.png's picture: the large squares' deviation.
|
||||
pub fn measure(frames: &[Luma]) -> R<(Value, image::GrayImage)> {
|
||||
pub fn measure(frames: &[Luma]) -> R<(Value, image::GrayImage, image::RgbImage)> {
|
||||
if frames.len() < 8 {
|
||||
return Err(format!("{} held frames: 8 at least say whether the light holds still", frames.len()));
|
||||
}
|
||||
@@ -85,12 +94,14 @@ pub fn measure(frames: &[Luma]) -> R<(Value, image::GrayImage)> {
|
||||
let level = |f: &[Luma]| f.iter().map(|f| f.y.iter().map(|&v| v as f64).sum::<f64>() / f.y.len().max(1) as f64).sum::<f64>() / f.len() as f64;
|
||||
let q = (frames.len() / 4).max(1);
|
||||
let drift = (level(&frames[frames.len() - q..]).max(1e-6) / level(&frames[..q]).max(1e-6)).log2();
|
||||
let (kinds, kinds_map) = crate::kinds::kinds(frames, LARGE, LIT, MAX_SHOWN);
|
||||
let report = json!({
|
||||
"kinds": kinds,
|
||||
"drift": (drift * 1e3).round() / 1e3,
|
||||
"frames": frames.len(), "blotch": pct(blotch), "grain": pct(grain), "spread": ((blotch / grain.max(1e-9)) * 100.0).round() / 100.0,
|
||||
"worst": pct(worst.0), "worst_at": [worst.1, worst.2], "lit": ((large.iter().filter(lit).count() as f64 / large.len().max(1) as f64) * 100.0).round() / 100.0,
|
||||
});
|
||||
Ok((report, map))
|
||||
Ok((report, map, kinds_map))
|
||||
}
|
||||
|
||||
/// The PNG frames of a folder, in order.
|
||||
@@ -122,21 +133,45 @@ fn draw(dir: &Path, file: &str, composition: Option<&str>, how: &[&str], env: &[
|
||||
if !run.status.success() {
|
||||
return Err(format!("the held render failed: {}", err.lines().rev().take(4).collect::<Vec<_>>().into_iter().rev().collect::<Vec<_>>().join(" | ")));
|
||||
}
|
||||
Ok(())
|
||||
unshaded(out)
|
||||
}
|
||||
|
||||
/// A held run whose shaders didn't compile drew without them (a Solari pipeline that failed leaves the frame to
|
||||
/// whatever is left), and its light says nothing about the path it was held for: refused, with the shader's error.
|
||||
fn unshaded(out: &Path) -> R<()> {
|
||||
let log = std::fs::read_to_string(out.join("render.log")).unwrap_or_default();
|
||||
let Some(at) = log.find("failed to process shader") else { return Ok(()) };
|
||||
let why: Vec<&str> = log[at..].lines().skip(1).map(str::trim).filter(|l| !l.is_empty()).take(3).collect();
|
||||
Err(format!("a shader of this render didn't compile, so its frames aren't the light it was held for: {} ({}/render.log)", why.join(" "), out.display()))
|
||||
}
|
||||
|
||||
/// The held frames of `dir` measured: DIR/steady.png and steady.json written, and the report, its "steady" saying
|
||||
/// whether the light held (`max`: the blotch a run may show, percent; MAX when None).
|
||||
pub fn report(dir: &Path, max: Option<f64>) -> R<Value> {
|
||||
unshaded(dir)?;
|
||||
let max = max.unwrap_or(MAX);
|
||||
// the second half: the first is the light building from nothing, which a render's lead-in covers
|
||||
let files = held(dir)?;
|
||||
let frames: Vec<Luma> = files[files.len() / 2..].iter().map(|p| metric::load(p)).collect::<R<_>>()?;
|
||||
let (mut report, map) = measure(&frames)?;
|
||||
let frames: Vec<Luma> = files[files.len() - WINDOW.min(files.len() - files.len() / 2)..].iter().map(|p| metric::load(p)).collect::<R<_>>()?;
|
||||
let (mut report, map, kinds_map) = measure(&frames)?;
|
||||
let png = dir.join("steady.png");
|
||||
map.save(&png).map_err(|e| format!("{}: {e}", png.display()))?;
|
||||
let kinds_png = dir.join("steady-kinds.png");
|
||||
kinds_map.save(&kinds_png).map_err(|e| format!("{}: {e}", kinds_png.display()))?;
|
||||
let get = |k: &str| report[k].as_f64().unwrap_or(0.0);
|
||||
let ok = get("blotch") <= max && get("worst") <= max * 3.0 && get("drift").abs() <= MAX_DRIFT;
|
||||
let kind = |k: &str, f: &str| report["kinds"][k][f].as_f64().unwrap_or(0.0);
|
||||
// each kind against its own limit, and what failed named: the fixes differ
|
||||
let mut failed: Vec<&str> = Vec::new();
|
||||
if kind("boiling", "rms") > max || kind("boiling", "worst") > max * 3.0 { failed.push("boiling"); }
|
||||
if kind("jitter", "worst") > MAX_FAST { failed.push("jitter"); }
|
||||
if kind("flicker", "worst") > MAX_FAST { failed.push("flicker"); }
|
||||
if get("drift").abs() > MAX_DRIFT { failed.push("drift"); }
|
||||
let ok = failed.is_empty();
|
||||
let unsettled = kind("settling", "p95") > MAX_SETTLING;
|
||||
let failed: Vec<String> = failed.into_iter().map(String::from).collect();
|
||||
report["failed"] = json!(failed);
|
||||
report["unsettled"] = json!(unsettled);
|
||||
report["kinds_picture"] = json!(kinds_png);
|
||||
report["max"] = json!(max);
|
||||
report["max_drift"] = json!(MAX_DRIFT);
|
||||
report["steady"] = json!(ok);
|
||||
@@ -147,14 +182,74 @@ pub fn report(dir: &Path, max: Option<f64>) -> R<Value> {
|
||||
|
||||
/// A report as one line.
|
||||
pub fn line(r: &Value) -> String {
|
||||
let k = &r["kinds"];
|
||||
let one = |name: &str| format!("{name} {}% (worst {}% at {},{})", k[name]["rms"], k[name]["worst"], k[name]["worst_at"][0], k[name]["worst_at"][1]);
|
||||
format!(
|
||||
"drift {} stops (max {}), blotch {}% (max {}), worst {}% at {},{}, grain {}%, spread {} over {} held frames; {}",
|
||||
r["drift"], r["max_drift"], r["blotch"], r["max"], r["worst"], r["worst_at"][0], r["worst_at"][1], r["grain"], r["spread"], r["frames"], r["picture"].as_str().unwrap_or("")
|
||||
"{}{}, {}{}, {}, settling {}% (p95 {}%){}, drift {} stops (max {}); all movement {}% (blotch), grain {}%, spread {} over {} held frames; {}",
|
||||
one("boiling"), format_args!(" (max {})", r["max"]), one("jitter"), if k["cycle"].as_u64().unwrap_or(0) > 0 { format!(" on a {}-frame cycle", k["cycle"]) } else { String::new() }, one("flicker"),
|
||||
k["settling"]["median"], k["settling"]["p95"], if r["unsettled"] == json!(true) { " STILL SETTLING: hold longer (--frames) before reading the rest" } else { "" },
|
||||
r["drift"], r["max_drift"], r["blotch"], r["grain"], r["spread"], r["frames"], r["kinds_picture"].as_str().unwrap_or("")
|
||||
)
|
||||
}
|
||||
|
||||
/// What a light that doesn't hold still is told.
|
||||
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";
|
||||
/// What a held frame that moves is told, by what moved.
|
||||
pub fn why(r: &Value) -> String {
|
||||
let failed: Vec<&str> = r["failed"].as_array().map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_default();
|
||||
let mut says: Vec<String> = Vec::new();
|
||||
if failed.contains(&"boiling") || failed.contains(&"drift") { says.push(WHY.to_string()); }
|
||||
if failed.contains(&"jitter") { says.push("Jitter: squares that repeat on a short cycle are edges stepping with the camera's sub-pixel jitter, which the temporal resolve should have held: a silhouette against the sky or a clipped-bright opening. Hold it with RAEA_SOLARI_AA=0 to confirm (it goes), then keep the bright side under the resolve's range (exposure, the sky's level) or report it".to_string()); }
|
||||
if failed.contains(&"flicker") { says.push("Flicker: fast and without a cycle is a firefly, a sparkle in a reflection or two faces at one depth: look at the worst square in steady-kinds.png (red), and run raea scene lint for faces in one plane".to_string()); }
|
||||
says.join(" ")
|
||||
}
|
||||
|
||||
/// What a light that boils is told (boiling: the trade's word for low-frequency patches that crawl on a held frame).
|
||||
pub const WHY: &str = "Boiling: patches this size are light built over frames that hasn't settled. On Solari, paths (SolariLighting paths={4}) first, then 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";
|
||||
|
||||
/// The check a held frame's findings carry in the project's record, which `raea check` reads for a traced composition.
|
||||
pub const CHECK: &str = "light-steady";
|
||||
|
||||
/// A held frame's report as findings, one a kind that failed: about the composition, on the frame held.
|
||||
pub fn findings(r: &Value, composition: Option<&str>, frame: i64) -> Vec<raea_core_facts::Finding> {
|
||||
use raea_core_facts::{Finding, Level};
|
||||
let k = &r["kinds"];
|
||||
let num = |v: &Value| v.as_f64().unwrap_or(0.0);
|
||||
let at = |name: &str| format!("{},{}", k[name]["worst_at"][0], k[name]["worst_at"][1]);
|
||||
let mut out = Vec::new();
|
||||
let mut push = |kind: &str, level: Level, says: String, value: f64, limit: f64, fix: &str| {
|
||||
let mut f = Finding::new(CHECK, level, says, "raea light steady").frames(frame, frame + 1).measure(kind, value, "%", Some(limit)).fix(fix);
|
||||
if let Some(c) = composition {
|
||||
f = f.about(c, None);
|
||||
}
|
||||
out.push(f);
|
||||
};
|
||||
let failed: Vec<&str> = r["failed"].as_array().map(|a| a.iter().filter_map(Value::as_str).collect()).unwrap_or_default();
|
||||
let max = num(&r["max"]);
|
||||
if failed.contains(&"boiling") {
|
||||
push("boiling", Level::Error, format!("the light boils on frame {frame} held: {}% (worst square {}% at {}; max {max}, worst {})", k["boiling"]["rms"], k["boiling"]["worst"], at("boiling"), max * 3.0), num(&k["boiling"]["worst"]), max * 3.0, WHY);
|
||||
}
|
||||
if failed.contains(&"jitter") {
|
||||
push("jitter", Level::Error, format!("edges step with the camera's jitter on frame {frame} held: worst square {}% at {} on a {}-frame cycle (max {MAX_FAST})", k["jitter"]["worst"], at("jitter"), k["cycle"]), num(&k["jitter"]["worst"]), MAX_FAST, "an edge against the sky, a forward mesh or an emitter left out of the denoiser's history: SolariLighting late and emissive=\"taa\" (the Solari guide)");
|
||||
}
|
||||
if failed.contains(&"flicker") {
|
||||
push("flicker", Level::Error, format!("a square flickers on frame {frame} held: {}% at {} (max {MAX_FAST})", k["flicker"]["worst"], at("flicker")), num(&k["flicker"]["worst"]), MAX_FAST, "a firefly, a sparkle in a reflection or two faces in one plane: look at the square in steady-kinds.png, and run raea scene lint for faces in one plane");
|
||||
}
|
||||
if failed.contains(&"drift") {
|
||||
push("drift", Level::Error, format!("the held frame's light drifts {} stops (max {MAX_DRIFT})", r["drift"]), num(&r["drift"]).abs(), MAX_DRIFT, WHY);
|
||||
}
|
||||
if failed.is_empty() {
|
||||
push("steady", Level::Note, format!("the light holds still on frame {frame} held: {}", line(r)), num(&r["blotch"]), max, "");
|
||||
}
|
||||
if r["unsettled"] == json!(true) {
|
||||
push("settling", Level::Note, format!("the light was still building on frame {frame} held (settling p95 {}%): hold longer, or give the shot a lead-in", k["settling"]["p95"]), num(&k["settling"]["p95"]), MAX_SETTLING, "a still lead-in before the shot, as long as the hold took to settle");
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A held frame's findings kept in `file`'s project's record (nothing outside a project).
|
||||
fn keep(file: &str, out: &Path, r: &Value, composition: Option<&str>, frame: i64) {
|
||||
let stamp = raea_io_trace::utc(std::time::SystemTime::now()).1;
|
||||
raea_core_facts::record::keep("raea light steady", Path::new(file), Some(out), &findings(r, composition, frame), Vec::new(), &stamp);
|
||||
}
|
||||
|
||||
pub fn steady(args: &[String]) -> R<String> {
|
||||
let first = args.first().ok_or(format!("usage: {USAGE}"))?;
|
||||
@@ -169,6 +264,10 @@ pub fn steady(args: &[String]) -> R<String> {
|
||||
out
|
||||
};
|
||||
let mut r = report(&dir, max)?;
|
||||
let held_frame = flag(args, "--frame").and_then(|f| f.parse::<i64>().ok());
|
||||
if let (false, Some(f)) = (Path::new(first).is_dir(), held_frame) {
|
||||
keep(first, dir.parent().unwrap_or(&dir), &r, flag(args, "--composition").as_deref(), f);
|
||||
}
|
||||
// --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
|
||||
@@ -191,9 +290,9 @@ pub fn steady(args: &[String]) -> R<String> {
|
||||
}
|
||||
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}")) };
|
||||
return if r["steady"] == json!(true) { Ok(format!("STEADY {said}")) } else { Err(format!("the held frame moves ({}): {said}. {}", r["failed"].as_array().map(|a| a.iter().filter_map(Value::as_str).collect::<Vec<_>>().join(", ")).unwrap_or_default(), why(&r))) };
|
||||
}
|
||||
if r["steady"] == json!(true) { Ok(format!("STEADY {}", line(&r))) } else { Err(format!("the light doesn't hold still: {}. {WHY}", line(&r))) }
|
||||
if r["steady"] == json!(true) { Ok(format!("STEADY {}", line(&r))) } else { Err(format!("the held frame moves ({}): {}. {}", r["failed"].as_array().map(|a| a.iter().filter_map(Value::as_str).collect::<Vec<_>>().join(", ")).unwrap_or_default(), line(&r), why(&r))) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -221,6 +320,7 @@ mod tests {
|
||||
#[test]
|
||||
fn grain_is_steady_and_blotches_are_not() {
|
||||
let still = measure(&frames(0.0, 0.0)).unwrap().0;
|
||||
assert_eq!(still["kinds"]["boiling"]["rms"], 0.0);
|
||||
assert_eq!(still["blotch"], 0.0);
|
||||
assert_eq!(still["drift"], 0.0);
|
||||
// a light that doubles over the held frames: about 0.8 of a stop between the first and the last quarter
|
||||
@@ -237,4 +337,17 @@ mod tests {
|
||||
assert!(blotch["blotch"].as_f64().unwrap() > 2.0, "{blotch}");
|
||||
assert!(blotch["spread"].as_f64().unwrap() > 0.6, "{blotch}");
|
||||
}
|
||||
|
||||
/// A run whose shaders failed isn't measured: its frames are another light's.
|
||||
#[test]
|
||||
fn a_run_that_drew_without_its_shaders_is_refused() {
|
||||
let dir = std::env::temp_dir().join(format!("raea-steady-unshaded-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
std::fs::write(dir.join("render.log"), "ERROR bevy_render::render_resource::pipeline_cache: failed to process shader error:\n use of a reserved word `target`\n").unwrap();
|
||||
let e = report(&dir, None).unwrap_err();
|
||||
assert!(e.contains("didn't compile") && e.contains("reserved word"), "{e}");
|
||||
std::fs::write(dir.join("render.log"), "APPLIED 96 frames\n").unwrap();
|
||||
assert!(unshaded(&dir).is_ok());
|
||||
let _ = std::fs::remove_dir_all(&dir);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ raea-sys-gi = { path = "../../systems/gi" }
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "multi_threaded", "3d_bevy_render", "ui_bevy_render", "png", "tonemapping_luts", "ktx2", "zstd_rust"] }
|
||||
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "hdr"] }
|
||||
# an edit as rows keyed per frame, and 3D shapes as values (docs/media.feature M2)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
raea-core-program = { path = "../../core/program" }
|
||||
# procedural surfaces on a mesh row (`proc`)
|
||||
raea-sys-procmat = { path = "../../systems/procmat" }
|
||||
|
||||
@@ -11,6 +11,8 @@ description = "raea-render's ray tracing: Bevy's Solari for a scene whose camera
|
||||
raea-io-trace = { path = "../../../io/trace" }
|
||||
# the jitter's Halton places (a facility of raea-sys-post's steady)
|
||||
raea-sys-post = { path = "../../../systems/post" }
|
||||
# Overscan, the camera's wider view (the denoiser crops it back)
|
||||
raea-sys-viewbox = { path = "../../../systems/viewbox" }
|
||||
serde_json = "1"
|
||||
# its own wgpu shaders read from a project's engine-shaders/ or the checkout (RAEA_ENGINE_SHADERS), as the embedded ones
|
||||
raea-sys-engine-shaders = { path = "../../../systems/engine-shaders" }
|
||||
|
||||
@@ -18,6 +18,16 @@ const HISTORY_CAP: f32 = 16.0;
|
||||
// a still pixel's history held within what's about it now, its darkest and brightest times these
|
||||
const STILL_LOW: f32 = 0.95;
|
||||
const STILL_HIGH: f32 = 1.05;
|
||||
// how far a still pixel's history goes toward those bounds a frame where it's thin (THIN). At 1, the default, it's held
|
||||
// to them at once, and an emitter under a pixel tall, which some of the jitter's positions miss altogether, is cut to
|
||||
// black on those frames and built again on the others: MALL RAT's ceiling tubes seen edge-on changed shape every frame
|
||||
// (raea light steady: jitter 7% and 8% in their squares, 0.01% with the history always taken). At a quarter
|
||||
// (<SolariLighting constants={{ emissiveClamp: { stillHold: 0.25 } }} />) they read 2.1% and 3.6%, and a 30000-nit
|
||||
// orb switched off leaves its rim behind: +0.30 stops on its tile against +0.17, +0.26 eight frames on (lightbench
|
||||
// window-still-off-q against -one). So it's a scene's choice until a pixel can count the frames it was missed
|
||||
const STILL_HOLD: f32 = 1.0;
|
||||
// a history counts as thin where the brighter of its two sides, two pixels off, is under this much of it
|
||||
const THIN: f32 = 0.25;
|
||||
// a moving pixel's history held under this many times the brightest about it, plus this
|
||||
const MOVING_GAIN: f32 = 4.0;
|
||||
const MOVING_FLOOR: f32 = 0.02;
|
||||
@@ -190,7 +200,23 @@ fn restore_taa(@builtin(global_invocation_id) id: vec3<u32>) {
|
||||
// them (a lamp switched off goes dark at once, rim and all, not over a second)
|
||||
let reach = select(1.5, 1.05, still);
|
||||
if (hd.b * reach >= zlo && hd.a <= zhi * reach && params[0].w != 3.0) {
|
||||
hrgb = clamped;
|
||||
// eased only where the history is a thin line or a point: an emitter under a pixel wide is all the jitter can miss outright. A lamp's or an orb's
|
||||
// face and rim have light to one side, and go dark at once (RT32: eased everywhere, a 30000-nit orb
|
||||
// switched off left +2.5 stops on its tile for 8 frames and +0.8 at 16; eased on thin histories, +0.30
|
||||
// against +0.17 clamped at once, the orb's rim where it's dark to both sides)
|
||||
var hold = 1.0;
|
||||
if (still) {
|
||||
let px = 2.0 / out_size;
|
||||
let lw = vec3<f32>(0.2126, 0.7152, 0.0722);
|
||||
let l0 = dot(hrgb, lw) * THIN;
|
||||
let lx = max(dot(textureSampleLevel(hist_in, hist_sampler, was + vec2<f32>(px.x, 0.0), 0.0).rgb, lw), dot(textureSampleLevel(hist_in, hist_sampler, was - vec2<f32>(px.x, 0.0), 0.0).rgb, lw));
|
||||
let ly = max(dot(textureSampleLevel(hist_in, hist_sampler, was + vec2<f32>(0.0, px.y), 0.0).rgb, lw), dot(textureSampleLevel(hist_in, hist_sampler, was - vec2<f32>(0.0, px.y), 0.0).rgb, lw));
|
||||
// stricter tests of "thin" kept the orb's rim out (+0.18 by the second frame) and lost the tubes:
|
||||
// a line alike along itself, 5.2 and 5.8%; a ring of eight with each lit place lit across, 6.2 and
|
||||
// 6.5% (the tubes hang in rows, so a tube's neighbours light one side of it)
|
||||
if (min(lx, ly) < l0) { hold = STILL_HOLD; }
|
||||
}
|
||||
hrgb = mix(hrgb, clamped, hold);
|
||||
dbg_f += 8.0;
|
||||
}
|
||||
}
|
||||
@@ -232,5 +258,5 @@ fn restore_taa(@builtin(global_invocation_id) id: vec3<u32>) {
|
||||
textureStore(color, p, vec4<f32>(weight, hist.a / HISTORY_CAP, f32(hist.a > 0.0), c.a));
|
||||
return;
|
||||
}
|
||||
textureStore(color, p, vec4<f32>(c.rgb + e, c.a));
|
||||
textureStore(color, p, vec4<f32>(uncompress(c.rgb) + e, c.a));
|
||||
}
|
||||
@@ -58,6 +58,16 @@ pub struct SolariSettings {
|
||||
/// what MetalFX divides the colour by before it denoises and multiplies it by after: bright light kept, at the cost
|
||||
/// of fireflies past 16 (metalfx.rs pre_exposure; RAEA_METALFX_PREEXPOSURE)
|
||||
pub preexposure: f32,
|
||||
/// where the denoiser's soft knee starts, in its white (the colour at `preexposure / 16`); 0 turns it off
|
||||
/// (RAEA_METALFX_KNEE). Above it a pixel's light goes in as its log: W (1 + ln(m / W)), its colour scaled to match,
|
||||
/// and comes out undone after the denoiser. MetalFX averages a silhouette against bright sky or a lit doorway in
|
||||
/// linear light, so its jittered edge pixel swung with the sky's share, 8 frames a cycle (MALL RAT t1 frame 1699:
|
||||
/// steady 3.72, 0.81 with the jitter off). Light under the knee is untouched, so it isn't biased
|
||||
pub knee: f32,
|
||||
/// a full-size view denoised after the main pass instead of before it, so the sky and the forward meshes (drawn
|
||||
/// there, with the jittered camera) are gathered over frames too and their edges stop stepping with the jitter
|
||||
/// (metalfx.rs denoise_late; RAEA_SOLARI_DENOISE_LATE)
|
||||
pub late: bool,
|
||||
/// a full-size view jittered too, so the denoiser anti-aliases its edges as it gathers frames (RAEA_SOLARI_AA=0)
|
||||
pub aa: bool,
|
||||
/// which of MetalFX's passes is told the jitter: "" the denoiser, "scaler", "both", "flip", "0" none (and none is
|
||||
@@ -74,6 +84,11 @@ pub struct SolariSettings {
|
||||
/// the traced scene follows what moves: a skinned mesh's traced twin posed each frame (RT5, a trial;
|
||||
/// RAEA_SOLARI_DYNAMIC). A hidden part leaves the traced scene with or without it (SG9)
|
||||
pub dynamic: bool,
|
||||
/// overscan: the main pass draws this much of the view more on every side (0.05 is a twentieth), and the denoiser
|
||||
/// crops the middle back out, so the light at the frame's border has neighbours and history to gather from as the
|
||||
/// camera moves (RT40; RAEA_SOLARI_OVERSCAN). 0, the default, is off. The view then draws at 1 / (1 + 2 x overscan)
|
||||
/// of its size at most and is brought up; with the denoiser off, or `upscale` "two", it does nothing
|
||||
pub overscan: f32,
|
||||
}
|
||||
|
||||
impl Default for SolariSettings {
|
||||
@@ -85,11 +100,14 @@ impl Default for SolariSettings {
|
||||
emissive: "taa".into(),
|
||||
upscale: "one".into(),
|
||||
preexposure: 16.0,
|
||||
knee: 1.0,
|
||||
late: false,
|
||||
aa: true,
|
||||
jitter: String::new(),
|
||||
emissive_sharpness: 6.0,
|
||||
jitter_frames: 8.0,
|
||||
dynamic: false,
|
||||
overscan: 0.0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ pub(crate) fn add(app: &mut App) {
|
||||
};
|
||||
core.add_systems(denoise.after(solari).before(main_opaque_pass_3d).in_set(Core3dSystems::MainPass));
|
||||
core.add_systems(denoise_up.before(super::upscale::upscale).in_set(Core3dSystems::EarlyPostProcess));
|
||||
core.add_systems(denoise_late.before(super::upscale::upscale).in_set(Core3dSystems::EarlyPostProcess));
|
||||
// Solari's own guides (primary surface replacement: a mirror's pixel takes what it reflects, and a glossy one is as
|
||||
// far off as what it reflects, RT34), written for every view; a view's `guides` and `reflection_depth` choose whether
|
||||
// its denoiser reads them
|
||||
@@ -88,13 +89,15 @@ struct View {
|
||||
/// the split emission's history (RAEA_SOLARI_EMISSIVE=taa, emit_taa.rs)
|
||||
taa: Option<super::emit_taa::History>,
|
||||
fresh: bool,
|
||||
/// overscan: the output is wider than the colour, and `run` copies its middle over once the emission is back in
|
||||
cropped: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Kit {
|
||||
/// the guides (and the emissive out), the emissive back in, from this frame or gathered over frames (emit_taa.rs),
|
||||
/// and the sampler that reads the gathered emission's history
|
||||
pipeline: Option<(wgpu::ComputePipeline, wgpu::ComputePipeline, wgpu::ComputePipeline, wgpu::Sampler, wgpu::ComputePipeline)>,
|
||||
pipeline: Option<(wgpu::ComputePipeline, wgpu::ComputePipeline, wgpu::ComputePipeline, wgpu::Sampler, wgpu::ComputePipeline, wgpu::ComputePipeline)>,
|
||||
views: HashMap<Entity, View>,
|
||||
off: bool,
|
||||
}
|
||||
@@ -161,7 +164,7 @@ impl View {
|
||||
mask: texture(dev, size, wgpu::TextureFormat::R32Float, guide, "metalfx denoise strength"),
|
||||
out: texture(dev, out_size, wgpu::TextureFormat::Rgba16Float, guide | U::RENDER_ATTACHMENT | U::COPY_SRC, "metalfx output"),
|
||||
taa: taa.then(|| super::emit_taa::History::new(dev, out_size)),
|
||||
fresh: true,
|
||||
fresh: true, cropped: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -204,15 +207,30 @@ impl View {
|
||||
s.setShouldResetHistory(reset || self.fresh);
|
||||
matrices(s, view.world_from_view.to_matrix().inverse(), view.clip_from_view);
|
||||
s.encodeToCommandBuffer(cb);
|
||||
let blit = cb.blitCommandEncoder().ok_or("no blit encoder")?;
|
||||
let o = MTLOrigin { x: 0, y: 0, z: 0 };
|
||||
let size = MTLSize { width: self.out_size.x as _, height: self.out_size.y as _, depth: 1 };
|
||||
blit.copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(&out, 0, 0, o, size, &color, 0, 0, o);
|
||||
blit.endEncoding();
|
||||
if !self.cropped {
|
||||
let blit = cb.blitCommandEncoder().ok_or("no blit encoder")?;
|
||||
let o = MTLOrigin { x: 0, y: 0, z: 0 };
|
||||
let size = MTLSize { width: self.out_size.x as _, height: self.out_size.y as _, depth: 1 };
|
||||
blit.copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(&out, 0, 0, o, size, &color, 0, 0, o);
|
||||
blit.endEncoding();
|
||||
}
|
||||
}
|
||||
self.fresh = false;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Overscan: the `full` middle of the wider output, from `at`, over the colour.
|
||||
fn crop_onto(&self, cb: &ProtocolObject<dyn MTLCommandBuffer>, color: &wgpu::Texture, at: UVec2, full: UVec2) -> Result<(), &'static str> {
|
||||
let (out, color) = (mtl(&self.out).ok_or("a texture isn't a Metal one")?, mtl(color).ok_or("a texture isn't a Metal one")?);
|
||||
unsafe {
|
||||
let blit = cb.blitCommandEncoder().ok_or("no blit encoder")?;
|
||||
let from = MTLOrigin { x: at.x as _, y: at.y as _, z: 0 };
|
||||
let size = MTLSize { width: full.x as _, height: full.y as _, depth: 1 };
|
||||
blit.copyFromTexture_sourceSlice_sourceLevel_sourceOrigin_sourceSize_toTexture_destinationSlice_destinationLevel_destinationOrigin(&out, 0, 0, from, size, &color, 0, 0, MTLOrigin { x: 0, y: 0, z: 0 });
|
||||
blit.endEncoding();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// worldToViewMatrix and viewToClipMatrix, simd_float4x4 properties objc2-metal-fx leaves out (no simd types in
|
||||
@@ -240,7 +258,7 @@ fn matrices(s: &ProtocolObject<dyn MTLFXTemporalDenoisedScaler>, world_to_view:
|
||||
}
|
||||
}
|
||||
|
||||
type Viewed = (&'static ViewTarget, &'static ViewPrepassTextures, &'static ExtractedView, &'static ExtractedCamera, &'static SolariLighting, Option<&'static MainPassResolutionOverride>, Option<&'static TemporalJitter>, Has<super::upscale::Upscaled>, Option<&'static SolariGuideTextures>, Option<&'static super::SolariSettings>);
|
||||
type Viewed = (&'static ViewTarget, &'static ViewPrepassTextures, &'static ExtractedView, &'static ExtractedCamera, &'static SolariLighting, Option<&'static MainPassResolutionOverride>, Option<&'static TemporalJitter>, Has<super::upscale::Upscaled>, Option<&'static SolariGuideTextures>, Option<&'static super::SolariSettings>, Option<&'static raea_sys_viewbox::Overscan>);
|
||||
|
||||
/// Before the forward meshes: a view at its full size, or one drawn small whose settings upscale in "two" (its corner).
|
||||
/// Each view's settings go into the run's trace here, once and on a change.
|
||||
@@ -250,8 +268,23 @@ fn denoise(view: ViewQuery<Viewed>, device: Res<RenderDevice>, mut kit: Local<Ki
|
||||
let st = super::settings::of(item.9);
|
||||
let scale = item.5.map_or(1.0, |p| p.0.x as f32 / item.0.main_texture().width() as f32);
|
||||
super::settings::record(entity, &st, scale, &mut seen);
|
||||
// a view drawn small is denoised and brought up in one pass, unless its upscale is "two"
|
||||
if !st.denoise || (item.7 && st.upscale != "two") {
|
||||
// a view drawn small is denoised and brought up in one pass, unless its upscale is "two"; one whose settings say
|
||||
// `late` after the forward meshes and the sky (denoise_late)
|
||||
if !st.denoise || (item.7 && st.upscale != "two") || (st.late && !item.7) {
|
||||
return;
|
||||
}
|
||||
run(entity, item, &st, &device, &mut kit, &mut ctx, false);
|
||||
}
|
||||
|
||||
/// After the main pass: a view at its full size whose settings say `late`, so the sky and the forward meshes, drawn with
|
||||
/// the jittered camera after Solari, are gathered over frames with the rest. Drawn after the denoiser, they kept the
|
||||
/// jitter: a silhouette against the sky stepped a pixel a frame on its 8-frame cycle (MALL RAT t1 frame 1699, steady's
|
||||
/// jitter worst square 73%)
|
||||
fn denoise_late(view: ViewQuery<Viewed>, device: Res<RenderDevice>, mut kit: Local<Kit>, mut ctx: RenderContext) {
|
||||
let entity = view.entity();
|
||||
let item = view.into_inner();
|
||||
let st = super::settings::of(item.9);
|
||||
if !st.denoise || item.7 || !st.late {
|
||||
return;
|
||||
}
|
||||
run(entity, item, &st, &device, &mut kit, &mut ctx, false);
|
||||
@@ -268,7 +301,7 @@ fn denoise_up(view: ViewQuery<Viewed>, device: Res<RenderDevice>, mut kit: Local
|
||||
run(entity, item, &st, &device, &mut kit, &mut ctx, true);
|
||||
}
|
||||
|
||||
type Item<'a> = (&'a ViewTarget, &'a ViewPrepassTextures, &'a ExtractedView, &'a ExtractedCamera, &'a SolariLighting, Option<&'a MainPassResolutionOverride>, Option<&'a TemporalJitter>, bool, Option<&'a SolariGuideTextures>, Option<&'a super::SolariSettings>);
|
||||
type Item<'a> = (&'a ViewTarget, &'a ViewPrepassTextures, &'a ExtractedView, &'a ExtractedCamera, &'a SolariLighting, Option<&'a MainPassResolutionOverride>, Option<&'a TemporalJitter>, bool, Option<&'a SolariGuideTextures>, Option<&'a super::SolariSettings>, Option<&'a raea_sys_viewbox::Overscan>);
|
||||
|
||||
/// The guides from the G-buffer and the emissive out, at the main pass's size; MetalFX's denoiser, out to the whole
|
||||
/// view when `up`; its output over the colour and the emissive back in.
|
||||
@@ -276,7 +309,7 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDe
|
||||
if kit.off {
|
||||
return;
|
||||
}
|
||||
let (target, pre, ext, cam, solari, part, jitter, _, guides, _) = item;
|
||||
let (target, pre, ext, cam, solari, part, jitter, _, guides, _, over) = item;
|
||||
// Solari wrote its guides for every view; this one reads them unless its settings say the G-buffer's
|
||||
let guides = guides.filter(|_| st.guides);
|
||||
let (Some(depth), Some(motion), Some(gbuf)) = (pre.depth.as_ref(), pre.motion_vectors.as_ref(), pre.deferred.as_ref()) else { return };
|
||||
@@ -286,7 +319,12 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDe
|
||||
let color: &wgpu::Texture = target.main_texture();
|
||||
let full = UVec2::new(color.width(), color.height());
|
||||
let size = part.map_or(full, |p| p.0);
|
||||
let out_size = if up { full } else { size };
|
||||
// overscan: the main pass drew the view wider, so the denoised frame is wider than the colour, and its middle is
|
||||
// what the colour takes (below)
|
||||
let k = if up { raea_sys_viewbox::Overscan::drawn(over) } else { 0.0 };
|
||||
let wide = (full.as_vec2() * (1.0 + 2.0 * k)).round().as_uvec2();
|
||||
let crop = (k > 0.0).then(|| (wide - full) / 2);
|
||||
let out_size = if !up { size } else if crop.is_some() { wide } else { full };
|
||||
let jitter = jitter.map_or(Vec2::ZERO, |j| -j.offset * super::upscale::jitter_gain(&st.jitter, true, true));
|
||||
let dev = device.wgpu_device().clone();
|
||||
// with Solari's guides, the denoiser's depth is theirs: a mirror's pixel as far off as what it reflects, so when what
|
||||
@@ -302,12 +340,13 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDe
|
||||
}
|
||||
Err(e) => {
|
||||
kit.off = true;
|
||||
super::upscale::NO_DENOISER.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||
eprintln!("raea: <SolariLighting>: no MetalFX denoiser ({e}); the lighting draws un-denoised (docs/raytracing.feature RT4)");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
let (pipeline, restore, restore_taa, hist_sampler, pipeline_psr) = kit
|
||||
let (pipeline, restore, restore_taa, hist_sampler, pipeline_psr, expand) = kit
|
||||
.pipeline
|
||||
.get_or_insert_with(|| {
|
||||
// read from a project's engine-shaders/ or the checkout when one has them (docs/nobuild.feature NB5b)
|
||||
@@ -316,18 +355,19 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDe
|
||||
let source = format!("{guides}{taa}");
|
||||
let module = dev.create_shader_module(wgpu::ShaderModuleDescriptor { label: Some("metalfx guides"), source: wgpu::ShaderSource::Wgsl(source.into()) });
|
||||
let make = |entry: &str| dev.create_compute_pipeline(&wgpu::ComputePipelineDescriptor { label: Some("metalfx guides"), layout: None, module: &module, entry_point: Some(entry), compilation_options: Default::default(), cache: None });
|
||||
(make("main"), make("restore"), make("restore_taa"), super::emit_taa::sampler(&dev), make("main_psr"))
|
||||
(make("main"), make("restore"), make("restore_taa"), super::emit_taa::sampler(&dev), make("main_psr"), make("expand"))
|
||||
})
|
||||
.clone();
|
||||
let color_view = color.create_view(&Default::default());
|
||||
let back = ext.world_from_view.back();
|
||||
let reset = solari.reset || kit.views.get(&entity).is_none_or(|v| v.fresh);
|
||||
// the jitter's cycle at this render scale, how long a twig glimpsed through it can stay away (emit_taa.wgsl)
|
||||
let cycle = super::upscale::cycle(size.x as f32 / full.x as f32, st.jitter_frames) as f32;
|
||||
let words: [f32; 16] = [cam.exposure, if split { 1.0 } else { 0.0 }, if reset { 1.0 } else { 0.0 }, super::emit_taa::debug(), out_size.x as f32, out_size.y as f32, size.x as f32, size.y as f32, back.x, back.y, back.z, st.emissive_sharpness, jitter.x, jitter.y, cycle, 0.0];
|
||||
let cycle = super::upscale::cycle(size.x as f32 / out_size.x.max(full.x) as f32, st.jitter_frames) as f32;
|
||||
let words: [f32; 16] = [cam.exposure, if split { 1.0 } else { 0.0 }, if reset { 1.0 } else { 0.0 }, super::emit_taa::debug(), out_size.x as f32, out_size.y as f32, size.x as f32, size.y as f32, back.x, back.y, back.z, st.emissive_sharpness, jitter.x, jitter.y, cycle, st.knee.max(0.0) * st.preexposure / 16.0];
|
||||
let bytes: Vec<u8> = words.iter().flat_map(|w| w.to_ne_bytes()).collect();
|
||||
let params = wgpu::util::DeviceExt::create_buffer_init(&dev, &wgpu::util::BufferInitDescriptor { label: Some("metalfx params"), contents: &bytes, usage: wgpu::BufferUsages::UNIFORM });
|
||||
let v = kit.views.get_mut(&entity).unwrap();
|
||||
v.cropped = crop.is_some();
|
||||
let views = [&v.diffuse, &v.specular, &v.normal, &v.rough].map(|t| t.create_view(&Default::default()));
|
||||
let mut entries = vec![wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::TextureView(&*gbuf.texture.default_view) }];
|
||||
for (i, tv) in views.iter().enumerate() {
|
||||
@@ -368,6 +408,9 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDe
|
||||
})
|
||||
};
|
||||
ctx.add_command_buffer(raw.finish());
|
||||
// overscan: the emission goes back into the denoiser's wider output, whose middle the colour then takes
|
||||
let out_view = v.out.create_view(&Default::default());
|
||||
let color_view = if crop.is_some() { out_view } else { color_view };
|
||||
// the emissive back in, after the denoiser's command buffer (add_command_buffer flushed the encoder before it)
|
||||
if split {
|
||||
let mut entries = vec![
|
||||
@@ -391,6 +434,31 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDe
|
||||
pass.dispatch_workgroups(out_size.x.div_ceil(8), out_size.y.div_ceil(8), 1);
|
||||
}
|
||||
}
|
||||
// the knee undone where no `restore` ran (emissive "mask")
|
||||
if !split && st.knee > 0.0 {
|
||||
let entries = [
|
||||
wgpu::BindGroupEntry { binding: 5, resource: wgpu::BindingResource::TextureView(&color_view) },
|
||||
wgpu::BindGroupEntry { binding: 6, resource: params.as_entire_binding() },
|
||||
];
|
||||
let bind = dev.create_bind_group(&wgpu::BindGroupDescriptor { label: Some("metalfx knee undone"), layout: &expand.get_bind_group_layout(0), entries: &entries });
|
||||
let mut pass = ctx.command_encoder().begin_compute_pass(&wgpu::ComputePassDescriptor { label: Some("metalfx knee undone"), timestamp_writes: None });
|
||||
pass.set_pipeline(&expand);
|
||||
pass.set_bind_group(0, &bind, &[]);
|
||||
pass.dispatch_workgroups(out_size.x.div_ceil(8), out_size.y.div_ceil(8), 1);
|
||||
}
|
||||
// the middle of the wider output over the colour: a raw blit as the denoiser's own (the colour has no COPY_DST for
|
||||
// wgpu's), in a command buffer after the emission's (add_command_buffer flushes the encoder before it)
|
||||
let mut done = done;
|
||||
if let (Some(at), true) = (crop, done.is_ok()) {
|
||||
let mut raw = dev.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("metalfx overscan crop") });
|
||||
done = unsafe {
|
||||
raw.as_hal_mut::<Metal, _, _>(|e| match e.and_then(|e| e.raw_command_buffer()) {
|
||||
Some(cb) => v.crop_onto(cb, color, at, full),
|
||||
None => Err("wgpu gave no Metal command buffer"),
|
||||
})
|
||||
};
|
||||
ctx.add_command_buffer(raw.finish());
|
||||
}
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
super::upscale::DENOISED.store(done.is_ok(), Relaxed);
|
||||
super::upscale::DENOISING.store(done.is_ok(), Relaxed);
|
||||
@@ -399,6 +467,7 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDe
|
||||
}
|
||||
if let Err(e) = done {
|
||||
kit.off = true;
|
||||
super::upscale::NO_DENOISER.store(true, Relaxed);
|
||||
eprintln!("raea: <SolariLighting>: the MetalFX denoiser stopped ({e}); the lighting draws un-denoised");
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,28 @@
|
||||
@group(0) @binding(5) var color: texture_storage_2d<rgba16float, read_write>;
|
||||
// [0].x: the camera's exposure, .y: 1 to split all emission out (RAEA_SOLARI_EMISSIVE=split); [1]: the output's size
|
||||
// and the input's (the corner of the colour the main pass drew); [2].xyz: the camera's back, world-space; [3].xy: the
|
||||
// jitter MetalFX is told, in input pixels
|
||||
// jitter MetalFX is told, in input pixels, .w: where the soft knee starts in the colour (0: none; SolariSettings.knee)
|
||||
@group(0) @binding(6) var<uniform> params: array<vec4<f32>, 4>;
|
||||
// the emission `main` took out of the colour, at the input's size, for `restore` to put back
|
||||
@group(0) @binding(7) var emit: texture_storage_2d<rgba16float, read_write>;
|
||||
// MetalFX's denoise strength mask: 1 leaves a pixel undenoised
|
||||
@group(0) @binding(8) var mask: texture_storage_2d<r32float, write>;
|
||||
// The soft knee (SolariSettings.knee): above W a pixel's light m (its largest channel) goes in as W (1 + ln(m / W)),
|
||||
// which meets the line at W with the same slope, and its colour is scaled to match; `expand` undoes it after the
|
||||
// denoiser. Logarithmic rather than Reinhard's m / (1 + m): its half floats keep a bright pixel's light to about 0.5%,
|
||||
// where Reinhard's curve crowds every highlight just under its ceiling and loses them
|
||||
fn compress(c: vec3<f32>) -> vec3<f32> {
|
||||
let w = params[3].w;
|
||||
let m = max(c.r, max(c.g, c.b));
|
||||
if (w <= 0.0 || m <= w) { return c; }
|
||||
return c * (w * (1.0 + log(m / w)) / m);
|
||||
}
|
||||
fn uncompress(c: vec3<f32>) -> vec3<f32> {
|
||||
let w = params[3].w;
|
||||
let m = max(c.r, max(c.g, c.b));
|
||||
if (w <= 0.0 || m <= w) { return c; }
|
||||
return c * (w * exp(min(m / w - 1.0, 80.0)) / m);
|
||||
}
|
||||
fn rgb9e5(v: u32) -> vec3<f32> {
|
||||
let scale = exp2(f32(i32(extractBits(v, 27u, 5u)) - 15 - 9));
|
||||
return vec3<f32>(f32(extractBits(v, 0u, 9u)), f32(extractBits(v, 9u, 9u)), f32(extractBits(v, 18u, 9u))) * scale;
|
||||
@@ -84,6 +100,7 @@ fn sky(p: vec2<i32>) {
|
||||
textureStore(rough, p, vec4<f32>(1.0, 0.0, 0.0, 0.0));
|
||||
textureStore(emit, p, vec4<f32>(0.0));
|
||||
textureStore(mask, p, vec4<f32>(1.0, 0.0, 0.0, 0.0));
|
||||
textureStore(color, p, vec4<f32>(compress(c), textureLoad(color, p).a));
|
||||
}
|
||||
fn store(p: vec2<i32>, g: vec4<u32>, s: Surface) {
|
||||
textureStore(normal, p, vec4<f32>(s.normal, 0.0));
|
||||
@@ -95,7 +112,7 @@ fn store(p: vec2<i32>, g: vec4<u32>, s: Surface) {
|
||||
if (params[0].y > 0.5) {
|
||||
let taken = min(e, c.rgb);
|
||||
textureStore(diffuse, p, vec4<f32>(s.diffuse, 1.0));
|
||||
textureStore(color, p, vec4<f32>(c.rgb - taken, c.a));
|
||||
textureStore(color, p, vec4<f32>(compress(c.rgb - taken), c.a));
|
||||
textureStore(emit, p, vec4<f32>(taken, 0.0));
|
||||
textureStore(mask, p, vec4<f32>(0.0));
|
||||
return;
|
||||
@@ -104,6 +121,7 @@ fn store(p: vec2<i32>, g: vec4<u32>, s: Surface) {
|
||||
let share = dot(e, luma) / max(dot(c.rgb, luma), 1e-4);
|
||||
textureStore(diffuse, p, vec4<f32>(min(s.diffuse + e / (vec3<f32>(1.0) + e), vec3<f32>(1.0)), 1.0));
|
||||
textureStore(mask, p, vec4<f32>(smoothstep(0.3, 0.7, share), 0.0, 0.0, 0.0));
|
||||
textureStore(color, p, vec4<f32>(compress(c.rgb), c.a));
|
||||
}
|
||||
@compute @workgroup_size(8, 8, 1)
|
||||
fn main(@builtin(global_invocation_id) id: vec3<u32>) {
|
||||
@@ -142,5 +160,14 @@ fn restore(@builtin(global_invocation_id) id: vec3<u32>) {
|
||||
let t = q - floor(q);
|
||||
let e = mix(mix(emitted(i), emitted(i + vec2<i32>(1, 0)), t.x), mix(emitted(i + vec2<i32>(0, 1)), emitted(i + vec2<i32>(1, 1)), t.x), t.y);
|
||||
let c = textureLoad(color, p);
|
||||
textureStore(color, p, vec4<f32>(c.rgb + e, c.a));
|
||||
textureStore(color, p, vec4<f32>(uncompress(c.rgb) + e, c.a));
|
||||
}
|
||||
// the knee undone, with no emission to put back (emissive "mask"): run after the denoiser whenever `restore` isn't
|
||||
@compute @workgroup_size(8, 8, 1)
|
||||
fn expand(@builtin(global_invocation_id) id: vec3<u32>) {
|
||||
let size = vec2<u32>(params[1].xy);
|
||||
if (id.x >= size.x || id.y >= size.y) { return; }
|
||||
let p = vec2<i32>(id.xy);
|
||||
let c = textureLoad(color, p);
|
||||
textureStore(color, p, vec4<f32>(uncompress(c.rgb), c.a));
|
||||
}
|
||||
@@ -13,10 +13,13 @@ struct Overrides {
|
||||
emissive: Option<String>,
|
||||
upscale: Option<String>,
|
||||
preexposure: Option<f32>,
|
||||
knee: Option<f32>,
|
||||
late: Option<bool>,
|
||||
aa: Option<bool>,
|
||||
jitter: Option<String>,
|
||||
emissive_sharpness: Option<f32>,
|
||||
dynamic: Option<bool>,
|
||||
overscan: Option<f32>,
|
||||
}
|
||||
|
||||
fn overrides() -> &'static Overrides {
|
||||
@@ -33,10 +36,13 @@ fn overrides() -> &'static Overrides {
|
||||
emissive: var("RAEA_SOLARI_EMISSIVE").filter(|v| matches!(v.as_str(), "taa" | "split" | "mask")),
|
||||
upscale: var("RAEA_SOLARI_UPSCALE").filter(|v| matches!(v.as_str(), "one" | "two")),
|
||||
preexposure: num("RAEA_METALFX_PREEXPOSURE"),
|
||||
late: switch("RAEA_SOLARI_DENOISE_LATE"),
|
||||
knee: if var("RAEA_METALFX_KNEE").as_deref() == Some("0") { Some(0.0) } else { num("RAEA_METALFX_KNEE") },
|
||||
aa: switch("RAEA_SOLARI_AA"),
|
||||
jitter: var("RAEA_SOLARI_JITTER"),
|
||||
emissive_sharpness: num("RAEA_EMIT_TAA_SHARP"),
|
||||
dynamic: switch("RAEA_SOLARI_DYNAMIC"),
|
||||
overscan: var("RAEA_SOLARI_OVERSCAN").and_then(|v| v.parse::<f32>().ok()).filter(|v| (0.0..=0.25).contains(v)),
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -51,10 +57,13 @@ pub(crate) fn of(s: Option<&SolariSettings>) -> SolariSettings {
|
||||
if let Some(v) = &o.emissive { s.emissive = v.clone(); }
|
||||
if let Some(v) = &o.upscale { s.upscale = v.clone(); }
|
||||
if let Some(v) = o.preexposure { s.preexposure = v; }
|
||||
if let Some(v) = o.knee { s.knee = v; }
|
||||
if let Some(v) = o.late { s.late = v; }
|
||||
if let Some(v) = o.aa { s.aa = v; }
|
||||
if let Some(v) = &o.jitter { s.jitter = v.clone(); }
|
||||
if let Some(v) = o.emissive_sharpness { s.emissive_sharpness = v; }
|
||||
if let Some(v) = o.dynamic { s.dynamic = v; }
|
||||
if let Some(v) = o.overscan { s.overscan = v; }
|
||||
s
|
||||
}
|
||||
|
||||
@@ -66,9 +75,12 @@ const VARS: &[(&str, &str)] = &[
|
||||
("RAEA_SOLARI_EMISSIVE", "emissive"),
|
||||
("RAEA_SOLARI_UPSCALE", "upscale"),
|
||||
("RAEA_METALFX_PREEXPOSURE", "preexposure"),
|
||||
("RAEA_METALFX_KNEE", "knee"),
|
||||
("RAEA_SOLARI_DENOISE_LATE", "late"),
|
||||
("RAEA_SOLARI_AA", "aa"),
|
||||
("RAEA_SOLARI_JITTER", "jitter"),
|
||||
("RAEA_SOLARI_DYNAMIC", "dynamic"),
|
||||
("RAEA_SOLARI_OVERSCAN", "overscan"),
|
||||
("RAEA_EMIT_TAA_SHARP", "emissiveSharpness"),
|
||||
("RAEA_SOLARI_SCALE", "scale"),
|
||||
];
|
||||
@@ -89,7 +101,7 @@ pub(crate) fn record(view: Entity, s: &SolariSettings, scale: f32, seen: &mut Ha
|
||||
"view": view.to_bits(),
|
||||
"denoise": s.denoise, "guides": s.guides, "reflection_depth": s.reflection_depth, "emissive": s.emissive,
|
||||
"upscale": s.upscale, "preexposure": s.preexposure, "aa": s.aa, "jitter": s.jitter,
|
||||
"emissive_sharpness": s.emissive_sharpness, "jitter_frames": s.jitter_frames, "dynamic": s.dynamic, "scale": (f64::from(scale) * 1000.0).round() / 1000.0,
|
||||
"emissive_sharpness": s.emissive_sharpness, "jitter_frames": s.jitter_frames, "dynamic": s.dynamic, "overscan": s.overscan, "scale": (f64::from(scale) * 1000.0).round() / 1000.0,
|
||||
"env": env.iter().map(|(n, v, _)| format!("{n}={v}")).collect::<Vec<_>>(),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -41,18 +41,49 @@ static NONE: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// After app.finish(): the jitter and the main pass's size in the main world, the scaler after the main pass.
|
||||
pub(crate) fn add(app: &mut App) {
|
||||
app.add_systems(PostUpdate, jitter);
|
||||
app.add_systems(PostUpdate, (jitter, widen.before(raea_sys_viewbox::tag_row_view).before(bevy::camera::CameraUpdateSystems)));
|
||||
let Some(r) = app.get_sub_app_mut(RenderApp) else { return };
|
||||
r.add_systems(ExtractSchedule, extract).add_systems(Core3d, upscale.in_set(Core3dSystems::EarlyPostProcess));
|
||||
}
|
||||
|
||||
/// The fraction of the view's size a side its main pass draws at, 1/3 to 1: RAEA_SOLARI_SCALE on a Solari camera, else
|
||||
/// its RenderScale; 1 where there's no scaler.
|
||||
fn scale(rs: Option<&RenderScale>, solari: bool) -> f32 {
|
||||
fn scale(rs: Option<&RenderScale>, solari: bool, k: f32) -> f32 {
|
||||
static FORCED: std::sync::OnceLock<Option<f32>> = std::sync::OnceLock::new();
|
||||
let forced = *FORCED.get_or_init(|| std::env::var("RAEA_SOLARI_SCALE").ok().and_then(|v| v.parse::<f32>().ok()));
|
||||
let s = if solari && let Some(f) = forced { f } else { rs.map_or(1.0, |r| r.scale) };
|
||||
if NONE.load(Ordering::Relaxed) || !s.is_finite() || s >= 0.999 { 1.0 } else { s.clamp(1.0 / 3.0, 1.0) }
|
||||
let s = if NONE.load(Ordering::Relaxed) || !s.is_finite() || s >= 0.999 { 1.0 } else { s.clamp(1.0 / 3.0, 1.0) };
|
||||
// overscan: the wider main pass has to fit the view's textures
|
||||
if k > 0.0 { s.min(1.0 / (1.0 + 2.0 * k)) } else { s }
|
||||
}
|
||||
|
||||
/// The denoiser stopped (metalfx.rs): nothing crops a wider view back, so no view is drawn wider.
|
||||
pub(crate) static NO_DENOISER: AtomicBool = AtomicBool::new(false);
|
||||
|
||||
/// A Solari camera's overscan as it applies: its settings', where the denoiser brings the view up in one pass (it does
|
||||
/// the cropping); none otherwise.
|
||||
fn overscan(solari: bool, st: &super::SolariSettings) -> f32 {
|
||||
if !solari || !st.denoise || st.upscale == "two" || NONE.load(Ordering::Relaxed) || NO_DENOISER.load(Ordering::Relaxed) || !st.overscan.is_finite() {
|
||||
return 0.0;
|
||||
}
|
||||
st.overscan.clamp(0.0, 0.25)
|
||||
}
|
||||
|
||||
/// Each Solari camera's Overscan from its settings, for the view it draws (raea-sys-viewbox widens it).
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn widen(mut cmd: Commands, cams: Query<(Entity, Has<SolariLighting>, Option<&super::SolariSettings>, Option<&raea_sys_viewbox::Overscan>), With<Camera3d>>) {
|
||||
for (e, solari, st, has) in &cams {
|
||||
let k = overscan(solari, &super::settings::of(st));
|
||||
match (k > 0.0, has) {
|
||||
(true, has) if has.map(|o| o.margin) != Some(k) => {
|
||||
cmd.entity(e).insert(raea_sys_viewbox::Overscan { margin: k, drawn: 0.0 });
|
||||
}
|
||||
(false, Some(_)) => {
|
||||
cmd.entity(e).remove::<raea_sys_viewbox::Overscan>();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The denoiser ran on the view this frame (metalfx.rs sets it; the scaler, after it, reads and clears it).
|
||||
@@ -94,10 +125,10 @@ pub(crate) fn cycle(s: f32, frames: f32) -> u32 {
|
||||
/// gathers frames: photo 2's frame 95 had stepped edges held still, and jittered it came 15.9 -> 15.6 off the path
|
||||
/// tracer.
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn jitter(mut cmd: Commands, frame: Res<FrameCount>, mut cams: Query<(Entity, Option<&RenderScale>, Has<SolariLighting>, Option<&mut TemporalJitter>, Has<Jittered>, Option<&super::SolariSettings>), With<Camera3d>>) {
|
||||
for (e, rs, solari, j, mine, st) in &mut cams {
|
||||
let s = scale(rs, solari);
|
||||
fn jitter(mut cmd: Commands, frame: Res<FrameCount>, mut cams: Query<(Entity, Option<&RenderScale>, Has<SolariLighting>, Option<&mut TemporalJitter>, Has<Jittered>, Option<&super::SolariSettings>, Option<&raea_sys_viewbox::Overscan>), With<Camera3d>>) {
|
||||
for (e, rs, solari, j, mine, st, over) in &mut cams {
|
||||
let st = super::settings::of(st);
|
||||
let s = scale(rs, solari, raea_sys_viewbox::Overscan::drawn(over));
|
||||
if s < 1.0 || (solari && st.aa && st.denoise && DENOISING.load(Ordering::Relaxed)) {
|
||||
let n = cycle(s, st.jitter_frames);
|
||||
let i = frame.0 % n + 1;
|
||||
@@ -120,16 +151,24 @@ fn jitter(mut cmd: Commands, frame: Res<FrameCount>, mut cams: Query<(Entity, Op
|
||||
pub(crate) struct Upscaled;
|
||||
|
||||
/// Each drawn-small camera's main pass size onto its view; taken off when its scale goes back to 1.
|
||||
fn extract(mut cmd: Commands, cams: Extract<Query<(RenderEntity, &Camera, Option<&RenderScale>, Has<SolariLighting>), With<Camera3d>>>, upscaled: Query<(), With<Upscaled>>) {
|
||||
for (re, cam, rs, solari) in &cams {
|
||||
let s = scale(rs, solari);
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn extract(mut cmd: Commands, cams: Extract<Query<(RenderEntity, &Camera, Option<&RenderScale>, Has<SolariLighting>, Option<&raea_sys_viewbox::Overscan>), With<Camera3d>>>, upscaled: Query<(), With<Upscaled>>) {
|
||||
for (re, cam, rs, solari, over) in &cams {
|
||||
// as wide as the camera's view was drawn (raea-sys-viewbox's tag_row_view): the main pass matches that
|
||||
let k = raea_sys_viewbox::Overscan::drawn(over);
|
||||
let s = scale(rs, solari, k);
|
||||
match cam.physical_viewport_size() {
|
||||
Some(size) if s < 1.0 && cam.is_active => {
|
||||
let part = (size.as_vec2() * s).round().as_uvec2().max(UVec2::ONE);
|
||||
let part = (size.as_vec2() * s * (1.0 + 2.0 * k)).round().as_uvec2().clamp(UVec2::ONE, size);
|
||||
cmd.entity(re).insert((MainPassResolutionOverride(part), Upscaled));
|
||||
if k > 0.0 {
|
||||
cmd.entity(re).insert(raea_sys_viewbox::Overscan { margin: k, drawn: k });
|
||||
} else {
|
||||
cmd.entity(re).remove::<raea_sys_viewbox::Overscan>();
|
||||
}
|
||||
}
|
||||
_ if upscaled.contains(re) => {
|
||||
cmd.entity(re).remove::<(MainPassResolutionOverride, Upscaled)>();
|
||||
cmd.entity(re).remove::<(MainPassResolutionOverride, Upscaled, raea_sys_viewbox::Overscan)>();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ impl Engine {
|
||||
app.add_plugins((raea_plugins::RaeaPlugins, raea_plugins::RegisteredPlugins { fps: prog.fps }));
|
||||
app.sub_app_mut(bevy::render::RenderApp).add_systems(
|
||||
bevy::render::Render,
|
||||
wait_pipelines.in_set(bevy::render::RenderSystems::Render).before(bevy::render::renderer::render_system),
|
||||
(wait_pipelines, failed_pipelines).chain().in_set(bevy::render::RenderSystems::Render).before(bevy::render::renderer::render_system),
|
||||
);
|
||||
// overlapping fog volumes composited in one order whatever frames came before (raea-sys-fog's FogRank)
|
||||
app.sub_app_mut(bevy::render::RenderApp)
|
||||
@@ -292,3 +292,22 @@ fn solari_cut(mut cams: Query<(&raea_sys_post::cut::CameraCut, &mut bevy::solari
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A pipeline whose shader didn't compile draws nothing, and the frame comes out without its pass (Solari's light, a
|
||||
/// material): an error of the render, said once a pipeline, so `raea render` ends on it instead of "0 errors" over a
|
||||
/// picture that isn't the scene's (11-25: a reserved word in a shader, and three held runs measured as if lit). A
|
||||
/// shader still loading is Bevy's to retry, not a failure.
|
||||
fn failed_pipelines(cache: Res<bevy::render::render_resource::PipelineCache>, mut told: Local<std::collections::HashSet<usize>>) {
|
||||
use bevy::render::render_resource::CachedPipelineState;
|
||||
use bevy::shader::ShaderCacheError;
|
||||
for (i, p) in cache.pipelines().enumerate() {
|
||||
let CachedPipelineState::Err(e) = &p.state else { continue };
|
||||
if matches!(e, ShaderCacheError::ShaderNotLoaded(_) | ShaderCacheError::ShaderImportNotYetAvailable) || !told.insert(i) {
|
||||
continue;
|
||||
}
|
||||
let why = e.to_string();
|
||||
let found = raea_core_facts::Finding::new("shader", raea_core_facts::Level::Error, format!("a shader didn't compile, so its pass isn't in the picture: {}", why.lines().map(str::trim).filter(|l| !l.is_empty()).take(4).collect::<Vec<_>>().join(" ")), "raea render");
|
||||
eprintln!("raea: {}", found.line());
|
||||
raea_core_facts::finding::said(&[found]);
|
||||
}
|
||||
}
|
||||
@@ -59,8 +59,8 @@ raea_plugin! {
|
||||
ProcMatPlugin: raea_sys_procmat::install, "Procedural surfaces: wood, stone, brick, tiles and the rest, with dust and dirt (systems/procmat).";
|
||||
PaintPlugin: super::paint::install, "The paint and cartoon looks' surfaces (paint.rs).";
|
||||
PassesPlugin: super::passes::install, "Render passes per view (passes.rs).";
|
||||
TracedAoPlugin: raea_sys_rt::passes, "Traced passes: ambient occlusion, raea GI's world probes and the sun's far shadow map (raea-sys-rt).";
|
||||
GiScreenPlugin: raea_sys_gi::install, "raea GI's light on screen: each pixel's indirect diffuse from the world cache, read by the main pass (raea-sys-gi, RAEA_GI=1).";
|
||||
TracedAoPlugin: raea_sys_rt::passes, "Traced passes: ambient occlusion, raealism's world probes and the sun's far shadow map (raea-sys-rt).";
|
||||
GiScreenPlugin: raea_sys_gi::install, "raealism's light on screen: each pixel's indirect diffuse from the world cache, read by the main pass (raea-sys-gi, RAEA_GI=1).";
|
||||
VolumePlugin: super::volume::install, "Simulated smoke, clouds and contrails, raymarched (volume.rs).";
|
||||
GrassPlugin: raea_sys_grass::install, "Fields of grass, made in tiles as detailed as the camera's distance asks (systems/grass).";
|
||||
DetailPlugin: raea_sys_lod::install, "Where each part is drawn: levels by distance or size on screen, cross-faded, draw distance and shadows left to a coarser level (raea-sys-lod, docs/realism.feature LT21).";
|
||||
|
||||
@@ -126,6 +126,9 @@ pub fn apply_rows(world: &mut World, dir: &Path, rows: &[Tup]) -> Result<bool, S
|
||||
}
|
||||
}
|
||||
}
|
||||
if world.resource::<FrameRows>().cols.id.len() != store::rows(world).len() {
|
||||
name_rows(world);
|
||||
}
|
||||
// a <BevyComponent> or <BevyResource> whose value a live frame changed (or a new one): set on its part
|
||||
plugins::apply_live_rows(world, &reflected)?;
|
||||
// a mesh spawned here with a shader over its surface: put on now that this frame's rows are in (scene3d's
|
||||
@@ -169,10 +172,27 @@ pub fn remove_rows_from(world: &mut World, rows: &[(String, String)]) -> Result<
|
||||
// the rows after a dropped one moved up: their places again, from the store's order
|
||||
let ix: bevy::ecs::entity::EntityHashMap<usize> = store::rows(world).iter().enumerate().map(|(r, &e)| (e, r)).collect();
|
||||
world.resource_mut::<FrameRows>().ix = ix;
|
||||
name_rows(world);
|
||||
}
|
||||
if gone.is_empty() { Ok(()) } else { Err(gone.join("; ")) }
|
||||
}
|
||||
|
||||
/// The frame's row names (`cols.kind`, `cols.id`) as the store holds its rows now. A live scene's rows move up when one
|
||||
/// before them is dropped and new ones join at the end, and a <FramePass>'s or a <Compute>'s `follow` finds its row
|
||||
/// by `cols.id`: left as the scene opened, a pass read another row from the first drop on and kept the uniforms it
|
||||
/// opened with for the rest of a video (11-25: MALL RAT's exposure stood still, its daylight blown out).
|
||||
fn name_rows(world: &mut World) {
|
||||
let (mut kinds, mut ids) = (Vec::<String>::new(), Vec::<String>::new());
|
||||
for &e in store::rows(world).iter() {
|
||||
if let Some(k) = store::key(world, e) {
|
||||
kinds.push(k.kind.clone());
|
||||
ids.push(k.id.clone());
|
||||
}
|
||||
}
|
||||
let mut fr = world.resource_mut::<FrameRows>();
|
||||
(fr.cols.kind, fr.cols.id) = (kinds.into(), ids.into());
|
||||
}
|
||||
|
||||
/// Where a plain App's 3D camera draws when its camera row arrives through apply_rows (an Engine's draws into its frame).
|
||||
#[derive(Resource, Clone)]
|
||||
pub struct SceneTarget {
|
||||
@@ -382,3 +402,23 @@ pub(crate) fn spawn_3d(world: &mut World, e: Entity, t: &Tup, inserted: &[Tup],
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_live_rows_name_follows_the_rows_dropped_before_it() {
|
||||
let row = |kind: &str, id: &str, k: f64| Tup { kind: kind.into(), id: id.into(), vals: [("k".into(), V::N(k))].into() };
|
||||
let mut s = store::Store::new(&[row("mesh", "a", 0.0), row("mesh", "b", 1.0), row("frame_pass", "frame_pass0", 2.0)]);
|
||||
let mut fr = FrameRows::new(store::rows(&s.world).iter().enumerate().map(|(r, &e)| (e, r)).collect());
|
||||
fr.cols = s.gather();
|
||||
fr.live = Some(s.tups().into_iter().map(|t| t.vals).collect());
|
||||
s.world.insert_resource(fr);
|
||||
remove_rows_from(&mut s.world, &[("mesh".into(), "a".into())]).unwrap();
|
||||
// the pass's row is one place up, and found there by its name (a FramePass's `follow`)
|
||||
let fr = s.world.resource::<FrameRows>();
|
||||
let r = fr.cols.id.iter().position(|i| i == "frame_pass0").unwrap();
|
||||
assert_eq!((r, fr.at(r, "k")), (1, Some(V::N(2.0))));
|
||||
}
|
||||
}
|
||||
+33
-2
@@ -35,7 +35,7 @@ pub fn decode_audio_symphonia(path: &Path) -> R<Audio> {
|
||||
.find(|t| t.codec_params.sample_rate.is_some())
|
||||
.ok_or("no audio track")?
|
||||
.clone();
|
||||
let mut dec = symphonia::default::get_codecs()
|
||||
let mut dec = crate::opusdec::codecs()
|
||||
.make(&track.codec_params, &DecoderOptions::default())
|
||||
.map_err(|e| format!("symphonia: {e}"))?;
|
||||
let mut rate = track.codec_params.sample_rate.unwrap_or(0);
|
||||
@@ -129,7 +129,7 @@ pub fn decode_audio_window_symphonia(path: &Path, start: f64, secs: f64) -> R<Au
|
||||
.map_err(|e| format!("symphonia: {e}"))?;
|
||||
let mut format = probed.format;
|
||||
let track = format.tracks().iter().find(|t| t.codec_params.sample_rate.is_some()).ok_or("no audio track")?.clone();
|
||||
let mut dec = symphonia::default::get_codecs().make(&track.codec_params, &DecoderOptions::default()).map_err(|e| format!("symphonia: {e}"))?;
|
||||
let mut dec = crate::opusdec::codecs().make(&track.codec_params, &DecoderOptions::default()).map_err(|e| format!("symphonia: {e}"))?;
|
||||
let rate = track.codec_params.sample_rate.unwrap_or(0);
|
||||
if rate == 0 {
|
||||
return Err(format!("{}: the sound track has no sample rate", path.display()));
|
||||
@@ -356,3 +356,34 @@ mod window_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod opus_tests {
|
||||
use raea_io_codec::Audio;
|
||||
|
||||
/// Opus packets as this backend writes them decode back here (#242: no decoder took them, so raea's own MP4s read
|
||||
/// as silent off the Mac): a 440 Hz tone, mono and stereo, comes back at its length and its level.
|
||||
#[test]
|
||||
fn opus_written_here_reads_back() {
|
||||
for channels in [1usize, 2] {
|
||||
let tone: Vec<f32> = (0..48_000).map(|i| 0.5 * (i as f32 * 440.0 * std::f32::consts::TAU / 48_000.0).sin()).collect();
|
||||
let a = Audio { rate: 48_000, channels: vec![tone; channels] };
|
||||
let packets = super::opus_packets(&a).unwrap();
|
||||
let mut dec = crate::packets::AudioPacketDecoder::new("opus", None, 48_000, channels as u32).unwrap();
|
||||
let mut out = vec![Vec::new(); channels];
|
||||
for (_, p) in &packets {
|
||||
let (rate, planes) = dec.decode(p).unwrap();
|
||||
assert_eq!(rate, 48_000);
|
||||
assert_eq!(planes.len(), channels);
|
||||
for (o, p) in out.iter_mut().zip(&planes) {
|
||||
o.extend_from_slice(p);
|
||||
}
|
||||
}
|
||||
let n = out[0].len();
|
||||
assert!((47_000..=49_500).contains(&n), "{channels} channel(s): {n} samples back from 48000");
|
||||
// past the coder's start, the tone's level (0.5 peak is 0.354 RMS)
|
||||
let rms = (out[0][4800..n - 4800].iter().map(|v| v * v).sum::<f32>() / (n - 9600) as f32).sqrt();
|
||||
assert!((rms - 0.354).abs() < 0.03, "{channels} channel(s): RMS {rms}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,8 @@
|
||||
mod audio;
|
||||
#[cfg(feature = "h264")]
|
||||
mod h264;
|
||||
/// Opus read back (libopus) as a Symphonia decoder, and the registry every decoder here is made from
|
||||
mod opusdec;
|
||||
/// packet-level audio decoding (Symphonia), for coders handed packets
|
||||
pub mod packets;
|
||||
mod probe;
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
//! Opus read back (libopus), as a Symphonia decoder: Symphonia's MP4 reader finds an Opus track and has no decoder for
|
||||
//! it, so the MP4s this backend writes itself (H.264 + Opus) came back without their sound wherever no platform reader
|
||||
//! stood in front (raea #242: on Windows `raea media probe` listed no audio and `raea media share` wrote a silent copy).
|
||||
//! `codecs()` is Symphonia's registry with this one added; every decoder here is made from it.
|
||||
|
||||
use std::sync::{Mutex, OnceLock};
|
||||
|
||||
use symphonia::core::audio::{AsAudioBufferRef, AudioBuffer, AudioBufferRef, Channels, Signal, SignalSpec};
|
||||
use symphonia::core::codecs::{CODEC_TYPE_OPUS, CodecDescriptor, CodecParameters, CodecRegistry, Decoder, DecoderOptions, FinalizeResult};
|
||||
use symphonia::core::errors::{Result, decode_error, unsupported_error};
|
||||
use symphonia::core::formats::Packet;
|
||||
use symphonia::core::support_codec;
|
||||
|
||||
/// Opus always decodes at 48 kHz, and a packet holds at most 120 ms of it
|
||||
const RATE: u32 = 48_000;
|
||||
const MAX_FRAMES: usize = 5760;
|
||||
|
||||
pub struct OpusDecoder {
|
||||
params: CodecParameters,
|
||||
/// (behind a lock only because a Symphonia decoder must be Sync, which libopus's state isn't: one caller at a time)
|
||||
dec: Mutex<opus::Decoder>,
|
||||
channels: usize,
|
||||
pcm: Vec<f32>,
|
||||
buf: AudioBuffer<f32>,
|
||||
}
|
||||
|
||||
/// Symphonia's own codecs and Opus.
|
||||
pub fn codecs() -> &'static CodecRegistry {
|
||||
static ALL: OnceLock<CodecRegistry> = OnceLock::new();
|
||||
ALL.get_or_init(|| {
|
||||
let mut r = CodecRegistry::new();
|
||||
symphonia::default::register_enabled_codecs(&mut r);
|
||||
r.register_all::<OpusDecoder>();
|
||||
r
|
||||
})
|
||||
}
|
||||
|
||||
/// How many channels an Opus track has: its identification header's count (OpusHead, as an MP4's dOps box and an Ogg
|
||||
/// stream's first packet both carry it: 8 bytes of magic, a version, the count), else what the container said.
|
||||
fn channel_count(p: &CodecParameters) -> usize {
|
||||
let head = p.extra_data.as_deref().filter(|d| d.len() > 9 && d.starts_with(b"OpusHead")).map(|d| d[9] as usize);
|
||||
let said = p.channels.map(|c| c.count()).or(p.channel_layout.map(|l| l.into_channels().count()));
|
||||
head.or(said).unwrap_or(2)
|
||||
}
|
||||
|
||||
impl Decoder for OpusDecoder {
|
||||
fn try_new(params: &CodecParameters, _: &DecoderOptions) -> Result<Self> {
|
||||
if params.codec != CODEC_TYPE_OPUS {
|
||||
return unsupported_error("opus: not an Opus track");
|
||||
}
|
||||
// mono and stereo (what raea writes, and nearly every Opus file): a surround stream is several coupled streams
|
||||
// under a mapping, which this isn't
|
||||
let (channels, layout, how) = match channel_count(params) {
|
||||
1 => (1, Channels::FRONT_LEFT, opus::Channels::Mono),
|
||||
2 => (2, Channels::FRONT_LEFT | Channels::FRONT_RIGHT, opus::Channels::Stereo),
|
||||
_ => return unsupported_error("opus: more than two channels"),
|
||||
};
|
||||
let dec = match opus::Decoder::new(RATE, how) {
|
||||
Ok(d) => d,
|
||||
Err(_) => return unsupported_error("opus: the decoder didn't start"),
|
||||
};
|
||||
let mut params = params.clone();
|
||||
params.with_sample_rate(RATE).with_channels(layout);
|
||||
Ok(OpusDecoder { params, dec: Mutex::new(dec), channels, pcm: vec![0.0; MAX_FRAMES * channels], buf: AudioBuffer::new(MAX_FRAMES as u64, SignalSpec::new(RATE, layout)) })
|
||||
}
|
||||
|
||||
fn supported_codecs() -> &'static [CodecDescriptor] {
|
||||
&[support_codec!(CODEC_TYPE_OPUS, "opus", "Opus")]
|
||||
}
|
||||
|
||||
fn reset(&mut self) {
|
||||
if let Ok(d) = self.dec.get_mut() {
|
||||
let _ = d.reset_state();
|
||||
}
|
||||
}
|
||||
|
||||
fn codec_params(&self) -> &CodecParameters {
|
||||
&self.params
|
||||
}
|
||||
|
||||
fn decode(&mut self, packet: &Packet) -> Result<AudioBufferRef<'_>> {
|
||||
self.buf.clear();
|
||||
let n = match self.dec.get_mut().map(|d| d.decode_float(packet.buf(), &mut self.pcm, false)) {
|
||||
Ok(Ok(n)) => n,
|
||||
_ => return decode_error("opus: a packet didn't decode"),
|
||||
};
|
||||
self.buf.render_reserved(Some(n));
|
||||
for c in 0..self.channels {
|
||||
for (o, i) in self.buf.chan_mut(c).iter_mut().zip(self.pcm.iter().skip(c).step_by(self.channels)) {
|
||||
*o = *i;
|
||||
}
|
||||
}
|
||||
Ok(self.buf.as_audio_buffer_ref())
|
||||
}
|
||||
|
||||
fn finalize(&mut self) -> FinalizeResult {
|
||||
FinalizeResult::default()
|
||||
}
|
||||
|
||||
fn last_decoded(&self) -> AudioBufferRef<'_> {
|
||||
self.buf.as_audio_buffer_ref()
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Packet-level audio decoding (Symphonia), for coders handed compressed packets one at a time: AAC (with its
|
||||
//! AudioSpecificConfig), MP3, FLAC, PCM, as Symphonia reads them. Planar f32 out.
|
||||
//! AudioSpecificConfig), MP3, FLAC, PCM, as Symphonia reads them, and Opus (opusdec.rs). Planar f32 out.
|
||||
|
||||
use symphonia::core::audio::{AudioBufferRef, Signal};
|
||||
use symphonia::core::codecs::{CodecParameters, Decoder, DecoderOptions};
|
||||
@@ -19,7 +19,8 @@ fn codec_type(codec: &str) -> R<symphonia::core::codecs::CodecType> {
|
||||
"mp4a" | "aac" => CODEC_TYPE_AAC,
|
||||
"mp3" => CODEC_TYPE_MP3,
|
||||
"flac" => CODEC_TYPE_FLAC,
|
||||
o => return Err(format!("{o}: audio decodes here as aac, mp3 or flac")),
|
||||
"opus" => CODEC_TYPE_OPUS,
|
||||
o => return Err(format!("{o}: audio decodes here as aac, mp3, flac or opus")),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ impl AudioPacketDecoder {
|
||||
} {
|
||||
p.with_channel_layout(layout);
|
||||
}
|
||||
let dec = symphonia::default::get_codecs().make(&p, &DecoderOptions::default()).map_err(|e| format!("symphonia: {e}"))?;
|
||||
let dec = crate::opusdec::codecs().make(&p, &DecoderOptions::default()).map_err(|e| format!("symphonia: {e}"))?;
|
||||
Ok(AudioPacketDecoder { dec, ts: 0 })
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ use std::time::{Instant, SystemTime, UNIX_EPOCH};
|
||||
|
||||
use serde_json::{Value, json};
|
||||
|
||||
pub mod once;
|
||||
mod crash;
|
||||
mod look;
|
||||
mod props;
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
//! An error that repeats, said once (#239): a failing audio device calls its stream's error callback without pause.
|
||||
|
||||
/// A device's error said once, then only how often it came back (at its 10th, 100th, ... time, and never more than once
|
||||
/// a second): a failing ALSA device calls a stream's error callback without pause, and every call printed a line: #239's
|
||||
/// app.log reached 40 GB of one line in two days.
|
||||
pub fn said_once<E: std::fmt::Display>(what: &'static str) -> impl FnMut(E) + Send + 'static {
|
||||
let mut seen = Repeats::default();
|
||||
move |e| {
|
||||
let m = e.to_string();
|
||||
match seen.hit(&m, std::time::Instant::now()) {
|
||||
Some(1) => eprintln!("{what}: {m}"),
|
||||
Some(n) => eprintln!("{what}: {m} ({n} times now)"),
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Which of an error's repeats get said: `hit` answers with the count to print, or nothing.
|
||||
#[derive(Default)]
|
||||
struct Repeats {
|
||||
last: String,
|
||||
n: u64,
|
||||
next: u64,
|
||||
at: Option<std::time::Instant>,
|
||||
}
|
||||
|
||||
impl Repeats {
|
||||
fn hit(&mut self, m: &str, now: std::time::Instant) -> Option<u64> {
|
||||
if m != self.last || self.n == 0 {
|
||||
(self.last, self.n, self.next) = (m.to_string(), 0, 1);
|
||||
}
|
||||
self.n += 1;
|
||||
let soon = self.at.is_some_and(|t| now.duration_since(t).as_secs() < 1);
|
||||
if self.n < self.next || (soon && self.n > 1) {
|
||||
return None;
|
||||
}
|
||||
self.next = self.n.saturating_mul(10);
|
||||
self.at = Some(now);
|
||||
Some(self.n)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Repeats;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
/// #239: half a billion repeats of one ALSA error were half a billion lines. Two days of them are a handful.
|
||||
#[test]
|
||||
fn a_repeating_error_is_a_handful_of_lines() {
|
||||
let (mut r, t0) = (Repeats::default(), Instant::now());
|
||||
// 5,000 a second for a minute
|
||||
let said = (0..300_000u64).filter(|i| r.hit("alsa::poll() returned POLLERR", t0 + Duration::from_micros(i * 200)).is_some()).count();
|
||||
assert!(said <= 8, "{said} lines for 300,000 repeats");
|
||||
assert_eq!(Repeats::default().hit("x", t0), Some(1), "the first is always said");
|
||||
// another error is said at once, when a second has gone by
|
||||
assert_eq!(r.hit("the device went away", t0 + Duration::from_secs(120)), Some(1));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "raea-runtime-cut-plan"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "A cut job held to its client's brief: every rule quoting the brief, the count and open items, and each delivered file's shape, words heard, banned phrases, CTA and frames check, from what's on disk (docs/make.feature MK25-MK27)"
|
||||
|
||||
[dependencies]
|
||||
# the contract: `make: cut({...})` on brief.ts
|
||||
raea-core-brief = { path = "../../core/brief" }
|
||||
# a delivered file's size and length from its header boxes, the media never read
|
||||
raea-io-soft = { path = "../../io/soft" }
|
||||
serde_json = "1"
|
||||
@@ -0,0 +1,261 @@
|
||||
//! A cut job's gates (docs/make.feature MK25-MK27): the brief as rules (`make: cut({...})`, core/brief cut.rs), held
|
||||
//! from what's on disk. The quotes: every rule's `from` is in the brief's text. The count: as many cuts as the brief
|
||||
//! asks for, or an answer saying why not. The open items: each answered. Then each delivered file: its shape and
|
||||
//! length; its words, heard after its last change (FILE.words.json, `raea words`), with every `say` phrase heard or
|
||||
//! shown, no `never` phrase in its words or its text, and the CTA in its last seconds; and its frames check, run after
|
||||
//! its last change (FILE.frames-check.json, `raea frames check`), with no face cut and no text too small.
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use raea_core_brief::cut::{self, Cut, norm};
|
||||
use serde_json::Value;
|
||||
|
||||
/// One gate as `raea make status` lists it: its name, the file or item it's about, whether it's clear, what it says.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Gate {
|
||||
pub name: &'static str,
|
||||
pub of: Option<String>,
|
||||
pub clear: bool,
|
||||
pub says: String,
|
||||
}
|
||||
|
||||
fn gate(name: &'static str, of: Option<&str>, clear: bool, says: String) -> Gate {
|
||||
Gate { name, of: of.map(str::to_string), clear, says }
|
||||
}
|
||||
|
||||
/// A delivered file's width, height and seconds, from its header boxes (io/soft's probe: the media isn't read, and a
|
||||
/// file re-encoded after its render is read as it is now).
|
||||
fn shape(f: &Path) -> Option<(u32, u32, f64)> {
|
||||
raea_io_soft::probe(f).ok().map(|p| (p.width.round() as u32, p.height.round() as u32, p.secs))
|
||||
}
|
||||
|
||||
/// A report beside the file (FILE.words.json, FILE.frames-check.json), read when it's newer than the file (a report
|
||||
/// from before the last change says nothing about it now): Ok(json), or Err(why not).
|
||||
fn fresh(f: &Path, ext: &str, run: &str) -> Result<Value, String> {
|
||||
let r = f.with_extension(ext);
|
||||
let changed = |p: &Path| -> Option<std::time::SystemTime> { p.metadata().ok()?.modified().ok() };
|
||||
let Some(at) = changed(&r) else { return Err(format!("never run: {run}")) };
|
||||
if changed(f).is_some_and(|m| m > at) {
|
||||
return Err(format!("the file changed after it: {run} again"));
|
||||
}
|
||||
std::fs::read_to_string(&r).ok().and_then(|s| serde_json::from_str(&s).ok()).ok_or_else(|| format!("{} isn't JSON: {run} again", r.display()))
|
||||
}
|
||||
|
||||
/// What a file says: its heard words with their times in seconds (`raea words`: start/end, or start_ms/end_ms).
|
||||
fn heard(words: &Value) -> Vec<(String, f64, f64)> {
|
||||
let list = words.as_array().or_else(|| words["words"].as_array()).cloned().unwrap_or_default();
|
||||
list.iter()
|
||||
.filter_map(|w| {
|
||||
let t = norm(w["text"].as_str().or_else(|| w["word"].as_str())?);
|
||||
let at = |k: &str| w[k].as_f64().or(w[format!("{k}_ms")].as_f64().map(|ms| ms * 0.001));
|
||||
let s = at("start")?;
|
||||
let e = at("end").unwrap_or(s);
|
||||
(!t.is_empty()).then_some((t, s, e))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// What a file shows: each text of its render manifest (FILE.render.json) and the second it's first on screen.
|
||||
fn shown(manifest: &Value) -> Vec<(String, f64)> {
|
||||
let fps = manifest["fps"].as_f64().filter(|f| *f > 0.0).unwrap_or(30.0);
|
||||
let mut out: Vec<(String, f64)> = Vec::new();
|
||||
for fr in manifest["frames"].as_array().into_iter().flatten() {
|
||||
let at = fr["frame"].as_f64().unwrap_or(0.0) / fps;
|
||||
for t in fr["text"].as_array().into_iter().flatten() {
|
||||
let s = norm(t["text"].as_str().unwrap_or(""));
|
||||
if !s.is_empty() && t["opacity"].as_f64().unwrap_or(1.0) > 0.05 && !out.iter().any(|(o, _)| *o == s) {
|
||||
out.push((s, at));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// `phrase` in `text` as whole words.
|
||||
fn has(text: &str, phrase: &str) -> bool {
|
||||
!phrase.is_empty() && format!(" {text} ").contains(&format!(" {phrase} "))
|
||||
}
|
||||
|
||||
/// `got`'s words with each compound the brief writes as one word joined back ("wish list" heard, "Wishlist" written),
|
||||
/// each with the index of its first word in `got`.
|
||||
fn joined<'a>(got: &[&'a str], want: &[&str]) -> Vec<(String, usize)> {
|
||||
let mut out = Vec::new();
|
||||
let mut i = 0;
|
||||
while i < got.len() {
|
||||
let k = (2..=3).rev().find(|&k| i + k <= got.len() && want.contains(&got[i..i + k].concat().as_str())).unwrap_or(1);
|
||||
out.push((got[i..i + k].concat(), i));
|
||||
i += k;
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Where `phrase` (normalised) is first said in `got`: the index of its first word. Its words in order, compounds
|
||||
/// joined, each at most `gap` words after the one before (1: word for word; people say "it's free, it's fun, and it's
|
||||
/// easy" for "free, fun, and easy", which a gap of 2 takes and a reordered "fun, free, and easy" doesn't).
|
||||
fn said_at(got: &[&str], phrase: &str, gap: usize) -> Option<usize> {
|
||||
let want: Vec<&str> = phrase.split(' ').filter(|w| !w.is_empty()).collect();
|
||||
let got = joined(got, &want);
|
||||
(0..got.len()).find(|&s| {
|
||||
if want.is_empty() || got[s].0 != want[0] {
|
||||
return false;
|
||||
}
|
||||
let mut at = s;
|
||||
want[1..].iter().all(|w| match (at + 1..(at + 1 + gap).min(got.len())).find(|&j| got[j].0 == *w) {
|
||||
Some(j) => {
|
||||
at = j;
|
||||
true
|
||||
}
|
||||
None => false,
|
||||
})
|
||||
})
|
||||
.map(|s| got[s].1)
|
||||
}
|
||||
|
||||
/// How far apart a `say` phrase's words may be heard.
|
||||
const SAY_GAP: usize = 2;
|
||||
|
||||
/// The share of `want`'s words that `got` has in order (longest common subsequence): a CTA heard with a word misheard
|
||||
/// still lands.
|
||||
fn in_order(want: &[&str], got: &[&str]) -> f64 {
|
||||
if want.is_empty() {
|
||||
return 1.0;
|
||||
}
|
||||
let mut row = vec![0usize; got.len() + 1];
|
||||
for w in want {
|
||||
let mut prev = 0;
|
||||
for (j, g) in got.iter().enumerate() {
|
||||
let keep = row[j + 1];
|
||||
row[j + 1] = if w == g { prev + 1 } else { row[j + 1].max(row[j]) };
|
||||
prev = keep;
|
||||
}
|
||||
}
|
||||
row[got.len()] as f64 / want.len() as f64
|
||||
}
|
||||
|
||||
/// How much of the CTA a run of words must have, in order.
|
||||
const CTA_SHARE: f64 = 0.85;
|
||||
|
||||
/// One delivered file's gates: shape, words (say, never, cta) and frames.
|
||||
fn file_gates(c: &Cut, plan: &cut::CutPlan, format: &str, f: &Path, rel: &str, said: &mut Vec<(usize, String)>) -> Vec<Gate> {
|
||||
let mut out = Vec::new();
|
||||
let shape = shape(f);
|
||||
match (shape, cut::ratio(format), cut::seconds(c, plan)) {
|
||||
(None, ..) => out.push(gate("shape", Some(rel), false, "not an MP4 or MOV with a video track".into())),
|
||||
(Some((w, h, secs)), Some((rw, rh)), len) => {
|
||||
let mut wrong = Vec::new();
|
||||
let (want, got) = (rw as f64 / rh as f64, w as f64 / h.max(1) as f64);
|
||||
if (got / want - 1.0).abs() > 0.02 {
|
||||
wrong.push(format!("{w}x{h} isn't {format}"));
|
||||
}
|
||||
if let Some([a, b]) = len
|
||||
&& (secs + 0.05 < a || secs > b + 0.05)
|
||||
{
|
||||
wrong.push(format!("{secs:.1} s isn't {a}-{b} s"));
|
||||
}
|
||||
out.push(gate("shape", Some(rel), wrong.is_empty(), if wrong.is_empty() { format!("{w}x{h}, {secs:.1} s") } else { wrong.join("; ") }));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
// what it says and shows
|
||||
match fresh(f, "words.json", &format!("raea words {rel}")) {
|
||||
Err(why) => out.push(gate("words", Some(rel), false, why)),
|
||||
Ok(w) => {
|
||||
let words = heard(&w);
|
||||
let spoken: Vec<&str> = words.iter().map(|(t, ..)| t.as_str()).collect();
|
||||
let screen = std::fs::read_to_string(f.with_extension("render.json")).ok().and_then(|s| serde_json::from_str::<Value>(&s).ok()).map(|m| shown(&m)).unwrap_or_default();
|
||||
let on_screen = |s: &str, p: &str, gap| said_at(&s.split(' ').collect::<Vec<_>>(), p, gap).is_some();
|
||||
let on = |p: &str| said_at(&spoken, p, SAY_GAP).is_some() || screen.iter().any(|(s, _)| on_screen(s, p, SAY_GAP));
|
||||
let missing: Vec<&str> = c.say.iter().filter(|p| p.every != Some(false) && !on(&norm(&p.text))).map(|p| p.text.as_str()).collect();
|
||||
said.extend(c.say.iter().enumerate().filter(|(_, p)| on(&norm(&p.text))).map(|(i, _)| (i, rel.to_string())));
|
||||
out.push(gate("say", Some(rel), missing.is_empty(), if missing.is_empty() { format!("says all {} of its phrases", c.say.iter().filter(|p| p.every != Some(false)).count()) } else { format!("never says or shows: {}", missing.iter().map(|m| format!("\"{m}\"")).collect::<Vec<_>>().join(", ")) }));
|
||||
let banned: Vec<String> = c
|
||||
.never
|
||||
.iter()
|
||||
.filter_map(|p| {
|
||||
let n = norm(&p.text);
|
||||
if let Some(i) = said_at(&spoken, &n, 1) {
|
||||
return Some(format!("\"{}\" heard at {:.1} s (brief: {})", p.text, words[i].1, p.from));
|
||||
}
|
||||
screen.iter().find(|(s, _)| on_screen(s, &n, 1)).map(|(_, at)| format!("\"{}\" on screen at {at:.1} s (brief: {})", p.text, p.from))
|
||||
})
|
||||
.collect();
|
||||
out.push(gate("never", Some(rel), banned.is_empty(), if banned.is_empty() { "says and shows none of the banned phrases".into() } else { banned.join("; ") }));
|
||||
if let Some(cta) = &c.cta {
|
||||
let within = cta.within.unwrap_or(cut::CTA_WITHIN);
|
||||
let end = shape.map(|s| s.2).or_else(|| words.last().map(|w| w.2)).unwrap_or(0.0);
|
||||
let want_s = norm(&cta.text);
|
||||
let want: Vec<&str> = want_s.split(' ').collect();
|
||||
let share = |got: &[&str]| {
|
||||
let j = joined(got, &want);
|
||||
in_order(&want, &j.iter().map(|(w, _)| w.as_str()).collect::<Vec<_>>())
|
||||
};
|
||||
let last: Vec<&str> = words.iter().filter(|w| w.2 >= end - within).map(|w| w.0.as_str()).collect();
|
||||
let heard_share = share(&last);
|
||||
let on_screen = screen.iter().any(|(s, at)| *at >= end - within && share(&s.split(' ').collect::<Vec<_>>()) >= CTA_SHARE);
|
||||
let ok = heard_share >= CTA_SHARE || on_screen;
|
||||
out.push(gate("cta", Some(rel), ok, if ok { format!("ends on the CTA ({})", if on_screen { "on screen" } else { "heard" }) } else { format!("the CTA isn't in its last {within:.0} s ({:.0}% of its words heard there): \"{}\"", heard_share * 100.0, cta.text) }));
|
||||
}
|
||||
}
|
||||
}
|
||||
// faces whole, text big enough: the frames check of the file as it is now
|
||||
if c.frames != Some(false) {
|
||||
match fresh(f, "frames-check.json", &format!("raea frames check {rel}")) {
|
||||
Err(why) => out.push(gate("frames", Some(rel), false, why)),
|
||||
Ok(r) => {
|
||||
let errors: Vec<&str> = r["findings"].as_array().into_iter().flatten().filter(|x| x["level"] == "error").filter_map(|x| x["says"].as_str()).collect();
|
||||
out.push(gate("frames", Some(rel), errors.is_empty(), match errors.as_slice() {
|
||||
[] => "no face cut, no text too small".into(),
|
||||
[one] => one.to_string(),
|
||||
many => format!("{} errors, first: {}", many.len(), many[0]),
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// The cut job's gates over its brief folder `dir`.
|
||||
pub fn gates(c: &Cut, dir: &Path) -> Vec<Gate> {
|
||||
let mut out = Vec::new();
|
||||
// the quotes: each rule is backed by the brief's own words
|
||||
match std::fs::read_to_string(dir.join(&c.brief)) {
|
||||
Err(_) => out.push(gate("quotes", None, false, format!("no brief text at {}: pdftotext -layout BRIEF.pdf {}", c.brief, c.brief))),
|
||||
Ok(t) => {
|
||||
let text = norm(&t);
|
||||
let unfound: Vec<String> = cut::quotes(c).into_iter().filter(|(_, from)| !has(&text, &norm(from))).map(|(what, from)| format!("{what} (\"{}\")", from.chars().take(60).collect::<String>())).collect();
|
||||
out.push(gate("quotes", None, unfound.is_empty(), if unfound.is_empty() { format!("all {} rules quote the brief", cut::quotes(c).len()) } else { format!("not in the brief's text, word for word: {}", unfound.join("; ")) }));
|
||||
}
|
||||
}
|
||||
let answered = |about: &str| c.open.iter().any(|o| o.about.as_deref() == Some(about) && o.answer.as_deref().is_some_and(|a| !a.trim().is_empty()));
|
||||
if let Some(n) = &c.count {
|
||||
let have = c.cuts.len() as u32;
|
||||
let ok = have >= n.value || answered("count");
|
||||
out.push(gate("count", None, ok, if have >= n.value { format!("{have} cuts planned; the brief asks for {}", n.value) } else if ok { format!("{have} of the brief's {} cuts, as answered", n.value) } else { format!("{have} cuts planned; the brief asks for {} (\"{}\"): plan them, or add an `open` item about \"count\" and get it answered", n.value, n.from) }));
|
||||
}
|
||||
for o in &c.open {
|
||||
let ok = o.answer.as_deref().is_some_and(|a| !a.trim().is_empty());
|
||||
out.push(gate("open", o.about.as_deref(), ok, if ok { format!("{} -> {}{}", o.question, o.answer.as_deref().unwrap_or(""), o.by.as_deref().map(|b| format!(" ({b})")).unwrap_or_default()) } else { format!("unanswered: {} (brief: \"{}\"): ask at the review, then write the answer and who gave it", o.question, o.from) }));
|
||||
}
|
||||
let mut said: Vec<(usize, String)> = Vec::new();
|
||||
for p in &c.cuts {
|
||||
for fmt in cut::formats(c, p) {
|
||||
let rel = cut::file(p, fmt);
|
||||
let f = dir.join(&rel);
|
||||
if f.is_file() {
|
||||
out.extend(file_gates(c, p, fmt, &f, &rel, &mut said));
|
||||
}
|
||||
}
|
||||
}
|
||||
// a phrase one cut is enough for
|
||||
for (i, p) in c.say.iter().enumerate() {
|
||||
if p.every != Some(false) {
|
||||
continue;
|
||||
}
|
||||
let by = said.iter().find_map(|(j, f)| (*j == i).then_some(f));
|
||||
out.push(gate("say-once", None, by.is_some(), if let Some(f) = by { format!("\"{}\" in {f}", p.text) } else { format!("no cut says or shows \"{}\" (brief: \"{}\")", p.text, p.from) }));
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
@@ -0,0 +1,182 @@
|
||||
//! A cut job held to its brief (MK25-MK27): the contract's doctor, the quotes, the count and open items, and each
|
||||
//! delivered file's shape, words and frames. The delivered file is raea's 3 s 320x180 test clip.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use raea_core_brief::{cut, make::Make, read};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::{Gate, gates};
|
||||
|
||||
const CLIP: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/../../engine/rune/media/tests/fixtures/clip.mp4");
|
||||
|
||||
fn dir(name: &str) -> PathBuf {
|
||||
let d = std::env::temp_dir().join(format!("raea-cut-plan-{name}-{}", std::process::id()));
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
std::fs::create_dir_all(&d).unwrap();
|
||||
d
|
||||
}
|
||||
|
||||
fn put(d: &Path, rel: &str, bytes: &[u8]) -> PathBuf {
|
||||
let p = d.join(rel);
|
||||
std::fs::create_dir_all(p.parent().unwrap()).unwrap();
|
||||
std::fs::write(&p, bytes).unwrap();
|
||||
p
|
||||
}
|
||||
|
||||
/// `p` as changed `secs` from now (a report written after its video is newer than it)
|
||||
fn touch(p: &Path, secs: i64) {
|
||||
let t = if secs >= 0 { SystemTime::now() + Duration::from_secs(secs as u64) } else { SystemTime::now() - Duration::from_secs((-secs) as u64) };
|
||||
std::fs::File::options().write(true).open(p).unwrap().set_modified(t).unwrap();
|
||||
}
|
||||
|
||||
const BRIEF: &str = "Deliverables: 10 total videos (4 solos / 1 mashup per angle).\nUse the phrase \"free, fun, and easy.\"\nDon't let it read as White Elephant.\nEnd on the CTA: \"Make your Wishlist and organize your Gift Exchange on Elfster. It's free.\"\nCTV specs from the client [TO CONFIRM]\n";
|
||||
|
||||
fn contract(extra: &str) -> Make {
|
||||
read(
|
||||
"make",
|
||||
&format!(
|
||||
r#"{{"kind": "cut", "cut": {{"brief": "media/brief.txt", "count": {{"value": 2, "from": "10 total videos"}}, "seconds": [2, 4], "formats": ["16:9"],
|
||||
"cuts": [{{"id": "a1_s1", "angle": "1", "hook": "Direct Problem", "text": "captions"}}, {{"id": "a1_s2"}}],
|
||||
"say": [{{"text": "free, fun, and easy", "from": "Use the phrase \"free, fun, and easy.\""}}],
|
||||
"never": [{{"text": "white elephant", "from": "Don't let it read as White Elephant."}}],
|
||||
"cta": {{"text": "Make your Wishlist and organize your Gift Exchange on Elfster. It's free.", "from": "End on the CTA"}}{extra}}}}}"#
|
||||
),
|
||||
)
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn run(m: &Make, d: &Path) -> Vec<Gate> {
|
||||
gates(m.cut.as_ref().unwrap(), d)
|
||||
}
|
||||
|
||||
fn named<'a>(g: &'a [Gate], name: &str) -> Vec<&'a Gate> {
|
||||
g.iter().filter(|g| g.name == name).collect()
|
||||
}
|
||||
|
||||
fn of(g: &[Gate], name: &str, file: &str) -> Gate {
|
||||
g.iter().find(|g| g.name == name && g.of.as_deref() == Some(file)).unwrap_or_else(|| panic!("no {name} gate of {file}")).clone()
|
||||
}
|
||||
|
||||
/// Words said evenly from 0.5 s, one every 0.6 s, as `raea words` writes them.
|
||||
fn words(line: &str) -> String {
|
||||
let w: Vec<Value> = line.split_whitespace().enumerate().map(|(i, t)| json!({"text": t, "start": 0.5 + i as f64 * 0.6, "end": 0.8 + i as f64 * 0.6})).collect();
|
||||
serde_json::to_string(&w).unwrap()
|
||||
}
|
||||
|
||||
/// A delivered file (the test clip) with its words and frames check written after it.
|
||||
fn deliver(d: &Path, file: &str, said: &str, frame_errors: &[&str]) {
|
||||
let f = put(d, file, &std::fs::read(CLIP).unwrap());
|
||||
touch(&f, -60);
|
||||
let stem = file.trim_end_matches(".mp4");
|
||||
put(d, &format!("{stem}.words.json"), words(said).as_bytes());
|
||||
let findings: Vec<Value> = frame_errors.iter().map(|e| json!({"level": "error", "kind": "face-cut", "says": e})).collect();
|
||||
put(d, &format!("{stem}.frames-check.json"), json!({"findings": findings}).to_string().as_bytes());
|
||||
}
|
||||
|
||||
const GOOD: &str = "So it draws the names for you it's free fun and easy to set up and everyone makes a wishlist so nobody draws their own name ever again Make your Wishlist and organize your Gift Exchange on Elfster It's free";
|
||||
const S1: &str = "out/cuts/a1_s1_16x9.mp4";
|
||||
const S2: &str = "out/cuts/a1_s2_16x9.mp4";
|
||||
|
||||
#[test]
|
||||
fn the_contract_is_read_and_doctored() {
|
||||
let m = contract("");
|
||||
assert_eq!(m.kind, raea_core_brief::make::Kind::Cut);
|
||||
assert_eq!(raea_core_brief::make::deliverables(&m), vec![S1, S2]);
|
||||
assert!(raea_core_brief::make::doctor(&m).is_empty(), "{:?}", raea_core_brief::make::doctor(&m));
|
||||
let bad: Make = read("make", r#"{"kind": "cut", "cut": {"brief": "b.txt", "cuts": [{"id": "A-1", "formats": ["tall"], "text": "both"}], "say": [{"text": "x", "from": ""}]}}"#).unwrap();
|
||||
let d = raea_core_brief::make::doctor(&bad).join("\n");
|
||||
for want in ["no `count`", "no `cta`", "ids are [a-z0-9_]", "isn't W:H", "no length", "captions, hook or none", "has no `from`"] {
|
||||
assert!(d.contains(want), "{want} in\n{d}");
|
||||
}
|
||||
let none: Make = read("make", r#"{"kind": "cut"}"#).unwrap();
|
||||
assert!(raea_core_brief::make::doctor(&none).iter().any(|x| x.contains("no `cut`")));
|
||||
assert_eq!(cut::norm("24/7 Virtual Vet Care. It’s free!"), "24 7 virtual vet care its free");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_rule_quotes_the_brief() {
|
||||
let d = dir("quotes");
|
||||
assert!(named(&run(&contract(""), &d), "quotes")[0].says.contains("no brief text"));
|
||||
put(&d, "media/brief.txt", BRIEF.as_bytes());
|
||||
assert!(named(&run(&contract(""), &d), "quotes")[0].clear);
|
||||
// a rule the brief doesn't say, or says in other words, is held
|
||||
let invented = contract(r#", "open": [{"question": "Which code?", "from": "the offer is PETS99"}]"#);
|
||||
let g = run(&invented, &d);
|
||||
assert!(!named(&g, "quotes")[0].clear);
|
||||
assert!(named(&g, "quotes")[0].says.contains("Which code?"), "{:?}", named(&g, "quotes"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_count_and_open_items_hold_the_job() {
|
||||
let d = dir("count");
|
||||
put(&d, "media/brief.txt", BRIEF.as_bytes());
|
||||
let mut m = contract("");
|
||||
m.cut.as_mut().unwrap().count.as_mut().unwrap().value = 10;
|
||||
assert!(!named(&run(&m, &d), "count")[0].clear);
|
||||
let mut asked = contract(r#", "open": [{"question": "Only 2 interviews came: cut 2?", "from": "10 total videos", "about": "count"}]"#);
|
||||
asked.cut.as_mut().unwrap().count.as_mut().unwrap().value = 10;
|
||||
let g = run(&asked, &d);
|
||||
assert!(!named(&g, "count")[0].clear, "an open item without its answer doesn't excuse the count");
|
||||
assert!(named(&g, "open")[0].says.starts_with("unanswered"));
|
||||
let o = &mut asked.cut.as_mut().unwrap().open[0];
|
||||
o.answer = Some("yes, the 2 we have".into());
|
||||
o.by = Some("Shane".into());
|
||||
let g = run(&asked, &d);
|
||||
assert!(named(&g, "count")[0].clear && named(&g, "open")[0].clear);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_delivered_cut_is_held_to_its_words_shape_and_frames() {
|
||||
let d = dir("files");
|
||||
put(&d, "media/brief.txt", BRIEF.as_bytes());
|
||||
let m = contract("");
|
||||
deliver(&d, S1, GOOD, &[]);
|
||||
deliver(&d, S2, GOOD, &[]);
|
||||
let g = run(&m, &d);
|
||||
assert!(g.iter().all(|g| g.clear), "{g:#?}");
|
||||
assert_eq!(of(&g, "shape", S1).says, "320x180, 3.0 s");
|
||||
// a banned phrase heard, the CTA cut, a phrase missing, a face cut
|
||||
deliver(&d, S2, "we did a white elephant swap last year and it was chaos so we tried something new", &["a face is cut by the left edge from 4.0 s to 5.5 s"]);
|
||||
let g = run(&m, &d);
|
||||
assert!(of(&g, "never", S2).says.contains("\"white elephant\" heard at 2.3 s"), "{:?}", of(&g, "never", S2));
|
||||
assert!(!of(&g, "say", S2).clear && !of(&g, "cta", S2).clear);
|
||||
assert!(of(&g, "frames", S2).says.contains("left edge"));
|
||||
// a report from before the file's last change says nothing about it now
|
||||
touch(&d.join(S1), 60);
|
||||
let g = run(&m, &d);
|
||||
assert!(of(&g, "words", S1).says.contains("changed after it"), "{:?}", of(&g, "words", S1));
|
||||
assert!(of(&g, "frames", S1).says.contains("changed after it"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_wrong_shape_is_named() {
|
||||
let d = dir("shape");
|
||||
put(&d, "media/brief.txt", BRIEF.as_bytes());
|
||||
let mut m = contract("");
|
||||
let p = &mut m.cut.as_mut().unwrap().cuts[0];
|
||||
p.formats = vec!["9:16".into()];
|
||||
p.seconds = Some([20.0, 30.0]);
|
||||
deliver(&d, "out/cuts/a1_s1_9x16.mp4", GOOD, &[]);
|
||||
let says = of(&run(&m, &d), "shape", "out/cuts/a1_s1_9x16.mp4").says;
|
||||
assert!(says.contains("320x180 isn't 9:16") && says.contains("3.0 s isn't 20-30 s"), "{says}");
|
||||
put(&d, "out/cuts/a1_s1_9x16.mp4", b"not a video");
|
||||
assert!(!of(&run(&m, &d), "shape", "out/cuts/a1_s1_9x16.mp4").clear);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heard_the_way_people_say_it() {
|
||||
// Gemini's Elfster A1 solo (11-25): the transcript splits "Wishlist" and the speaker fills the phrase out
|
||||
let d = dir("said");
|
||||
put(&d, "media/brief.txt", BRIEF.as_bytes());
|
||||
let m = contract("");
|
||||
let line = "so it draws the names for you and everyone gets a gift they want It's free it's fun and it's easy so set it up tonight with your whole family Make your wish list and organize your gift exchange on Elfster It's free";
|
||||
deliver(&d, S1, line, &[]);
|
||||
let g = run(&m, &d);
|
||||
assert!(of(&g, "say", S1).clear, "{:?}", of(&g, "say", S1));
|
||||
assert!(of(&g, "cta", S1).clear, "{:?}", of(&g, "cta", S1));
|
||||
// the brief's order is the phrase: "fun, free and easy" isn't it
|
||||
deliver(&d, S1, &line.replace("It's free it's fun", "It's fun it's free"), &[]);
|
||||
assert!(!of(&run(&m, &d), "say", S1).clear);
|
||||
}
|
||||
@@ -11,4 +11,6 @@ raea-core-scene = { path = "../../core/scene" }
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
raea-sys-contact = { path = "../../systems/contact" }
|
||||
raea-sys-stage = { path = "../../systems/stage" }
|
||||
# each part held to its planned detail (MK21)
|
||||
raea-runtime-lod-plan = { path = "../lod-plan" }
|
||||
serde_json = "1"
|
||||
@@ -2,6 +2,8 @@
|
||||
//! clipping check (raea-sys-contact; RAEA_CLIP_CHECK=0 skips it), the staging (raea-sys-stage; RAEA_STAGE_CHECK=0) and
|
||||
//! the manifest's word on the parts (raea_sys_stage::Mounts) keep of them, and let go, so a long render never holds its
|
||||
//! frames' parts for its checks. raea-runtime-export hands each frame in as it's drawn, and a still's at its end.
|
||||
//! With them, each part held to its planned detail (raea-runtime-lod-plan; RAEA_LOD_CHECK=0 skips it): its own `lod`, else
|
||||
//! its name's on the plan above the composition (its plan.rs: `lod` on the brief's make objects, MK22).
|
||||
|
||||
use raea_core_facts::Finding;
|
||||
use raea_core_scene::Item;
|
||||
@@ -10,6 +12,7 @@ use serde_json::Value;
|
||||
pub struct EndChecks {
|
||||
clip: Option<raea_sys_contact::Clipping>,
|
||||
stage: Option<raea_sys_stage::Staging>,
|
||||
lod: Option<raea_runtime_lod_plan::Lods>,
|
||||
mounts: raea_sys_stage::Mounts,
|
||||
any: bool,
|
||||
parts: usize,
|
||||
@@ -19,7 +22,8 @@ impl EndChecks {
|
||||
pub fn new(w: u32, h: u32, fps: f64) -> EndChecks {
|
||||
let on = |k: &str| std::env::var(k).as_deref() != Ok("0");
|
||||
let (clip, stage) = (on("RAEA_CLIP_CHECK").then(|| raea_sys_contact::Clipping::new(w, h, fps)), on("RAEA_STAGE_CHECK").then(|| raea_sys_stage::Staging::new(w, h, fps)));
|
||||
EndChecks { clip, stage, mounts: raea_sys_stage::Mounts::new(w, h), any: false, parts: 0 }
|
||||
let lod = on("RAEA_LOD_CHECK").then(|| raea_runtime_lod_plan::Lods::new(w, h, fps, raea_runtime_lod_plan::plan::here(), false));
|
||||
EndChecks { clip, stage, lod, mounts: raea_sys_stage::Mounts::new(w, h), any: false, parts: 0 }
|
||||
}
|
||||
|
||||
/// The next frame (its number, `frame`): its parts, and its page where the manifest has it.
|
||||
@@ -31,6 +35,9 @@ impl EndChecks {
|
||||
if let Some(s) = &mut self.stage {
|
||||
s.push(frame, its, page);
|
||||
}
|
||||
if let Some(l) = &mut self.lod {
|
||||
l.push(frame, its);
|
||||
}
|
||||
self.mounts.push(frame, its);
|
||||
}
|
||||
|
||||
@@ -47,9 +54,39 @@ impl EndChecks {
|
||||
mark("end checks: clipping");
|
||||
found.extend(self.stage.map_or_else(Vec::new, raea_sys_stage::Staging::told));
|
||||
mark("end checks: staging");
|
||||
// parts shown closer than their planned detail, said as the staging's are
|
||||
let closer = self.lod.map_or_else(Vec::new, |l| l.findings(raea_sys_stage::BY));
|
||||
closer.iter().for_each(|f| eprintln!("raea: {}", f.line()));
|
||||
raea_core_facts::finding::said(&closer);
|
||||
found.extend(closer);
|
||||
// the clipping check's solids, kept for the process, aren't needed again by a render
|
||||
raea_sys_contact::forget();
|
||||
mark("end checks: done, their solids let go");
|
||||
(found, Some(seen))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn item(kind: &'static str, props: Value, shape: Option<&str>) -> Item {
|
||||
Item { kind, props: Arc::new(props.as_object().cloned().unwrap_or_default()), shape: shape.map(Arc::from), at: None, material: None, world: Default::default() }
|
||||
}
|
||||
|
||||
// MK21: a render's end checks say a part shown closer than its planned detail, with its other findings
|
||||
#[test]
|
||||
fn a_render_says_a_part_shown_closer_than_its_planned_detail() {
|
||||
let frame = |z: f32, lod: u8| vec![item("camera", json!({"position": [0.0, 0.0, z], "lookAt": [0, 0, 0], "fov": 50}), None), item("mesh", json!({"name": "kiosk", "lod": lod}), Some("box(1, 1, 1)"))];
|
||||
let run = |z: f32, lod: u8| {
|
||||
let mut e = EndChecks::new(1280, 720, 30.0);
|
||||
e.push(0, &frame(z, lod), None);
|
||||
e.told(|_| {}).0.into_iter().filter(|f| f.check == "lod-closer").collect::<Vec<_>>()
|
||||
};
|
||||
let found = run(2.0, 4);
|
||||
assert_eq!((found.len(), found[0].level, found[0].by.as_str()), (1, raea_core_facts::Level::Error, "raea render"), "{found:?}");
|
||||
assert!(run(2.0, 0).is_empty() && run(80.0, 4).is_empty(), "a hero up close and a far part far away are as planned");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "raea-runtime-lod-plan"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
license = "FSL-1.1-ALv2"
|
||||
publish = false
|
||||
description = "Planned detail held to the frame: a part planned as a grey box or as far away (lod 0 the hero to 4 far) that a shot shows closer than its plan, the levels a job's plan gives its objects, the gate a job is held at and raea scene lod's table (docs/make.feature MK21-MK24)"
|
||||
|
||||
[dependencies]
|
||||
raea-core-scene = { path = "../../core/scene" }
|
||||
# its results as Findings (docs/direction.feature DR3)
|
||||
raea-core-facts = { path = "../../core/facts" }
|
||||
# the frame's camera, a part's box and what stands in front of it
|
||||
raea-sys-stage = { path = "../../systems/stage" }
|
||||
# the brief above a composition, found as raea make finds it (MK22)
|
||||
dunce = "1"
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std"] }
|
||||
serde_json = "1"
|
||||
@@ -0,0 +1,304 @@
|
||||
//! raea-runtime-lod-plan (docs/make.feature MK21), planned detail held to the frame: a part planned as a grey box or as something far away (`lod` on the part,
|
||||
//! or on its object in the plan, `make` on brief.ts) that a shot then shows closer than its plan. A plan's level is how
|
||||
//! large the part is meant to be seen, 0 (the hero, half the frame or more) to 4 (far, under 2% of it); a frame's level
|
||||
//! is how large the part's box is on screen through that frame's camera. A part seen finer than planned was built for
|
||||
//! a distance the camera no longer keeps: a warning one level finer, an error two or more. It reads the scene, not the
|
||||
//! pixels: a part behind others is passed over only when every line from the camera to it crosses another mesh's box
|
||||
//! (a hollow shape's box hides more than the shape does, so a part behind one may be missed; one in the open never is).
|
||||
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
|
||||
use bevy::math::Vec3;
|
||||
use raea_core_facts::{Finding, Level};
|
||||
use raea_core_scene::base_ident;
|
||||
use serde_json::Value;
|
||||
|
||||
use raea_core_scene::Item;
|
||||
use raea_sys_stage::{View, called, corners, crossing, model_box, own_box, see_through};
|
||||
|
||||
// the levels a job's plan gives its objects (`lod` on brief.ts's make objects, MK22)
|
||||
pub mod plan;
|
||||
// the gate a job is held at, and the table `raea scene lod` prints
|
||||
mod report;
|
||||
pub use report::{gate, held, ordered, table};
|
||||
|
||||
/// The coarsest level: far, a silhouette.
|
||||
pub const COARSEST: u8 = 4;
|
||||
/// SPANS[k]: a part across this share of the frame or more (the larger of its width's and its height's) is seen at
|
||||
/// level k; under the last it is at level 4. Unity's and Unreal's levels switch on the same measure, size on screen.
|
||||
pub const SPANS: [f32; 4] = [0.5, 0.2, 0.08, 0.02];
|
||||
/// What each level is for.
|
||||
pub const NAMES: [&str; 5] = ["hero", "featured", "dressing", "background", "far"];
|
||||
|
||||
/// The level a part across `span` of the frame is seen at.
|
||||
pub fn level(span: f32) -> u8 {
|
||||
SPANS.iter().position(|s| span >= *s).unwrap_or(SPANS.len()) as u8
|
||||
}
|
||||
|
||||
/// A level in words: "LOD 3 (background, under 8% of the frame)".
|
||||
pub fn words(l: u8) -> String {
|
||||
let l = l.min(COARSEST) as usize;
|
||||
let size = if l == 0 { format!("{:.0}% of the frame or more", SPANS[0] * 100.0) } else { format!("under {:.0}% of the frame", SPANS[l - 1] * 100.0) };
|
||||
format!("LOD {l} ({}, {size})", NAMES[l])
|
||||
}
|
||||
|
||||
/// A part's planned level: its own `lod`, else its name's in the plan.
|
||||
fn planned(it: &Item, plan: &HashMap<String, u8>) -> Option<u8> {
|
||||
let own = it.props.get("lod").and_then(Value::as_f64).filter(|l| *l >= 0.0).map(|l| (l as u8).min(COARSEST));
|
||||
own.or_else(|| plan.get(base_ident(it)).copied())
|
||||
}
|
||||
|
||||
/// How much of the frame a part's box spans through `v` (the larger of its width's and its height's share, 1 at
|
||||
/// most), and the box's corners; None when its size isn't known or none of it is in the frame.
|
||||
fn span(it: &Item, v: &View, boxes: &mut HashMap<String, Option<(Vec3, Vec3)>>) -> Option<(f32, [Vec3; 8])> {
|
||||
let (lo, hi) = match it.kind {
|
||||
"mesh" => own_box(it, boxes)?,
|
||||
"model" => model_box(it, boxes)?,
|
||||
_ => return None,
|
||||
};
|
||||
let pts = corners(&it.world, lo, hi);
|
||||
if let Some(b) = v.bounds(pts) {
|
||||
return (v.share(b) > 0.0).then(|| (((b[2] - b[0]) / v.w).max((b[3] - b[1]) / v.h).min(1.0), pts));
|
||||
}
|
||||
// across the camera's plane: the camera is in it or beside it, so it is measured at its nearest point
|
||||
let near = it.world.transform_point3(it.world.inverse().transform_point3(v.eye).clamp(lo, hi));
|
||||
if near.distance(v.eye) < 1e-4 {
|
||||
return Some((1.0, pts));
|
||||
}
|
||||
let [x, y, depth] = v.project(near)?;
|
||||
(x >= 0.0 && x <= v.w && y >= 0.0 && y <= v.h).then(|| (((pts[7] - pts[0]).length() * v.focal / depth / v.h).min(1.0), pts))
|
||||
}
|
||||
|
||||
/// Whether other parts stand between the camera and all of a part: its box's middle and eight points halfway out to
|
||||
/// its corners, each behind a mesh's box the line passes right through (not one the camera or the point is inside: a
|
||||
/// room round either hides nothing). Models never hide: a file's box is mostly air.
|
||||
fn hidden(its: &[Item], me: usize, pts: &[Vec3; 8], eye: Vec3, boxes: &mut HashMap<String, Option<(Vec3, Vec3)>>) -> bool {
|
||||
let mid = pts.iter().copied().sum::<Vec3>() / 8.0;
|
||||
let targets: Vec<Vec3> = std::iter::once(mid).chain(pts.iter().map(|p| mid + (*p - mid) * 0.5)).collect();
|
||||
let mut others = Vec::new();
|
||||
for (j, it) in its.iter().enumerate() {
|
||||
if j == me || it.kind != "mesh" || it.at.is_some() || see_through(it) {
|
||||
continue;
|
||||
}
|
||||
if let Some((lo, hi)) = own_box(it, boxes) {
|
||||
others.push((it.world.inverse(), lo, hi));
|
||||
}
|
||||
}
|
||||
targets.iter().all(|p| others.iter().any(|(inv, lo, hi)| crossing(inv.transform_point3(eye), inv.transform_point3(*p), *lo, *hi).is_some_and(|(t0, t1)| t0 > 0.0 && t1 < 1.0)))
|
||||
}
|
||||
|
||||
/// What the frames showed of one part.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Seen {
|
||||
pub name: String,
|
||||
pub planned: Option<u8>,
|
||||
/// how many frames it was in
|
||||
pub frames: usize,
|
||||
/// where it was largest: the frame's number, and the share of the frame it spanned there
|
||||
pub finest: Option<(i64, f32)>,
|
||||
/// how many frames showed it finer than planned
|
||||
pub closer: usize,
|
||||
}
|
||||
|
||||
impl Seen {
|
||||
/// The finest level it was seen at.
|
||||
pub fn level(&self) -> Option<u8> {
|
||||
self.finest.map(|(_, s)| level(s))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Part {
|
||||
planned: Option<u8>,
|
||||
frames: usize,
|
||||
/// its largest: (frame, span)
|
||||
finest: Option<(i64, f32)>,
|
||||
/// the frames it was seen finer than planned: (frame, span)
|
||||
closer: Vec<(i64, f32)>,
|
||||
}
|
||||
|
||||
/// Each frame as it comes: per part, how often it was in the frame, where it was largest, and the frames it was seen
|
||||
/// finer than its plan. A render keeps only the parts with a plan; `every` keeps all (`raea scene lod`'s table).
|
||||
pub struct Lods {
|
||||
plan: HashMap<String, u8>,
|
||||
every: bool,
|
||||
w: u32,
|
||||
h: u32,
|
||||
fps: f64,
|
||||
boxes: HashMap<String, Option<(Vec3, Vec3)>>,
|
||||
parts: BTreeMap<String, Part>,
|
||||
}
|
||||
|
||||
impl Lods {
|
||||
/// For frames w x h at `fps`. `plan` is the levels the job's plan gives its objects, by name (`lod` on brief.ts's
|
||||
/// make objects); a part's own `lod` comes first.
|
||||
pub fn new(w: u32, h: u32, fps: f64, plan: HashMap<String, u8>, every: bool) -> Lods {
|
||||
Lods { plan, every, w, h, fps: fps.max(1.0), boxes: HashMap::new(), parts: BTreeMap::new() }
|
||||
}
|
||||
|
||||
/// The next frame's parts, through its camera.
|
||||
pub fn push(&mut self, frame: i64, its: &[Item]) {
|
||||
if self.plan.is_empty() && !self.every && !its.iter().any(|it| it.props.contains_key("lod")) {
|
||||
return;
|
||||
}
|
||||
let Some(v) = View::of(its, self.w, self.h) else { return };
|
||||
for (j, it) in its.iter().enumerate() {
|
||||
if !matches!(it.kind, "mesh" | "model") || it.at.is_some() {
|
||||
continue;
|
||||
}
|
||||
let plan = planned(it, &self.plan);
|
||||
if plan.is_none() && !self.every {
|
||||
continue;
|
||||
}
|
||||
let Some((s, pts)) = span(it, &v, &mut self.boxes) else { continue };
|
||||
let closer = plan.is_some_and(|p| level(s) < p);
|
||||
if closer && hidden(its, j, &pts, v.eye, &mut self.boxes) {
|
||||
continue;
|
||||
}
|
||||
// parts of one name planned apart (two crates, one a hero) are told apart
|
||||
let mut name = called(it);
|
||||
if self.parts.get(&name).is_some_and(|p| p.planned != plan) {
|
||||
name = format!("{name} (lod {})", plan.map_or("none".into(), |p| p.to_string()));
|
||||
}
|
||||
let part = self.parts.entry(name).or_default();
|
||||
part.planned = plan;
|
||||
part.frames += 1;
|
||||
if part.finest.is_none_or(|(_, best)| s > best) {
|
||||
part.finest = Some((frame, s));
|
||||
}
|
||||
if closer {
|
||||
part.closer.push((frame, s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What the frames showed of each part, by name.
|
||||
pub fn seen(&self) -> Vec<Seen> {
|
||||
self.parts.iter().map(|(name, p)| Seen { name: name.clone(), planned: p.planned, frames: p.frames, finest: p.finest, closer: p.closer.len() }).collect()
|
||||
}
|
||||
|
||||
/// One finding a part seen finer than planned, worst first: where it was largest, and for how long.
|
||||
pub fn findings(&self, by: &str) -> Vec<Finding> {
|
||||
let mut out = Vec::new();
|
||||
for (name, p) in &self.parts {
|
||||
let (Some(plan), Some(&(first, _)), Some(&(last, _))) = (p.planned, p.closer.first(), p.closer.last()) else { continue };
|
||||
let Some(&(at, s)) = p.closer.iter().max_by(|a, b| a.1.total_cmp(&b.1)) else { continue };
|
||||
let seen = level(s);
|
||||
let lasts = if p.closer.len() == 1 { "on one frame".to_string() } else { format!("on {} frames ({:.1} s)", p.closer.len(), p.closer.len() as f64 / self.fps) };
|
||||
let says = format!("'{name}' is planned at {} and is seen at {}: across {:.0}% of the frame at frame {at}, closer than planned {lasts}", words(plan), words(seen), s * 100.0);
|
||||
let fix = format!("build it for LOD {seen} and plan it there (lod={{{seen}}} on the part, or `lod: {seen}` on its object in brief.ts), or keep the camera off it");
|
||||
let level = if plan - seen >= 2 { Level::Error } else { Level::Warn };
|
||||
out.push(Finding::new("lod-closer", level, says, by).frames(first, last + 1).about(name.clone(), None).measure("span", (s * 100.0) as f64, "% of the frame", Some((SPANS[plan as usize - 1] * 100.0) as f64)).fix(fix));
|
||||
}
|
||||
raea_core_facts::finding::ranked(out)
|
||||
}
|
||||
}
|
||||
|
||||
/// Every part of the frames against its planned detail (`all[k]` is frame `frames[k]`'s parts): each part's row, and a
|
||||
/// finding a part seen finer than planned.
|
||||
pub fn lods(all: &[Vec<Item>], frames: &[i64], w: u32, h: u32, fps: f64, by: &str, plan: HashMap<String, u8>) -> (Vec<Seen>, Vec<Finding>) {
|
||||
let mut l = Lods::new(w, h, fps, plan, true);
|
||||
for (k, its) in all.iter().enumerate() {
|
||||
l.push(frames[k], its);
|
||||
}
|
||||
(l.seen(), l.findings(by))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bevy::math::Mat4;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
|
||||
fn item(kind: &'static str, props: Value, world: Mat4) -> Item {
|
||||
Item { kind, props: Arc::new(props.as_object().cloned().unwrap_or_default()), shape: None, at: None, material: None, world }
|
||||
}
|
||||
|
||||
/// A camera at `eye` looking at `at`, 50 degrees.
|
||||
fn cam(eye: [f32; 3], at: [f32; 3]) -> Item {
|
||||
item("camera", json!({"position": eye, "lookAt": at, "fov": 50}), Mat4::IDENTITY)
|
||||
}
|
||||
|
||||
/// a 1 m cube at `at`, with these props
|
||||
fn cube(props: Value, at: [f32; 3]) -> Item {
|
||||
let mut it = item("mesh", props, Mat4::from_translation(Vec3::from(at)));
|
||||
it.shape = Some(Arc::from("box(1, 1, 1)"));
|
||||
it
|
||||
}
|
||||
|
||||
fn run(frames: Vec<Vec<Item>>, plan: &[(&str, u8)]) -> (Vec<Seen>, Vec<Finding>) {
|
||||
let nums: Vec<i64> = (0..frames.len() as i64).collect();
|
||||
lods(&frames, &nums, 1920, 1080, 30.0, "test", plan.iter().map(|(n, l)| (n.to_string(), *l)).collect())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_level_is_how_much_of_the_frame_a_part_spans() {
|
||||
assert_eq!([0.9, 0.5, 0.3, 0.1, 0.05, 0.01].map(level), [0, 0, 1, 2, 3, 4]);
|
||||
assert_eq!(words(3), "LOD 3 (background, under 8% of the frame)");
|
||||
assert_eq!(words(0), "LOD 0 (hero, 50% of the frame or more)");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_far_part_the_camera_comes_up_to_is_said_with_where_and_how_close() {
|
||||
// planned far (4); the camera dollies from 60 m to 2 m
|
||||
let frames: Vec<Vec<Item>> = [60.0, 30.0, 8.0, 2.0].iter().map(|z| vec![cam([0.0, 0.0, *z], [0.0, 0.0, 0.0]), cube(json!({"name": "crate", "lod": 4}), [0.0, 0.0, 0.0])]).collect();
|
||||
let (seen, found) = run(frames, &[]);
|
||||
assert_eq!((seen[0].planned, seen[0].level(), seen[0].closer), (Some(4), Some(0), 3), "{seen:?}");
|
||||
assert_eq!(seen[0].finest.map(|f| f.0), Some(3));
|
||||
let f = &found[0];
|
||||
assert_eq!((f.check.as_str(), f.level, f.frames), ("lod-closer", Level::Error, Some([1, 4])), "{f:?}");
|
||||
assert!(f.says.starts_with("'crate' is planned at LOD 4 (far, under 2% of the frame) and is seen at LOD 0 (hero") && f.says.contains("at frame 3, closer than planned on 3 frames (0.1 s)"), "{}", f.says);
|
||||
assert!(f.fix.as_deref().unwrap().contains("lod={0}"), "{:?}", f.fix);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_level_finer_warns_and_a_part_at_its_plan_says_nothing() {
|
||||
// a 1 m cube 5 m off a 50 degree lens is about 23% of the frame's height: level 1
|
||||
let scene = |lod: u8| vec![vec![cam([0.0, 0.0, 5.5], [0.0, 0.0, 0.0]), cube(json!({"name": "crate", "lod": lod}), [0.0, 0.0, 0.0])]];
|
||||
assert!(run(scene(1), &[]).1.is_empty() && run(scene(0), &[]).1.is_empty());
|
||||
assert_eq!(run(scene(2), &[]).1[0].level, Level::Warn);
|
||||
assert_eq!(run(scene(3), &[]).1[0].level, Level::Error);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_plan_names_a_part_and_its_own_lod_wins() {
|
||||
let scene = |props: Value| vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), cube(props, [0.0, 0.0, 0.0])]];
|
||||
let (seen, found) = run(scene(json!({"name": "kiosk"})), &[("kiosk", 3)]);
|
||||
assert_eq!((seen[0].planned, found.len()), (Some(3), 1));
|
||||
assert!(run(scene(json!({"name": "kiosk", "lod": 0})), &[("kiosk", 3)]).1.is_empty(), "the part's own level is the newer word");
|
||||
// a part with no plan is never a finding; the table still has its row, and a render doesn't keep it
|
||||
let (seen, found) = run(scene(json!({"name": "other"})), &[("kiosk", 3)]);
|
||||
assert_eq!((seen[0].planned, seen[0].level(), found.len()), (None, Some(1), 0));
|
||||
let mut l = Lods::new(1920, 1080, 30.0, HashMap::from([("kiosk".to_string(), 3)]), false);
|
||||
l.push(0, &scene(json!({"name": "other"}))[0]);
|
||||
assert!(l.seen().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_part_out_of_frame_behind_the_camera_or_behind_a_wall_is_not_seen() {
|
||||
let far = |at: [f32; 3]| cube(json!({"name": "crate", "lod": 4}), at);
|
||||
// beside the frame, and behind the camera
|
||||
assert!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([40.0, 0.0, 0.0])]], &[]).1.is_empty());
|
||||
assert!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 9.0])]], &[]).1.is_empty());
|
||||
// a wall wider than it between the two hides it; a post narrower than it doesn't
|
||||
let mut wall = cube(json!({"name": "wall"}), [0.0, 0.0, 1.5]);
|
||||
wall.world = Mat4::from_translation(Vec3::new(0.0, 0.0, 1.5)) * Mat4::from_scale(Vec3::new(6.0, 6.0, 0.2));
|
||||
assert!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 0.0]), wall.clone()]], &[]).1.is_empty());
|
||||
wall.world = Mat4::from_translation(Vec3::new(0.0, 0.0, 1.5)) * Mat4::from_scale(Vec3::new(0.1, 6.0, 0.1));
|
||||
assert_eq!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 0.0]), wall]], &[]).1.len(), 1);
|
||||
// a room round both hides nothing
|
||||
let mut room = cube(json!({"name": "room"}), [0.0, 0.0, 0.0]);
|
||||
room.world = Mat4::from_scale(Vec3::splat(20.0));
|
||||
assert_eq!(run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), far([0.0, 0.0, 0.0]), room]], &[]).1.len(), 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_camera_inside_or_beside_a_part_sees_it_at_its_nearest() {
|
||||
// a 30 m hall the camera stands in, planned as background
|
||||
let mut hall = cube(json!({"name": "hall", "lod": 3}), [0.0, 0.0, 0.0]);
|
||||
hall.world = Mat4::from_scale(Vec3::new(30.0, 4.0, 30.0));
|
||||
let (seen, found) = run(vec![vec![cam([0.0, 0.0, 3.0], [0.0, 0.0, 0.0]), hall]], &[]);
|
||||
assert_eq!((seen[0].level(), found[0].level), (Some(0), Level::Error));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
//! The levels a job's plan gives its objects (docs/make.feature MK22): `lod` on the objects of `make` in the brief.ts
|
||||
//! at or above a composition, inside its raea project. Read only when the brief's words hold a `lod` at all, since
|
||||
//! reading it runs the module (`raea spec brief.ts --as brief`, a child process: this crate carries no TS engine);
|
||||
//! read once a brief's version a process. A brief that doesn't load plans nothing: a render never fails on it.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use serde_json::Value;
|
||||
|
||||
/// The last brief read: its path, when it last changed, and its levels.
|
||||
static READ: Mutex<Option<(PathBuf, Option<SystemTime>, HashMap<String, u8>)>> = Mutex::new(None);
|
||||
|
||||
/// The composition a command was given: its first word naming a .tsx or .jsx file (`raea render EDIT.tsx ...`).
|
||||
pub fn composition(words: impl IntoIterator<Item = String>) -> Option<PathBuf> {
|
||||
for w in words {
|
||||
if w.ends_with(".tsx") || w.ends_with(".jsx") {
|
||||
return Some(PathBuf::from(w));
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// The plan's levels for the composition this process was asked to render, read from its own command line: a render's
|
||||
/// end checks are made deep in the export, which isn't told where the composition is. None when it names none.
|
||||
pub fn here() -> HashMap<String, u8> {
|
||||
let dir = composition(std::env::args().skip(1)).and_then(|c| std::path::absolute(c).ok()).and_then(|c| c.parent().map(Path::to_path_buf));
|
||||
dir.map(|d| lods(&d)).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// The brief.ts at or above `dir` in its project whose words plan a level.
|
||||
fn brief(dir: &Path) -> Option<PathBuf> {
|
||||
let dir = dunce::canonicalize(dir).ok()?;
|
||||
let project = raea_core_facts::record::up(&dir, ".raea/project");
|
||||
for d in dir.ancestors() {
|
||||
let p = d.join("brief.ts");
|
||||
if p.is_file() {
|
||||
return std::fs::read_to_string(&p).is_ok_and(|t| t.contains("lod")).then_some(p);
|
||||
}
|
||||
if project.as_deref() == Some(d) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// The levels in a brief as `raea spec --as brief` prints it: each of make's objects with a `lod`, by its id.
|
||||
pub fn of_brief(v: &Value) -> HashMap<String, u8> {
|
||||
let b = v.get("brief").unwrap_or(v);
|
||||
let objects = b["make"]["objects"].as_array().into_iter().flatten();
|
||||
objects.filter_map(|o| Some((o["id"].as_str()?.to_string(), o["lod"].as_u64()?.min(crate::COARSEST as u64) as u8))).collect()
|
||||
}
|
||||
|
||||
/// The plan's levels for a composition in `dir`: object id to level, empty when no brief above it plans any.
|
||||
pub fn lods(dir: &Path) -> HashMap<String, u8> {
|
||||
let Some(brief) = brief(dir) else { return HashMap::new() };
|
||||
let changed = std::fs::metadata(&brief).and_then(|m| m.modified()).ok();
|
||||
if let Some((p, at, plan)) = READ.lock().unwrap().as_ref() {
|
||||
if *p == brief && *at == changed {
|
||||
return plan.clone();
|
||||
}
|
||||
}
|
||||
let read = || {
|
||||
let out = std::process::Command::new(std::env::current_exe().ok()?).arg("spec").arg(&brief).args(["--as", "brief"]).env("RAEA_RECORD", "off").output().ok()?;
|
||||
let text = String::from_utf8_lossy(&out.stdout);
|
||||
Some(of_brief(&serde_json::from_str(&text[text.find('{')?..]).ok()?))
|
||||
};
|
||||
let plan = read().unwrap_or_default();
|
||||
*READ.lock().unwrap() = Some((brief, changed, plan.clone()));
|
||||
plan
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn a_briefs_objects_with_a_level_are_the_plan() {
|
||||
let v = json!({"brief": {"make": {"kind": "scene", "objects": [{"id": "kiosk", "lod": 3}, {"id": "desk"}, {"id": "sign", "lod": 9}]}}});
|
||||
let plan = of_brief(&v);
|
||||
assert_eq!((plan.len(), plan["kiosk"], plan["sign"]), (2, 3, 4));
|
||||
assert!(of_brief(&json!({"title": "no job"})).is_empty());
|
||||
// as `raea spec brief.ts --as brief` prints it: the brief itself, every field given, a level left out null
|
||||
let printed = json!({"title": "Kiosk square", "make": {"kind": "scene", "objects": [{"id": "kiosk", "lod": 3, "hero": null}, {"id": "desk", "lod": null}]}});
|
||||
assert_eq!(of_brief(&printed), HashMap::from([("kiosk".to_string(), 3)]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_composition_is_the_commands_first_tsx() {
|
||||
let words = |w: &[&str]| composition(w.iter().map(|s| s.to_string()));
|
||||
assert_eq!(words(&["render", "shots/walk.tsx", "-o", "out/walk.mp4"]), Some(PathBuf::from("shots/walk.tsx")));
|
||||
assert_eq!(words(&["check", "out/walk.mp4"]), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_folder_with_no_brief_planning_a_level_plans_nothing() {
|
||||
let d = std::env::temp_dir().join(format!("raea-lod-plan-{}", std::process::id()));
|
||||
std::fs::create_dir_all(d.join(".raea")).unwrap();
|
||||
std::fs::write(d.join(".raea/project"), "").unwrap();
|
||||
assert!(lods(&d).is_empty());
|
||||
std::fs::write(d.join("brief.ts"), "export default brief({ title: \"x\" })").unwrap();
|
||||
assert!(brief(&d).is_none(), "a brief whose words plan no level isn't run");
|
||||
let _ = std::fs::remove_dir_all(&d);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
//! What is said of planned detail once the frames are read: the parts a job is held at (`raea make status`'s lod gate,
|
||||
//! MK24) and the table `raea scene lod` prints (MK23).
|
||||
|
||||
use raea_core_facts::Finding;
|
||||
|
||||
use crate::{Seen, level};
|
||||
|
||||
/// Of a render's or check's findings, the parts seen closer than planned (`lod-closer`), and those of them not yet
|
||||
/// answered in the job's notes: a line of NOTES.md with `lod` and the part's name answers it.
|
||||
pub fn held<'a>(findings: &'a [Finding], notes: &str) -> (Vec<&'a str>, Vec<&'a str>) {
|
||||
let answered = |name: &str| notes.lines().any(|l| l.to_lowercase().contains("lod") && l.contains(name));
|
||||
let name = |f: &'a Finding| (f.check == "lod-closer").then(|| f.about.first()).flatten().map(|a| a.name.as_str());
|
||||
let closer: Vec<&str> = findings.iter().filter_map(name).collect();
|
||||
let open = closer.iter().copied().filter(|n| !answered(n)).collect();
|
||||
(closer, open)
|
||||
}
|
||||
|
||||
/// A composition's lod gate, from the findings of its last render or check (the record's entry `id`): whether it is
|
||||
/// clear and what it says, None when the job plans no level and the render found none. Two levels finer is an error,
|
||||
/// which the checks gate holds until it's fixed; one level finer is held here until the part is replanned and rendered
|
||||
/// again, or answered in the notes.
|
||||
pub fn gate(of: &str, id: &str, findings: &[Finding], notes: &str, plans: bool) -> Option<(bool, String)> {
|
||||
let (closer, open) = held(findings, notes);
|
||||
if open.is_empty() {
|
||||
return (plans || !closer.is_empty()).then(|| (true, format!("no part closer than its planned detail left unanswered at {id}")));
|
||||
}
|
||||
Some((false, format!("seen closer than planned at {id}: {}. Build each for the level it's seen at and plan it there (`lod` on its object in brief.ts or on the part), keep the camera off it, or answer in NOTES.md on a line with `lod` and its name; raea scene lod {of} lists every part", open.join(", "))))
|
||||
}
|
||||
|
||||
/// What a row says of its part: closer than planned, never as close as planned, or as planned.
|
||||
fn verdict(s: &Seen) -> &'static str {
|
||||
match (s.planned, s.level()) {
|
||||
(Some(p), Some(l)) if l < p => "CLOSER than planned",
|
||||
(Some(p), Some(l)) if l > p => "never this close: planned finer than any frame shows it",
|
||||
(Some(_), _) => "as planned",
|
||||
(None, _) => "no plan",
|
||||
}
|
||||
}
|
||||
|
||||
/// The rows in reading order: seen closer than planned (the widest gap first), the rest of the planned, then the
|
||||
/// unplanned, each by how large it gets.
|
||||
pub fn ordered(mut seen: Vec<Seen>) -> Vec<Seen> {
|
||||
let gap = |s: &Seen| s.planned.zip(s.level()).map_or(0, |(p, l)| p.saturating_sub(l));
|
||||
let size = |s: &Seen| s.finest.map_or(0.0, |f| f.1);
|
||||
seen.sort_by(|a, b| (gap(b), b.planned.is_some()).cmp(&(gap(a), a.planned.is_some())).then(size(b).total_cmp(&size(a))).then(a.name.cmp(&b.name)));
|
||||
seen
|
||||
}
|
||||
|
||||
/// The table: a row a part, its plan beside the finest level a frame showed it at, how much of the frame it spanned
|
||||
/// there, at which frame, and how many frames it was in.
|
||||
pub fn table(seen: &[Seen]) -> Vec<String> {
|
||||
let mut t = vec![format!("{:<32} {:>7} {:>5} {:>7} {:>7} {:>7} ", "part", "planned", "seen", "largest", "at", "frames")];
|
||||
let n = |l: Option<u8>| l.map_or("-".into(), |l| l.to_string());
|
||||
for s in seen {
|
||||
let (at, span) = s.finest.map_or(("-".into(), "-".into()), |(f, sp)| (f.to_string(), format!("{:.0}%", sp * 100.0)));
|
||||
t.push(format!("{:<32} {:>7} {:>5} {:>7} {:>7} {:>7} {}", s.name.chars().take(32).collect::<String>(), n(s.planned), n(s.finest.map(|f| level(f.1))), span, at, s.frames, verdict(s)));
|
||||
}
|
||||
t
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use raea_core_facts::Level;
|
||||
|
||||
fn row(name: &str, planned: Option<u8>, span: f32) -> Seen {
|
||||
Seen { name: name.into(), planned, frames: 10, finest: Some((4, span)), closer: 0 }
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_table_reads_closer_than_planned_first_then_planned_then_the_rest_by_size() {
|
||||
let rows = ordered(vec![row("floor", None, 1.0), row("desk", Some(0), 0.6), row("kiosk", Some(3), 0.3), row("tower", Some(4), 0.05), row("lamp", None, 0.1), row("phone", Some(0), 0.04)]);
|
||||
assert_eq!(rows.iter().map(|r| r.name.as_str()).collect::<Vec<_>>(), ["kiosk", "tower", "desk", "phone", "floor", "lamp"]);
|
||||
let t = table(&rows);
|
||||
assert!(t[1].starts_with("kiosk") && t[1].ends_with("CLOSER than planned"), "{}", t[1]);
|
||||
assert!(t[3].ends_with("as planned"), "{}", t[3]);
|
||||
assert!(t[4].ends_with("never this close: planned finer than any frame shows it"), "{}", t[4]);
|
||||
assert!(t[5].ends_with("no plan"), "{}", t[5]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_part_seen_closer_is_held_until_a_notes_line_with_lod_and_its_name_answers_it() {
|
||||
let closer = |name: &str| Finding::new("lod-closer", Level::Warn, format!("'{name}' is planned at LOD 3"), "raea render").about(name, None);
|
||||
let fs = [closer("kiosk"), Finding::new("clips", Level::Error, "the mug is in the desk", "raea render").about("mug", None), closer("tower")];
|
||||
assert_eq!(held(&fs, ""), (vec!["kiosk", "tower"], vec!["kiosk", "tower"]));
|
||||
// a line about the part that isn't about its detail answers nothing
|
||||
assert_eq!(held(&fs, "the kiosk is fine\n- LOD tower: one frame at the cut").1, ["kiosk"]);
|
||||
assert!(held(&fs, "- lod kiosk and tower: left as boxes, the cut hides them").1.is_empty());
|
||||
// the gate: open with the parts named, clear once answered, and absent from a job that plans and found nothing
|
||||
let open = gate("scene.tsx", "r1", &fs, "", false).unwrap();
|
||||
assert!(!open.0 && open.1.starts_with("seen closer than planned at r1: kiosk, tower.") && open.1.ends_with("raea scene lod scene.tsx lists every part"), "{open:?}");
|
||||
assert_eq!(gate("scene.tsx", "r1", &fs, "lod kiosk, tower: boxes", false).map(|g| g.0), Some(true));
|
||||
assert_eq!((gate("scene.tsx", "r1", &[], "", false), gate("scene.tsx", "r1", &[], "", true).map(|g| g.0)), (None, Some(true)));
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,15 @@ The brief template, the builder prompt and the judge prompt to paste are in `bev
|
||||
- `raea make plan` is the stop before anything costs money: `review/plan/floor-plan.png` (every footprint, invented
|
||||
ones dashed), a grey-box blockout seen from the entrance with its review sheets, and `comparison.png` beside the
|
||||
reference. Show it, fix positions and sizes, and only then generate.
|
||||
- Plan each object's detail with `lod`, 0 to 4, by how large it will be seen: 0 the hero (half the frame or more),
|
||||
1 featured (20%+), 2 dressing (8%+), 3 background (2%+: a grey box reads), 4 far (a silhouette). Build to the
|
||||
plan: a 3 or 4 stays a box, a card or a quarter-triangle `_lod1`, and the budget goes to the 0s and 1s. Name the
|
||||
part as its object's id (`<Mesh3d name="kiosk">`), or put `lod={3}` on the part itself; a parent
|
||||
`<Entity transform lod={4}>` plans everything inside it. Every render then says `lod-closer` when a shot shows a
|
||||
part finer than planned (a camera move added later, a box you meant to replace and forgot), and
|
||||
`raea scene lod EDIT.tsx` lists every part's plan beside the largest the frames show it, the unplanned ones too.
|
||||
Two levels finer is an error; one holds `raea make status` until you build it up and replan it, keep the camera
|
||||
off it, or answer it in NOTES.md on a line with `lod` and its name.
|
||||
- NOTES.md beside the brief ends with `## What the skill got wrong`: what the guides or tools led you into. Status
|
||||
checks it's there once the work is.
|
||||
|
||||
@@ -102,6 +111,9 @@ and its materials as jobs (`<Mat job="steel" />`), so a note can name it and the
|
||||
- Build ONE of a repeated thing, check it, then pattern it.
|
||||
- After each object, run `raea scene lint EDIT.tsx --json --part ID`. It must show nothing floating, sunk or
|
||||
clipping. Apply its `{y, dy}` fixes in code, never by eye. Each joint in the connection map must touch.
|
||||
A thing left in the air touching nothing is an error: lower it by the distance the lint gives. What's meant to
|
||||
hang there (a balloon, a sign on wires that aren't modelled) takes `floating`; a part whose own material glows
|
||||
(a lamp's panel, a neon tube) is left alone. `posed` does the same for a lean, `allowOverlap` for a clip.
|
||||
4. **Light, practicals first.** Give every practical its real kelvin, and add fills last, weak.
|
||||
- Check with `raea scene light EDIT.tsx --part HERO --json`.
|
||||
- Read the EXPOSURE line `raea render` prints for every still. It gives mean luma, the 1st and 99th percentiles,
|
||||
@@ -181,3 +193,4 @@ Three tiers, each gating once it has earned it (`raea make status` lists them):
|
||||
- Placing generated models by nudging transforms: fit them on the way in (`--h`, `--turn`), then lint.
|
||||
- Several fixes to light and materials at once: they are coupled, so do one a round.
|
||||
- Calling a stage done because the command ran: every claim needs an image or a check's output.
|
||||
- Raising a part's `lod` plan to silence `lod-closer` without building it up: the plan is what you built it for.
|
||||
@@ -21,7 +21,7 @@
|
||||
the denoiser, 4 and 2 look the same in most rooms and save time.
|
||||
- Every other choice the engine makes for the traced light is a prop too, so an A/B is two compositions, never a
|
||||
build: `denoise`, `guides`, `reflectionDepth`, `emissive` ("taa", "split", "mask"), `upscale` ("one", "two"),
|
||||
`preexposure`, `aa`, `jitter`, `jitterFrames`, `emissiveSharpness`, `dynamic`, `firstBounce`, `confidenceCap` and `cache` (the world cache's
|
||||
`preexposure`, `knee`, `late`, `firefly`, `aa`, `jitter`, `jitterFrames`, `emissiveSharpness`, `dynamic`, `firstBounce`, `confidenceCap` and `cache` (the world cache's
|
||||
`frames`, `lightSamples`, `reach`, `updates`, `cellSize`, `lodScale`). Each prop's TSDoc says what it changes. The
|
||||
defaults are the measured best, so leave them unless a test scene shows otherwise. A developer's environment
|
||||
variable of the same setting (`RAEA_SOLARI_DENOISE=0`, `RAEA_METALFX_PREEXPOSURE=4`) overrides the prop on every
|
||||
@@ -104,6 +104,65 @@ frames path-traced (FLIP, bias, flicker, blotches, lag after a doorway opens or
|
||||
looks wrong as a case. A take's own passes after the denoiser (a lens, a grade) aren't evidence about it: bench the
|
||||
view without them.
|
||||
|
||||
## Boiling: soft patches that crawl
|
||||
|
||||
Boiling is what real-time path tracing's leftover noise looks like once a denoiser has smoothed it: soft patches tens of
|
||||
pixels across that crawl over floors, walls and reflections in a shot that should hold still, each frame a little
|
||||
different. A still frame can look clean while the shot boils, so judge it held, never from one frame. It's the industry's
|
||||
word (NVIDIA's NRD and RTXDI, AMD's GI-1.0, the ReSTIR papers, Lumen's guides), and raea uses it for this alone. A toon
|
||||
look's line boil (`boil`, a drawn line wobbling on twos) is a different thing; say "light boiling" when both are about.
|
||||
|
||||
Tell it from its neighbours:
|
||||
- **flicker**: a region's brightness jumps (a light count changing, exposure hunting), rather than patches crawling;
|
||||
- **fireflies**: lone bright pixels, from a tiny, very bright emitter;
|
||||
- **grain**: pixel-sized noise, which a denoiser removes and boiling is what it leaves;
|
||||
- **sparkle**: thin edges and fine texture aliasing under the camera's jitter.
|
||||
|
||||
Measure it: `raea light steady FILE --composition ID --frame N --frames 150 -o DIR` holds frame N and reads its last
|
||||
75 frames square by square (32 px), each square's movement told by kind, since each has its own fix:
|
||||
- **settling**: the square's straight-line trend, the light still building. It's a note, not a fault: hold longer, or
|
||||
give the shot a lead-in as long as it took;
|
||||
- **boiling**: what's slow once the trend is out. Limit 1.5% over the frame, and three times that in its worst square;
|
||||
- **jitter**: what repeats on a short cycle (8 frames at full size). Edges step with the camera's sub-pixel jitter
|
||||
because something was drawn outside the denoiser's history. Limit 5% in the worst square;
|
||||
- **flicker**: fast with no cycle, such as a firefly, a sparkle in a reflection, or two faces in one plane. Limit 5%.
|
||||
`DIR/steady-kinds.png` maps them (red jitter and flicker, green boiling, blue settling). Each hold is kept in the
|
||||
project's record, so `raea check` reports what the newest hold of each frame found for a composition lit by Solari, and
|
||||
waits for one when there is none. raea check names the command.
|
||||
|
||||
What it comes from, measured on MALL RAT's sunlit mall court (blotch 3.0 at one path a pixel), largest first:
|
||||
1. **Too few paths.** One path's bounce light at a pixel is as noisy as its mean, and ReSTIR's reuse and the denoiser
|
||||
turn that into patches. `<SolariLighting paths={4} />` traces 4 paths a pixel and halves it, at about 1.7x the
|
||||
frame (8 paths: a little more, at 2.2x). This is the fix to reach for first, on any sunlit interior.
|
||||
2. **ReSTIR's reuse.** Neighbouring pixels and frames share a few good samples, so their errors move together (the
|
||||
papers' "correlation artifacts"). Its radius and confidence cap don't fix it.
|
||||
3. **The world cache's young cells.** A frozen, converged cache reads 0.1-0.3 lower than any live one; `cache.steady`
|
||||
doesn't close the gap yet.
|
||||
4. **A firefly that lingers.** A patch jumps brighter in one frame and takes a second to fall back: one very bright
|
||||
sample (a bounce landing beside a small lamp) kept by temporal reuse and spread by spatial reuse. Rooms lit by
|
||||
small bulbs have them constantly. `<SolariLighting firefly={6} />` cuts a sample over 6 times the mean of its 8x8
|
||||
pixels back to that. It costs the light those samples carried (0.3 stops in such a room at 6, half that at 12),
|
||||
so set the exposure after it.
|
||||
Not the cause there: the denoiser (it passes the patches through), the number of small lights, the direct light's
|
||||
samples, the world cache's update rate or how long its cells live.
|
||||
|
||||
Jitter has its own causes, measured on MALL RAT (t1 against its sky: worst square 73%, then 3.8%):
|
||||
1. **The sky and forward meshes drawn after the denoiser.** By default the denoiser runs before the main pass, which
|
||||
then draws the Environment's background and every forward mesh with the jittered camera, unresolved. Every
|
||||
silhouette against the sky steps a pixel a frame. `<SolariLighting late />` denoises after them.
|
||||
2. **Emitters put back frame by frame.** `emissive="split"` returns each emitter's light after the denoiser without a
|
||||
history, so a sign's letters step. Keep the default "taa".
|
||||
3. **An emitter thinner than a pixel.** A ceiling tube seen edge-on is missed by some of the jitter's positions, and
|
||||
its history is cut to black on those frames. `constants={{ emissiveClamp: { stillHold: 0.25 } }}` eases that for
|
||||
thin lights (7% to 2%). It isn't the default: a bright lamp switched off in shot then leaves its rim for a few frames.
|
||||
4. **The frame's border.** The last 32 px boil about twice as much as the middle, and a wall there can show 8 px
|
||||
blocks. `<SolariLighting overscan={0.05}>` traces the view a twentieth wider on every side and crops the middle
|
||||
back out, so the border has neighbours and history to gather from: a wall at the frame's edge went from 16% to 6%
|
||||
in its worst square. It costs 1.21 times the tracing, the picture is drawn at 0.91 of its size and brought up, and
|
||||
depth of field, motion blur and `--aov` read the wider view. More than 0.05 bought nothing. Mac only. Without it,
|
||||
frame a held shot so a flat lit wall doesn't end at the frame's edge.
|
||||
The first two, and paths, belong on any shot that has sky or signs in it.
|
||||
|
||||
## Why
|
||||
|
||||
Solari is real-time path tracing in three parts. Direct light picks among the emissive triangles and the sun with
|
||||
@@ -129,6 +188,8 @@ WESL), not a post written for an older one.
|
||||
- Walls of `Plane3d`: light leaks along their edges. Use boxes.
|
||||
- No `reset` at a cut made by moving the one camera: the new shot's first frames carry the old shot's light.
|
||||
- A tiny, very bright emitter (a 1 cm LED at 100,000): fireflies. Make it bigger and dimmer, or turn on `restir`.
|
||||
- A sunlit interior at one path a pixel: it boils (Boiling, above). Set `paths={4}` and hold a frame with
|
||||
`raea light steady` before the whole render.
|
||||
- Judging reflections from one still. Check a moving shot for smearing.
|
||||
- A glow pitched for raster (`emissive` 2) in a traced scene: it's black. Pitch it in the traced light's units.
|
||||
- Following a 0.17 or 0.18 example: the API and the defaults have changed since.
|
||||
|
||||
@@ -21,6 +21,26 @@ A viewer who had no plan to watch stops, believes the brief's `believe:` line, a
|
||||
- **Plan it.** Hook · problem · proof · ask as a storyboard, approved before anything renders. Chain its cuts on the
|
||||
thirds so the proof lands where the problem was (`raea guide match-cuts`).
|
||||
|
||||
## A client's brief is a contract
|
||||
|
||||
When a client hands you a brief (a PDF, a doc, an email of rules), make it rules before you plan a single cut, or it
|
||||
is only context, and context gets lost. Run `pdftotext -layout BRIEF.pdf media/brief.txt`, then write
|
||||
`make: cut({ cut: {...} })` on brief.ts from it:
|
||||
|
||||
- `count`, `seconds`, `formats` and every cut (id, angle, solo or mashup, hook, captions or a text hook);
|
||||
- `say`: the phrases the brief asks every cut to say or show (`every: false` when one cut is enough);
|
||||
- `never`: the claims, words and names it bans;
|
||||
- `cta`: the exact line every cut ends on;
|
||||
- `open`: each [TO CONFIRM], gap or contradiction in it, as a question for the review.
|
||||
|
||||
Every rule carries `from`, the brief's own words for it, copied exactly. `raea make status` finds each one in
|
||||
media/brief.txt, so a rule can't be made up and a line can't be paraphrased away. Then it holds every file at
|
||||
out/cuts/ID_WxH.mp4: its shape and length; its words (FILE.words.json, newer than the file: raea cloud writes it
|
||||
after every render) for each `say`, `never` and the CTA; and its frames check (FILE.frames-check.json, newer than
|
||||
the file: raea cloud's measured faces and text sizes; `frames: false` where there is none). The job isn't done, and
|
||||
the Stop hook won't let you end, until every gate is clear and every `open` item has the person's answer, written in
|
||||
with who gave it.
|
||||
|
||||
## The decisions
|
||||
|
||||
Each one has a default that comes easily. Question it before you take it.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// docs/make.feature MK21: a part's `lod` is its planned detail, a prop on its row that the stage checks read.
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { Cuboid, Entity, Model } from "../src/3d";
|
||||
import { Group } from "@raea/render/three";
|
||||
import { Mesh3d, StandardMaterial } from "@raea/render/bevy3d";
|
||||
import { renderFrame } from "../src/test";
|
||||
|
||||
const html = (el: React.ReactElement) => renderFrame(el, { frame: 0, width: 320, height: 240, fps: 30, durationInFrames: 30 });
|
||||
const props = (out: string, kind: string) => [...out.matchAll(new RegExp(`data-3d="${kind}" data-props="([^"]*)"`, "g"))].map((m) => JSON.parse(m[1]!.replaceAll(""", '"')));
|
||||
|
||||
describe("MK21: planned detail", () => {
|
||||
test("a Mesh3d's and a Model's lod ride on their rows, and a part that plans none carries none", () => {
|
||||
const out = html(<><Mesh3d name="kiosk" lod={3}><Cuboid /><StandardMaterial /></Mesh3d><Mesh3d name="desk"><Cuboid /></Mesh3d><Model src="tower.glb" lod={4} /></>);
|
||||
expect(props(out, "Mesh").map((p) => [p.name, p.lod])).toEqual([["kiosk", 3], ["desk", undefined]]);
|
||||
expect(props(out, "Model")[0].lod).toBe(4);
|
||||
});
|
||||
|
||||
test("a Group's lod is the plan of every part inside that plans none of its own", () => {
|
||||
const out = html(<Group lod={4}><Mesh3d name="far"><Cuboid /></Mesh3d><Mesh3d name="hero" lod={0}><Cuboid /></Mesh3d><Group><Model src="a.glb" /></Group></Group>);
|
||||
expect(props(out, "Mesh").map((p) => p.lod)).toEqual([4, 0]);
|
||||
expect(props(out, "Model")[0].lod).toBe(4);
|
||||
// Bevy's parent entity is the same
|
||||
const bevy = html(<Entity transform={{ translation: [0, 0, -80] }} lod={3}><Mesh3d name="skyline"><Cuboid /></Mesh3d></Entity>);
|
||||
expect(props(bevy, "Mesh")[0].lod).toBe(3);
|
||||
});
|
||||
|
||||
test("a level that isn't one of the five is refused", () => {
|
||||
expect(() => html(<Mesh3d lod={5 as 4}><Cuboid /></Mesh3d>)).toThrow("0 (the hero");
|
||||
expect(() => html(<Model src="a.glb" lod={1.5 as 1} />)).toThrow("lod is its planned detail");
|
||||
});
|
||||
});
|
||||
+101
-3
@@ -223,9 +223,13 @@ deliverables?: Array<string>,
|
||||
/**
|
||||
* the most critic rounds the job gets; at the cap it is delivered with what's still missing (8 by default)
|
||||
*/
|
||||
rounds?: number, };
|
||||
rounds?: number,
|
||||
/**
|
||||
* a cut job's contract: the brief as rules (cut.rs)
|
||||
*/
|
||||
cut?: MakeCut, };
|
||||
|
||||
export type MakeKind = "scene" | "kit" | "shot";
|
||||
export type MakeKind = "scene" | "kit" | "shot" | "cut";
|
||||
|
||||
export type MakeSource = "customer" | "reference";
|
||||
|
||||
@@ -279,7 +283,13 @@ crop?: [number, number, number, number],
|
||||
/**
|
||||
* where it stands in a scene: metres, the floor's front-left corner at the origin, rot 0 = facing the entrance
|
||||
*/
|
||||
at?: [number, number, number], rot?: number, hero?: boolean, pick?: MakePick,
|
||||
at?: [number, number, number], rot?: number, hero?: boolean,
|
||||
/**
|
||||
* how large it is planned to be seen, which is how much of it gets built: 0 the hero (half the frame or more),
|
||||
* 1 featured (under 50%), 2 dressing (under 20%), 3 background (under 8%: a grey box reads), 4 far (under 2%: a
|
||||
* silhouette). A render that shows it finer than this says so (`lod-closer`; `raea scene lod` lists every part)
|
||||
*/
|
||||
lod?: number, pick?: MakePick,
|
||||
/**
|
||||
* what was fixed by script ("glass made transmissive, label kept opaque")
|
||||
*/
|
||||
@@ -314,3 +324,91 @@ composition?: string,
|
||||
* its frame rate, for the frames `seconds` spans (30 when left out)
|
||||
*/
|
||||
fps?: number, };
|
||||
|
||||
export type MakeCut = {
|
||||
/**
|
||||
* the brief as text, relative to brief.ts (`pdftotext -layout brief.pdf media/brief.txt`): every `from` is found in it
|
||||
*/
|
||||
brief: string,
|
||||
/**
|
||||
* how many cuts the brief asks for; fewer planned is held open until an answered `open` item about "count" says why
|
||||
*/
|
||||
count?: MakeQuoted<number>,
|
||||
/**
|
||||
* a cut's length when its own `seconds` says none: [least, most]
|
||||
*/
|
||||
seconds?: [number, number],
|
||||
/**
|
||||
* the formats every cut is delivered in when its own `formats` says none: "9:16", "16:9", "1:1", "4:5"
|
||||
*/
|
||||
formats?: Array<string>, cuts?: Array<MakeCutPlan>,
|
||||
/**
|
||||
* what is said or shown: in every cut unless `every: false` (then in one or more)
|
||||
*/
|
||||
say?: Array<MakePhrase>,
|
||||
/**
|
||||
* what no cut says or shows: a banned claim, a word, a name
|
||||
*/
|
||||
never?: Array<MakePhrase>,
|
||||
/**
|
||||
* the line every cut ends on, heard or on screen in its last `within` seconds
|
||||
*/
|
||||
cta?: MakeCta,
|
||||
/**
|
||||
* the brief's open items ([TO CONFIRM]): each holds the job open until it has an answer
|
||||
*/
|
||||
open?: Array<MakeOpen>,
|
||||
/**
|
||||
* every face whole and every text big enough, by the frames check of each file (true when left out)
|
||||
*/
|
||||
frames?: boolean, };
|
||||
|
||||
export type MakeQuoted<T> = { value: T,
|
||||
/**
|
||||
* the brief's own words, as they are in its text
|
||||
*/
|
||||
from: string, };
|
||||
|
||||
export type MakeCutPlan = {
|
||||
/**
|
||||
* [a-z0-9_], unique: each format lands as out/cuts/<id>_<W>x<H>.mp4 ("a1_s1_9x16.mp4")
|
||||
*/
|
||||
id: string, angle?: string,
|
||||
/**
|
||||
* solo or mashup
|
||||
*/
|
||||
kind?: string,
|
||||
/**
|
||||
* one of the brief's hook types ("Direct Problem", "Reaction")
|
||||
*/
|
||||
hook?: string,
|
||||
/**
|
||||
* captions, hook (a text hook) or none
|
||||
*/
|
||||
text?: string, formats?: Array<string>, seconds?: [number, number], };
|
||||
|
||||
export type MakePhrase = {
|
||||
/**
|
||||
* as it's said or shown; compared in lower case, by letters and digits ("24/7" and "24-7" are the same)
|
||||
*/
|
||||
text: string, from: string,
|
||||
/**
|
||||
* `say` only: false when one cut saying it is enough
|
||||
*/
|
||||
every?: boolean, };
|
||||
|
||||
export type MakeCta = { text: string, from: string,
|
||||
/**
|
||||
* how near the end it must land, in seconds (8 when left out)
|
||||
*/
|
||||
within?: number, };
|
||||
|
||||
export type MakeOpen = { question: string, from: string,
|
||||
/**
|
||||
* what it decides: "count", "cta", "offer", a cut's id...
|
||||
*/
|
||||
about?: string,
|
||||
/**
|
||||
* the person's answer, as they gave it, and who gave it: until then the job can't be done
|
||||
*/
|
||||
answer?: string, by?: string, };
|
||||
@@ -35,3 +35,5 @@ export const scene = (m: Omit<Make, "kind">): Make => ({ kind: "scene", ...m });
|
||||
export const kit = (m: Omit<Make, "kind">): Make => ({ kind: "kit", ...m });
|
||||
/** Shots of a built scene, each named for the file it lands as and described in a crew's words. */
|
||||
export const shot = (m: Omit<Make, "kind">): Make => ({ kind: "shot", ...m });
|
||||
/** ads cut from footage to a client's brief: `cut: {...}` is the brief as rules, each quoting it (docs/make.feature MK25) */
|
||||
export const cut = (m: Omit<Make, "kind">): Make => ({ kind: "cut", ...m });
|
||||
@@ -1,5 +1,6 @@
|
||||
// Where a part is drawn (docs/realism.feature LT21): its levels by distance or by size on screen, cross-faded, its
|
||||
// draw distance and its shadow, as raea-sys-lod's Detail component on the part (systems/lod).
|
||||
import { createContext, useContext } from "react";
|
||||
import { BevyComponent } from "./bevy";
|
||||
|
||||
/** Where a part is drawn. Distances in metres from the camera; sizes on screen are the part's size across in pixels,
|
||||
@@ -45,3 +46,22 @@ export function detailNode(who: string, d: Detail | undefined) {
|
||||
const value = { near: d.near ?? 0, far: d.far ?? 0, min_px: d.minPx ?? 0, max_px: d.maxPx ?? 0, fade: d.fade ?? 0.1, shadow: d.shadow ?? true, size: d.size ?? 0, edge: d.edge ?? false, bounds: d.box ?? [] };
|
||||
return <BevyComponent key="raea-detail" type="raea_sys_lod::Detail" value={value} />;
|
||||
}
|
||||
|
||||
/** How large a part is planned to be seen, which is how much of it gets built (docs/make.feature MK21): 0 the hero
|
||||
* (half the frame or more), 1 featured (under 50%), 2 dressing (under 20%), 3 background (under 8%: a grey box
|
||||
* reads), 4 far (under 2%: a silhouette). It draws nothing differently (`detail` switches levels): it is the plan a
|
||||
* render holds the part to, saying `lod-closer` when a frame shows it finer than this, and `raea scene lod` lists
|
||||
* every part's plan beside what the frames show. A part without one takes its name's level from the job's plan
|
||||
* (`lod` on its object in brief.ts's make). */
|
||||
export type PlannedLod = 0 | 1 | 2 | 3 | 4;
|
||||
|
||||
/** the planned detail of every part inside a <Group lod> that plans none of its own */
|
||||
export const PlannedLodOf = createContext<PlannedLod | undefined>(undefined);
|
||||
|
||||
/** a part's `lod` checked, else the level of the Group it is in */
|
||||
export function usePlannedLod(who: string, own: PlannedLod | undefined): PlannedLod | undefined {
|
||||
const around = useContext(PlannedLodOf);
|
||||
if (own === undefined) return around;
|
||||
if (!(Number.isInteger(own) && own >= 0 && own <= 4)) throw new RangeError(`${who}: lod is its planned detail, 0 (the hero, half the frame or more) to 4 (far, under 2% of it), got ${JSON.stringify(own)}`);
|
||||
return own;
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import { modelScreens, type ModelScreens } from "../screen";
|
||||
import { pageLayers } from "../layers";
|
||||
import { Place3d, useCamera3d, usePlace3d } from "../events3d";
|
||||
import { MeshStandardMaterialProps, PerspectiveCameraProps, Vec3, checkMaterial, checkPass, checkVec, colours, node3d, samplerSpec, type SamplerSpec } from "./all";
|
||||
import { detailNode, type Detail } from "./detail";
|
||||
import { PlannedLodOf, detailNode, usePlannedLod, type Detail, type PlannedLod } from "./detail";
|
||||
|
||||
/** What a light or camera holds: Bevy's own reflected components on it (<BevyComponent>, or a generated wrapper such
|
||||
* as bevy_light's ShadowFilteringMethod or bevy_pbr's ScreenSpaceReflections), applied through Bevy's TypeRegistry. */
|
||||
@@ -66,6 +66,8 @@ export interface EntityProps {
|
||||
transform?: { translation?: Vec3; rotation?: [number, number, number, number]; scale?: Vec3 };
|
||||
/** with `transform`: the composition pass of every part inside that doesn't name its own (Mesh's `pass`) */
|
||||
pass?: string;
|
||||
/** with `transform`: the planned detail of every part inside that plans none of its own, 0 (the hero) to 4 (far) */
|
||||
lod?: PlannedLod;
|
||||
/** its Bevy components (<BevyComponent>, or the generated wrappers in raea/bevy-own); with `transform`, also
|
||||
* the parts it carries */
|
||||
children?: ReactNode;
|
||||
@@ -79,18 +81,19 @@ export interface EntityProps {
|
||||
* hand-written element. */
|
||||
export function Entity({ children, ...rest }: EntityProps) {
|
||||
if (rest.transform !== undefined) {
|
||||
const { transform: t, pass, ...own } = rest;
|
||||
const { transform: t, pass, lod, ...own } = rest;
|
||||
if (own.position !== undefined || own.rotation !== undefined || own.scale !== undefined) throw new TypeError("Entity: transform, or position, rotation and scale, not both");
|
||||
if (own.name !== undefined) throw new TypeError("Entity: a parent entity (with a transform) takes no name yet; name a bare Entity inside it");
|
||||
// a parent entity draws as the old Group: its place, and its children placed in it
|
||||
return (
|
||||
<Group position={t.translation ?? [0, 0, 0]} rotation={t.rotation ? eulerOf(t.rotation) : [0, 0, 0]} scale={t.scale ?? 1} {...(pass !== undefined ? { pass } : {})}>
|
||||
<Group position={t.translation ?? [0, 0, 0]} rotation={t.rotation ? eulerOf(t.rotation) : [0, 0, 0]} scale={t.scale ?? 1} {...(pass !== undefined ? { pass } : {})} {...(lod !== undefined ? { lod } : {})}>
|
||||
{children}
|
||||
</Group>
|
||||
);
|
||||
}
|
||||
if (rest.position !== undefined) checkVec("Entity", "position", rest.position);
|
||||
if (rest.rotation !== undefined) checkVec("Entity", "rotation", rest.rotation);
|
||||
if (rest.lod !== undefined) throw new TypeError("Entity: lod is a parent entity's (with a transform), for the parts inside it; a part takes its own");
|
||||
if (rest.name !== undefined && (typeof rest.name !== "string" || !rest.name)) throw new TypeError(`Entity: name is a non-empty string, got ${JSON.stringify(rest.name)}`);
|
||||
const id = useId();
|
||||
const m = usePlace3d(rest.position ?? [0, 0, 0], rest.rotation ?? [0, 0, 0], rest.scale ?? 1);
|
||||
@@ -106,6 +109,9 @@ export interface GroupProps {
|
||||
scale?: number | Vec3;
|
||||
/** the composition pass of every part inside that doesn't name its own (Mesh's `pass`) */
|
||||
pass?: string;
|
||||
/** the planned detail of every part inside that plans none of its own, 0 (the hero) to 4 (far): a skyline's
|
||||
* buildings, a street's far end (PlannedLod) */
|
||||
lod?: PlannedLod;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
@@ -139,7 +145,8 @@ export function Group(props: GroupProps) {
|
||||
const q = props.quaternion;
|
||||
if (q !== undefined && !(Array.isArray(q) && q.length === 4 && q.every(Number.isFinite))) throw new TypeError(`Group: quaternion is [x, y, z, w], got ${JSON.stringify(q)}`);
|
||||
const m = usePlace3d(position, rotation, scale, q);
|
||||
return node3d("Group", { position, rotation, scale, ...(q !== undefined ? { quaternion: q } : {}), ...(props.pass !== undefined ? { pass: props.pass } : {}) }, <Place3d.Provider value={m}>{props.children}</Place3d.Provider>);
|
||||
const lod = usePlannedLod("Group", props.lod);
|
||||
return node3d("Group", { position, rotation, scale, ...(q !== undefined ? { quaternion: q } : {}), ...(props.pass !== undefined ? { pass: props.pass } : {}) }, <Place3d.Provider value={m}><PlannedLodOf.Provider value={lod}>{props.children}</PlannedLodOf.Provider></Place3d.Provider>);
|
||||
}
|
||||
|
||||
export interface ModelProps {
|
||||
@@ -180,6 +187,9 @@ export interface ModelProps {
|
||||
/** set at an angle on purpose (a bowl knocked over, a mug on its side): `raea scene lint` doesn't call it
|
||||
* tilted */
|
||||
posed?: boolean;
|
||||
/** it hangs in the air on purpose, touching nothing (a balloon, a sign on wires that aren't modelled):
|
||||
* `raea scene lint` doesn't call it left in the air */
|
||||
floating?: boolean;
|
||||
/** a clip to play: its name in the file, or its index */
|
||||
animation?: string | number;
|
||||
/** live pictures on its materials, by the glTF material's name: `{ monitor_screen: <Screen resolution={[384, 272]}>
|
||||
@@ -225,6 +235,9 @@ export interface ModelProps {
|
||||
shadow?: boolean;
|
||||
/** where it's drawn: its distances or sizes on screen, cross-faded, and its shadow (Detail; raea-sys-lod) */
|
||||
detail?: Detail;
|
||||
/** its planned detail, 0 (the hero) to 4 (far): how large it is meant to be seen. A render that shows it finer
|
||||
* says so (`lod-closer`); a stand-in or a far backdrop is planned at 3 or 4 (PlannedLod) */
|
||||
lod?: PlannedLod;
|
||||
/** false: no shadow falls on its meshes, its own included (true by default): a furry coat of many cards that would
|
||||
* otherwise speckle itself in the shadow maps */
|
||||
receiveShadow?: boolean;
|
||||
@@ -322,7 +335,7 @@ export function Model(props: ModelProps) {
|
||||
if (props.sampler !== undefined) samplerSpec("Model", props.sampler);
|
||||
if (props.pixelSize !== undefined && !(props.pixelSize >= 1)) throw new RangeError(`Model: pixelSize must be at least 1, got ${props.pixelSize}`);
|
||||
if (props.bones !== undefined && (typeof props.bones !== "object" || Object.values(props.bones).some((v) => typeof v !== "string"))) throw new TypeError(`Model: bones maps each joint's name to a model's name, got ${JSON.stringify(props.bones)}`);
|
||||
const p: Record<string, unknown> = { ...props, time };
|
||||
const p: Record<string, unknown> = { ...props, time, lod: usePlannedLod("Model", props.lod) };
|
||||
if (props.animations !== undefined) {
|
||||
const a = props.animations;
|
||||
if (props.animation !== undefined) throw new TypeError("Model: give animation (one clip) or animations (a blend), not both");
|
||||
|
||||
@@ -5,6 +5,7 @@ import { useAnimation3d, type Keys, type Move, type TrackSpec } from "@raea/math
|
||||
import { Place3d, usePlace3d, usePointer3d, type LocalBounds, type PointerHandlers3d } from "../events3d";
|
||||
import { Canvas3DProps, Vec3, checkArgs, checkPass, checkVec, node3d, sameProps, serialisable } from "./all";
|
||||
import { InCanvas3D } from "./model";
|
||||
import { usePlannedLod, type PlannedLod } from "./detail";
|
||||
import type { MeshAttribute } from "./attribute";
|
||||
import { firstKey, useSequenceFrames } from "./clock";
|
||||
import { Text3D, text3dShape, type Text3DProps } from "./text3d";
|
||||
@@ -368,6 +369,12 @@ export interface MeshProps extends PointerHandlers3d {
|
||||
allowOverlap?: boolean;
|
||||
/** set at an angle on purpose (a bowl knocked over, a mug on its side): `raea scene lint` doesn't call it tilted */
|
||||
posed?: boolean;
|
||||
/** it hangs in the air on purpose, touching nothing (a balloon, a sign on wires that aren't modelled):
|
||||
* `raea scene lint` doesn't call it left in the air */
|
||||
floating?: boolean;
|
||||
/** its planned detail, 0 (the hero) to 4 (far): how large it is meant to be seen. A render that shows it finer
|
||||
* says so (`lod-closer`); a grey box or a far backdrop is planned at 3 or 4 (PlannedLod) */
|
||||
lod?: PlannedLod;
|
||||
/** a Manifold solid (manifold.box(...).minus(...)) or its expression; wins over the geometry child */
|
||||
shape?: string | Solid;
|
||||
/** a Bevy plugin moves it (a rigid body): position, rotation and scale set where it starts, then the plugin's */
|
||||
@@ -474,11 +481,12 @@ export function Mesh(props: MeshProps) {
|
||||
const manifold = shape instanceof Solid ? shape.expr : shape ?? shapeFromChildren(props.children);
|
||||
// a Text3D's read={false} rides on its mesh, which the stage checks read (SG10)
|
||||
const read = props.read ?? text3dRead(props.children);
|
||||
const lod = usePlannedLod("Mesh", props.lod);
|
||||
const extra: Record<string, string> = {};
|
||||
if (manifold !== undefined) extra["data-shape"] = manifold as string;
|
||||
if (anim.attr) extra["data-raea-anim"] = anim.attr;
|
||||
const id = useId();
|
||||
const m = usePlace3d(position, rotation, scale, props.quaternion);
|
||||
usePointer3d(props.name ?? id, m, () => (shape === undefined ? boundsFromChildren(props.children) : undefined), props as Record<string, unknown>);
|
||||
return node3d("Mesh", { ...props, read, animate: undefined, shape: undefined, position, rotation, scale, attributes: props.attributes && JSON.stringify(props.attributes) }, <Place3d.Provider value={m}>{props.children}</Place3d.Provider>, Object.keys(extra).length ? extra : undefined);
|
||||
return node3d("Mesh", { ...props, read, lod, animate: undefined, shape: undefined, position, rotation, scale, attributes: props.attributes && JSON.stringify(props.attributes) }, <Place3d.Provider value={m}>{props.children}</Place3d.Provider>, Object.keys(extra).length ? extra : undefined);
|
||||
}
|
||||
@@ -21,6 +21,14 @@ export interface SolariLightingProps {
|
||||
/** the chance a pixel traces its first bounce this frame, its light divided by it (Russian roulette): 0.5 halves the
|
||||
* bounce's tracing, most of a dense forest's (1, every pixel every frame) */
|
||||
firstBounce?: number;
|
||||
/** initial paths a pixel a frame (1 to 16, 1 by default): N cut the noise of one path N times, at N times its rays.
|
||||
* A sunlit room seen through bounces (MALL RAT's court) needs 4 or more to hold still */
|
||||
paths?: number;
|
||||
/** the firefly filter: a sample over this many times the mean of its 8x8 pixels is cut back to that after temporal
|
||||
* reuse (off by default; 2 and up). One very bright sample otherwise lingers and spreads: a patch jumps brighter and
|
||||
* takes a second to fall back. Lower holds stiller and loses more light (a room lit by small bulbs: 6 holds still
|
||||
* and reads 0.3 stops darker, 12 half of both; 32 loses nothing and gains little) */
|
||||
firefly?: number;
|
||||
/** Solari's world cache, the bounce light it keeps in cells across the scene */
|
||||
cache?: {
|
||||
/** frames a cell's light is gathered over: steadier and slower to follow a change (Bevy's 32) */
|
||||
@@ -32,9 +40,24 @@ export interface SolariLightingProps {
|
||||
/** about how many cells are updated a frame (40000) */
|
||||
updates?: number;
|
||||
/** a nearest cell's size, metres (0.15) */
|
||||
/** keep each cell's whole history (up to frames), not cut short when its own noise reads as the light changing */
|
||||
steady?: boolean;
|
||||
/** cache updates a frame (1): more converge faster */
|
||||
iterations?: number;
|
||||
/** frames a cell lives unqueried (10): a camera that leaves a place and comes back finds its light still built
|
||||
* instead of starting cold; longer lives keep more cells, which the cache's 2^20 slots must hold */
|
||||
life?: number;
|
||||
cellSize?: number;
|
||||
/** how fast cells grow with distance from the camera (15) */
|
||||
lodScale?: number;
|
||||
/** bake the cache (docs/solari-efficiency.md): render the take's own camera path with it and every cell it meets
|
||||
* stays, keeps its whole history (set `frames` long, 4096 or more) and updates `iterations` times a frame (1).
|
||||
* `save` names the file to write this frame: give it a few frames before the bake's last */
|
||||
bake?: { iterations?: number; save?: string };
|
||||
/** a baked cache's file (`bake.save`), read and held while the shot renders: no updates, nothing ages out, a cut
|
||||
* doesn't empty it. Another name later in the shot reads that one (a take whose lights change at a cut). Its sets
|
||||
* and lights must be the bake's: what moved since is lit as the bake saw it */
|
||||
load?: string;
|
||||
};
|
||||
/** draw the view at this fraction of its size a side (a third to 1) and let MetalFX's temporal scaler bring it up to
|
||||
* the full size, so a game traces fewer pixels: 0.67 traces 45% of them (RT9). On the Mac; elsewhere it draws at the
|
||||
@@ -59,6 +82,13 @@ export interface SolariLightingProps {
|
||||
* bright sample (a lamp found by one path in many) and lets more fireflies through: 1 kept 0.74 of the desk's
|
||||
* light, 16 0.86, 64 0.91. Default 16; RAEA_METALFX_PREEXPOSURE overrides it */
|
||||
preexposure?: number;
|
||||
/** where the denoiser's soft knee starts, in its white (1 by default; 0 off). Light above it is denoised as its log
|
||||
* and restored after, so a silhouette against bright sky or a lit doorway doesn't step with the camera's jitter.
|
||||
* RAEA_METALFX_KNEE overrides it */
|
||||
knee?: number;
|
||||
/** denoise after the forward meshes and the sky, so their edges are gathered over frames too instead of stepping
|
||||
* with the camera's jitter. RAEA_SOLARI_DENOISE_LATE overrides it */
|
||||
late?: boolean;
|
||||
/** jitter a full-size view too, so the denoiser anti-aliases its edges as it gathers frames. Default true;
|
||||
* RAEA_SOLARI_AA=0 overrides it */
|
||||
aa?: boolean;
|
||||
@@ -76,6 +106,12 @@ export interface SolariLightingProps {
|
||||
* frame, so it casts traced shadows and bounces light. Decided as each mesh is first traced, so set it from the first
|
||||
* frame. (A hidden part, or one a frame leaves out, leaves the traced scene with or without it.) */
|
||||
dynamic?: boolean;
|
||||
/** overscan (off by default): the view is traced this much wider on every side (0.05 is a twentieth of its width and
|
||||
* height) and the middle cropped back out, so the frame's border has light to gather from as the camera moves. For
|
||||
* a moving shot whose edges crawl (`raea light steady` passing everywhere but the border). It costs (1 + 2 x
|
||||
* overscan)² the tracing, the picture is drawn at 1 / (1 + 2 x overscan) of its size at most and brought up, and
|
||||
* depth of field, motion blur and `--aov` read the wider view. Mac only (it rides MetalFX's denoiser) */
|
||||
overscan?: number;
|
||||
/** constants in Solari's and the denoiser's shaders, compiled in when the scene loads (a value changed later in the
|
||||
* composition isn't drawn); each left out keeps the shader's own, given in brackets. <ShaderConstants> reaches the
|
||||
* rest */
|
||||
@@ -121,8 +157,10 @@ export interface SolariLightingProps {
|
||||
emissiveHistory?: number;
|
||||
/** how an emissive surface's history is held to the light about it now: a still pixel within the darkest times
|
||||
* stillLow (0.95) and the brightest times stillHigh (1.05); a moving one under the brightest times movingGain (4)
|
||||
* plus movingFloor (0.02) */
|
||||
emissiveClamp?: { stillLow?: number; stillHigh?: number; movingGain?: number; movingFloor?: number };
|
||||
* plus movingFloor (0.02). stillHold (1) is how far a still pixel whose history is a thin line or a
|
||||
* point goes toward its bounds a frame: 0.25 stops an emitter thinner than a pixel flickering (a ceiling tube seen
|
||||
* edge-on), and a bright lamp switched off then leaves its rim for a few frames */
|
||||
emissiveClamp?: { stillLow?: number; stillHigh?: number; stillHold?: number; movingGain?: number; movingFloor?: number };
|
||||
};
|
||||
}
|
||||
|
||||
@@ -159,6 +197,7 @@ export function solariConstants(c: SolariLightingProps["constants"]) {
|
||||
[taa, "HISTORY_CAP", at(c.emissiveHistory, "emissiveHistory")],
|
||||
[taa, "STILL_LOW", at(e.stillLow, "emissiveClamp.stillLow")],
|
||||
[taa, "STILL_HIGH", at(e.stillHigh, "emissiveClamp.stillHigh")],
|
||||
[taa, "STILL_HOLD", at(e.stillHold, "emissiveClamp.stillHold")],
|
||||
[taa, "MOVING_GAIN", at(e.movingGain, "emissiveClamp.movingGain")],
|
||||
[taa, "MOVING_FLOOR", at(e.movingFloor, "emissiveClamp.movingFloor")],
|
||||
]);
|
||||
@@ -187,12 +226,18 @@ export function solariSettings(p: SolariLightingProps): Record<string, unknown>
|
||||
if (p.emissive !== undefined) v.emissive = p.emissive;
|
||||
if (p.upscale !== undefined) v.upscale = p.upscale;
|
||||
if (p.preexposure !== undefined) v.preexposure = p.preexposure;
|
||||
if (p.late !== undefined) v.late = p.late;
|
||||
if (p.knee !== undefined) {
|
||||
if (!(Number.isFinite(p.knee) && p.knee >= 0)) throw new RangeError(`SolariLighting: knee is a number from 0, got ${p.knee}`);
|
||||
v.knee = p.knee;
|
||||
}
|
||||
if (p.aa !== undefined) v.aa = p.aa;
|
||||
// the engine's names for the passes (upscale.rs jitter_gain): "" the denoiser, "0" none
|
||||
if (p.jitter !== undefined) v.jitter = p.jitter === "denoiser" ? "" : p.jitter === "none" ? "0" : p.jitter;
|
||||
if (p.emissiveSharpness !== undefined) v.emissive_sharpness = p.emissiveSharpness;
|
||||
if (p.jitterFrames !== undefined) v.jitter_frames = p.jitterFrames;
|
||||
if (p.dynamic !== undefined) v.dynamic = p.dynamic;
|
||||
if (p.overscan !== undefined) v.overscan = p.overscan;
|
||||
return Object.keys(v).length ? v : undefined;
|
||||
}
|
||||
|
||||
@@ -218,6 +263,10 @@ export function SolariLighting(p: SolariLightingProps = {}) {
|
||||
field("secondarySamples", "secondary_di_samples", p.secondarySamples, true);
|
||||
if (p.firstBounce !== undefined && !(p.firstBounce > 0 && p.firstBounce <= 1)) throw new RangeError(`SolariLighting: firstBounce is a chance above 0, up to 1, got ${p.firstBounce}`);
|
||||
field("firstBounce", "first_bounce_probability", p.firstBounce);
|
||||
if (p.paths !== undefined && !(Number.isInteger(p.paths) && p.paths >= 1 && p.paths <= 16)) throw new RangeError(`SolariLighting: paths is a whole number from 1 to 16, got ${p.paths}`);
|
||||
field("paths", "paths_per_pixel", p.paths, true);
|
||||
if (p.firefly !== undefined && !(p.firefly === 0 || p.firefly >= 2)) throw new RangeError(`SolariLighting: firefly is 0 (off) or a multiplier from 2 up, got ${p.firefly}`);
|
||||
field("firefly", "firefly_cap", p.firefly);
|
||||
const c = p.cache ?? {};
|
||||
field("cache.frames", "world_cache_max_temporal_samples", c.frames);
|
||||
field("cache.lightSamples", "world_cache_direct_light_sample_count", c.lightSamples, true);
|
||||
@@ -225,6 +274,21 @@ export function SolariLighting(p: SolariLightingProps = {}) {
|
||||
field("cache.updates", "world_cache_cell_updates_soft_target", c.updates, true);
|
||||
field("cache.cellSize", "world_cache_position_base_cell_size", c.cellSize);
|
||||
field("cache.lodScale", "world_cache_position_lod_scale", c.lodScale);
|
||||
// steady: the cache's light kept over its whole history (up to cache.frames), never cut short when a cell's own noise
|
||||
// reads as change; iterations: that many cache updates a frame. Light that holds still converges instead of crawling
|
||||
// (11-25, MALL RAT's splotches); light that moves (a power cut) lags by the history, so set frames to what it can bear
|
||||
if (c.steady) value.world_cache_steady = true;
|
||||
field("cache.iterations", "world_cache_update_iterations", c.iterations, true);
|
||||
if (c.life !== undefined && !(Number.isInteger(c.life) && c.life >= 1 && c.life <= 65535)) throw new RangeError(`SolariLighting: cache.life is a whole number of frames from 1 to 65535, got ${c.life}`);
|
||||
field("cache.life", "world_cache_cell_lifetime", c.life, true);
|
||||
if (c.bake) {
|
||||
value.world_cache_keep = true;
|
||||
value.world_cache_steady = true;
|
||||
field("cache.bake.iterations", "world_cache_update_iterations", c.bake.iterations ?? 1, true);
|
||||
}
|
||||
if (c.bake && c.load) throw new RangeError("SolariLighting: cache.bake and cache.load together: a bake gathers the cache, a load holds one already baked");
|
||||
// both always written: a value left out may keep the last frame's, and a save that stuck would write every frame
|
||||
if (c.bake || c.load) { value.world_cache_save = c.bake?.save ?? ""; value.world_cache_load = c.load ?? ""; }
|
||||
const settings = solariSettings(p);
|
||||
const constants = solariConstants(p.constants);
|
||||
const lighting = <BevyComponent type="bevy_solari::realtime::SolariLighting" value={value} />;
|
||||
|
||||
+1
-1
Submodule skills updated: 2acd36246f...ae1c222713.
@@ -66,6 +66,30 @@ struct PassView(u32);
|
||||
#[derive(Component, Clone, Copy, Default)]
|
||||
pub struct PrepassRead;
|
||||
|
||||
/// Overscan: a camera's main pass draws `margin` of its view more on every side (0.05: a twentieth of the width left and
|
||||
/// right, of the height top and bottom), and what draws it crops the middle back out, so the light a traced view
|
||||
/// gathers from its neighbours and from the frames before has something to gather at the frame's border
|
||||
/// (docs/raytracing.feature RT40). Put on a camera by what does the cropping (raea-render-raytrace's denoiser), never
|
||||
/// by a composition.
|
||||
#[derive(Component, Clone, Copy, PartialEq, Debug, Default)]
|
||||
pub struct Overscan {
|
||||
pub margin: f32,
|
||||
/// the margin the camera's view was last widened by (raea-sys-viewbox's tag_row_view sets it): what is cropped back
|
||||
pub drawn: f32,
|
||||
}
|
||||
|
||||
impl Overscan {
|
||||
/// The margin as it applies: none without the component, at most a quarter.
|
||||
pub fn of(o: Option<&Overscan>) -> f32 {
|
||||
o.map_or(0.0, |o| if o.margin.is_finite() { o.margin.clamp(0.0, 0.25) } else { 0.0 })
|
||||
}
|
||||
|
||||
/// The margin the camera's view is drawn wider by: none until tag_row_view has widened it.
|
||||
pub fn drawn(o: Option<&Overscan>) -> f32 {
|
||||
o.map_or(0.0, |o| o.drawn)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn install(app: &mut App) {
|
||||
let Some(pass) = wanted() else { return };
|
||||
bevy::asset::embedded_asset!(app, "passes.wesl");
|
||||
|
||||
@@ -72,6 +72,8 @@ const ENCLOSED: f32 = 0.97;
|
||||
const PIERCE: f32 = 0.15;
|
||||
const PIERCE_MIN: f32 = 0.004;
|
||||
const PIERCE_POINTS: usize = 4;
|
||||
/// The other part's cell at most this share of the smaller part's diagonal, or its solid can't say where the part is.
|
||||
const COARSE: f32 = 0.5;
|
||||
/// A part smaller than this across (metres) is a particle: a spark, an ember, a mote.
|
||||
const PARTICLE: f32 = 0.08;
|
||||
/// An overlap within the bottom of the smaller part (this share of its height) is it seated in what's below.
|
||||
@@ -206,6 +208,11 @@ fn volume(a: &Solid, wa: &Mat4, b: &Solid, wb: &Mat4) -> Option<Hit> {
|
||||
if size < PARTICLE {
|
||||
return None;
|
||||
}
|
||||
// the other's cells are coarser than the part can be placed in: a node holding every wall of one material in a
|
||||
// mall is voxelized over a metre a cell, and each payphone near one read "47% inside" it (11-25, MALL RAT)
|
||||
if o.cell * ko > COARSE * size {
|
||||
return None;
|
||||
}
|
||||
// no point of the overlap is deeper than half the boxes' common part is thin: two parts side by side stop here
|
||||
let (ilo, ihi) = (alo.max(blo), ahi.min(bhi));
|
||||
if (ihi - ilo).min_element() < DEPTH_SHARE * size {
|
||||
@@ -384,4 +391,15 @@ mod tests {
|
||||
// beside it
|
||||
assert!(!blocked(Vec3::new(3.0, 0.0, 0.0), Vec3::new(3.0, 0.0, 6.0), 0.05, &seen));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_part_smaller_than_the_others_cells_isnt_tested_in_it() {
|
||||
// a stand sunk to its middle in the top of a block: found in a block whose cells place it, and one as large
|
||||
// as the cells in a 60 m block, but not the 2 m stand in the 60 m block (its cells are over a metre)
|
||||
let block = |x: f32| voxelize(&boxed(Vec3::new(0.0, 6.0, 0.0), Vec3::new(x, 12.0, 12.0))).unwrap();
|
||||
let stand = |k: f32| voxelize(&boxed(Vec3::new(0.0, 12.0, 0.0), Vec3::new(0.4 * k, 2.0 * k, 0.4 * k))).unwrap();
|
||||
let w = Mat4::IDENTITY;
|
||||
assert!(test(&stand(1.0), &w, &block(4.0), &w).is_some() && test(&stand(4.0), &w, &block(60.0), &w).is_some());
|
||||
assert!(test(&stand(1.0), &w, &block(60.0), &w).is_none());
|
||||
}
|
||||
}
|
||||
+27
-59
@@ -14,7 +14,7 @@ use std::collections::HashMap;
|
||||
use bevy::math::{Mat4, Vec3};
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use raea_core_scene::{Item, Part, base_ident, label, parts_of, ray_tri};
|
||||
use raea_core_scene::{Item, Part, base_ident, face, feet, glows, label, parts_of, ray_tri, unparked, wall};
|
||||
|
||||
use super::solid_of;
|
||||
|
||||
@@ -33,11 +33,6 @@ const SUNK_SHARE: f32 = 0.1;
|
||||
/// A door this far in front of the carcass behind it, the carcass covering it, is hung on it (doors stand off their
|
||||
/// cupboard's frame by a reveal; the kitchen pack's by up to 2 cm).
|
||||
const CARCASS: f32 = 0.025;
|
||||
/// A wall, or a piece of one (the strip of wall over a window, the window in it): no thicker than WALL_THICK, at least
|
||||
/// WALL_WIDE across and WALL_TALL high (metres; the kitchen's strip over its back window is 9.6 cm).
|
||||
const WALL_THICK: f32 = 0.35;
|
||||
const WALL_WIDE: f32 = 0.8;
|
||||
const WALL_TALL: f32 = 0.05;
|
||||
/// A part this big across its footprint (m²) with nothing under it is the ground.
|
||||
const GROUND: f32 = 1.0;
|
||||
/// The xz grid the scene's triangles are binned in, metres.
|
||||
@@ -118,49 +113,6 @@ enum Rest {
|
||||
Ground,
|
||||
}
|
||||
|
||||
/// The part's lowest points (its feet): its vertices within a millimetre (or 2% of its height) of its lowest, and
|
||||
/// points across the faces lying there (a slab's corners overhang what holds it up; its middle doesn't), at most FEET.
|
||||
fn feet(p: &Part) -> Vec<Vec3> {
|
||||
let tol = (0.02 * (p.hi.y - p.lo.y)).clamp(0.0005, 0.003);
|
||||
let low = |q: &Vec3| q.y <= p.lo.y + tol;
|
||||
let mut v: Vec<Vec3> = p.tris.iter().flatten().filter(|q| low(q)).copied().collect();
|
||||
let bases: Vec<&[Vec3; 3]> = p.tris.iter().filter(|t| t.iter().all(low)).collect();
|
||||
let area: f32 = bases.iter().map(|t| 0.5 * (t[1] - t[0]).cross(t[2] - t[0]).length()).sum();
|
||||
if area > 0.0 {
|
||||
// about FEET points over the base, spread by area
|
||||
let step = (area / FEET as f32).sqrt();
|
||||
for t in bases {
|
||||
let long = (t[1] - t[0]).length().max((t[2] - t[1]).length()).max((t[0] - t[2]).length());
|
||||
let m = ((long / step).ceil() as usize).clamp(1, 32);
|
||||
for i in 0..=m {
|
||||
for j in 0..=(m - i) {
|
||||
let (a, b) = (i as f32 / m as f32, j as f32 / m as f32);
|
||||
v.push(t[0] + (t[1] - t[0]) * a + (t[2] - t[0]) * b);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
v.sort_by(|a, b| (a.x, a.z, a.y).partial_cmp(&(b.x, b.z, b.y)).unwrap_or(std::cmp::Ordering::Equal));
|
||||
v.dedup_by(|a, b| (*a - *b).length() < 1e-4);
|
||||
if v.len() > 4 * FEET {
|
||||
let k = v.len() as f32 / (4 * FEET) as f32;
|
||||
v = (0..4 * FEET).map(|i| v[(i as f32 * k) as usize]).collect();
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// Whether a part is a wall or a piece of one: thin, wide and high.
|
||||
fn wall(p: &Part) -> bool {
|
||||
let e = p.hi - p.lo;
|
||||
e.y >= WALL_TALL && e.x.min(e.z) <= WALL_THICK && e.x.max(e.z) >= WALL_WIDE
|
||||
}
|
||||
|
||||
/// A wall's face area, for which of two is set into the other.
|
||||
fn face(p: &Part) -> f32 {
|
||||
let e = p.hi - p.lo;
|
||||
e.y * e.x.max(e.z)
|
||||
}
|
||||
|
||||
/// The wall each part is set into (a sill in the wall under it; a window, itself a wall's piece, in a bigger one), if
|
||||
/// any: its box passes more than 3 mm into the wall's thickness. What's set into a wall and the wall are mounted on each
|
||||
/// other, and neither is sunk into the other.
|
||||
@@ -185,7 +137,7 @@ fn rest_of(parts: &[Part], grid: &Grid, insets: &[Option<usize>], i: usize) -> R
|
||||
let height = p.hi.y - p.lo.y;
|
||||
// how far above a foot a surface may be and still be the one it stands in (sunk): half its height, at most NEAR
|
||||
let up = (0.5 * height).min(NEAR);
|
||||
let feet = feet(p);
|
||||
let feet = feet(p, FEET);
|
||||
// each foot: the highest surface of another part from `up` above it down
|
||||
let mut best: Option<(f32, usize, u32, Vec3)> = None;
|
||||
let mut nearest_below: Option<(usize, u32, f32)> = None;
|
||||
@@ -320,7 +272,8 @@ fn moving(now: &[Item], other: &[Item]) -> Vec<bool> {
|
||||
/// `now` is the frame's parts, `next` the next frame's (or the one before, at the end) to see what moves.
|
||||
pub fn lint(now: &[Item], next: &[Item]) -> (Vec<Value>, usize) {
|
||||
let moving = moving(now, next);
|
||||
let (parts, items, skipped) = parts_of(now, &moving);
|
||||
let (parts, items, mut skipped) = parts_of(now, &moving);
|
||||
let (parts, items) = unparked(parts, items, &mut skipped);
|
||||
let grid = Grid::new(&parts);
|
||||
let insets = insets(&parts);
|
||||
let mut out = Vec::new();
|
||||
@@ -349,11 +302,19 @@ pub fn lint(now: &[Item], next: &[Item]) -> (Vec<Value>, usize) {
|
||||
let under = below.map(|(j, g)| format!("; {} above {}", mm(g), parts[j].label)).unwrap_or_default();
|
||||
("ok", "mounted", format!("{} is mounted on {} ({}){under}", p.label, named(&parts, *on, *node), mm(*gap)))
|
||||
}
|
||||
Rest::Air { below } => match below {
|
||||
Some((j, node, g)) if *g < 0.0 => ("warning", "air", format!("{} touches nothing it could rest on, and {} passes {} into it", p.label, named(&parts, *j, *node), mm(-g))),
|
||||
Some((j, node, g)) => ("warning", "air", format!("{} is in the air, {} above {} and touching nothing", p.label, mm(*g), named(&parts, *j, *node))),
|
||||
None => ("warning", "air", format!("{} has nothing under it and touches nothing", p.label)),
|
||||
},
|
||||
// a thing with weight that touches nothing has been left in the air (a boombox 12 cm over its counter went
|
||||
// through as a warning); a light may hang there, and what's meant to (a balloon, a sign on wires that
|
||||
// aren't modelled) says so with `floating`
|
||||
Rest::Air { below } => {
|
||||
let meant = glows(&items[i]) || items[i].props.get("floating").and_then(Value::as_bool) == Some(true);
|
||||
let level = if meant { "note" } else { "error" };
|
||||
let fix = if meant { "" } else { " (give it floating if it's meant to hang there)" };
|
||||
match below {
|
||||
Some((j, node, g)) if *g < 0.0 => (level, "air", format!("{} touches nothing it could rest on, and {} passes {} into it{fix}", p.label, named(&parts, *j, *node), mm(-g))),
|
||||
Some((j, node, g)) => (level, "air", format!("{} is in the air, {} above {} and touching nothing: lower it {:+.4} m{fix}", p.label, mm(*g), named(&parts, *j, *node), -g)),
|
||||
None => (level, "air", format!("{} has nothing under it and touches nothing{fix}", p.label)),
|
||||
}
|
||||
}
|
||||
Rest::Ground => ("ok", "ground", format!("{} is the ground", p.label)),
|
||||
};
|
||||
// a part left out of the checks, or on its way somewhere, is still a surface; its own faults aren't said
|
||||
@@ -434,18 +395,25 @@ pub fn lint(now: &[Item], next: &[Item]) -> (Vec<Value>, usize) {
|
||||
if parts[j].excused || parts[j].moving || !near(&parts[i], &parts[j]) {
|
||||
continue;
|
||||
}
|
||||
if let Some((n, area, at)) = raea_core_zfight::overlaps(&parts[i].tris, Some(&parts[j].tris)) {
|
||||
let over = raea_core_zfight::sorted(&parts[i].tris, Some(&parts[j].tris));
|
||||
if let Some((n, area, at)) = over.fight {
|
||||
let level = if area >= 1e-4 { "error" } else { "warning" };
|
||||
if level == "error" {
|
||||
errors += 1;
|
||||
}
|
||||
out.push(json!({"part": parts[i].label, "into": parts[j].label, "check": "zfight", "level": level, "faces": n, "area": (area * 1e6).round() / 1e6, "at": [at.x, at.y, at.z],
|
||||
"says": format!("{} and {} have faces in one plane over each other ({n} pair{}, up to {:.1} cm² at [{:.3}, {:.3}, {:.3}]): they flicker as the camera moves; lift one by a millimetre or cut the overlap", parts[i].label, parts[j].label, if n == 1 { "" } else { "s" }, area * 1e4, at.x, at.y, at.z)}));
|
||||
"says": format!("{} and {} have faces in one plane over each other ({n} pair{}, {:.1} cm² shared, most at [{:.3}, {:.3}, {:.3}]): they flicker as the camera moves; lift one by a millimetre or cut the overlap", parts[i].label, parts[j].label, if n == 1 { "" } else { "s" }, area * 1e4, at.x, at.y, at.z)}));
|
||||
}
|
||||
// the same triangles in both (a slab built into two neighbouring chunks) draw alike whichever wins, unless
|
||||
// the two give them different materials: said, never an error
|
||||
if let Some((n, area, at)) = over.twins {
|
||||
out.push(json!({"part": parts[i].label, "into": parts[j].label, "check": "doubled", "level": "warning", "faces": n, "area": (area * 1e6).round() / 1e6, "at": [at.x, at.y, at.z],
|
||||
"says": format!("{} and {} both hold the same {n} face{} ({:.1} cm², most at [{:.3}, {:.3}, {:.3}]): nothing to see where they look alike; take them out of one", parts[i].label, parts[j].label, if n == 1 { "" } else { "s" }, area * 1e4, at.x, at.y, at.z)}));
|
||||
}
|
||||
}
|
||||
if let Some((n, area, at)) = raea_core_zfight::overlaps(&parts[i].tris, None) {
|
||||
out.push(json!({"part": parts[i].label, "check": "zfight", "level": "warning", "faces": n, "area": (area * 1e6).round() / 1e6, "at": [at.x, at.y, at.z],
|
||||
"says": format!("{} has faces doubled in one plane inside it ({n} pair{}, up to {:.1} cm²): they flicker where they show; delete the doubles (raea gen check -o)", parts[i].label, if n == 1 { "" } else { "s" }, area * 1e4)}));
|
||||
"says": format!("{} has faces doubled in one plane inside it ({n} pair{}, {:.1} cm² shared): they flicker where they show; delete the doubles (raea gen check -o)", parts[i].label, if n == 1 { "" } else { "s" }, area * 1e4)}));
|
||||
}
|
||||
}
|
||||
(out, errors)
|
||||
|
||||
@@ -140,3 +140,33 @@ fn a_part_moved_sideways_is_settled_where_it_lands() {
|
||||
// moved along the top it stays on it
|
||||
assert!(matches!(rest_after(&parts, &ins, 2, Vec3::new(-0.3, 0.0, 0.0)), Rest::On { under: 1, .. }));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_thing_left_in_the_air_is_an_error_unless_it_glows_or_is_floating() {
|
||||
use raea_core_scene::Node3;
|
||||
use serde_json::json;
|
||||
use std::sync::Arc;
|
||||
let mesh = |name: &str, shape: &str, y: f32, props: Value, material: Value| {
|
||||
let Value::Object(mut p) = props else { unreachable!() };
|
||||
p.insert("name".into(), json!(name));
|
||||
let Value::Object(m) = material else { unreachable!() };
|
||||
let material = Node3 { kind: "StandardMaterial".into(), props: Arc::new(m), shape: None, at: None, kids: Vec::new().into() };
|
||||
Item { kind: "mesh", props: Arc::new(p), shape: Some(shape.into()), at: None, material: Some(material), world: Mat4::from_translation(Vec3::new(0.0, y, 0.0)) }
|
||||
};
|
||||
let floor = || mesh("floor", "box(10, 0.1, 10)", -0.05, json!({}), json!({}));
|
||||
let air = |props: Value, material: Value| {
|
||||
let items = [floor(), mesh("crate", "box(0.4, 0.4, 0.4)", 1.2, props, material)];
|
||||
let (found, errors) = lint(&items, &items);
|
||||
let f = found.iter().find(|f| f["part"] == "crate").expect("the crate is said").clone();
|
||||
(f["check"].as_str().unwrap().to_string(), f["level"].as_str().unwrap().to_string(), f["says"].as_str().unwrap().to_string(), errors)
|
||||
};
|
||||
let (check, level, says, errors) = air(json!({}), json!({}));
|
||||
assert_eq!((check.as_str(), level.as_str(), errors), ("air", "error", 1), "{says}");
|
||||
assert!(says.contains("lower it -1.0000 m") && says.contains("floating"), "{says}");
|
||||
// meant to hang there
|
||||
let (_, level, _, errors) = air(json!({"floating": true}), json!({}));
|
||||
assert_eq!((level.as_str(), errors), ("note", 0));
|
||||
// a lamp's panel
|
||||
let (_, level, _, errors) = air(json!({}), json!({"emissive": {"red": 2200.0, "green": 120.0, "blue": 80.0, "alpha": 1.0}}));
|
||||
assert_eq!((level.as_str(), errors), ("note", 0));
|
||||
}
|
||||
@@ -7,6 +7,7 @@ publish = false
|
||||
description = "Full-screen passes written in TypeScript (docs/shaders.feature SH6): <FramePass>, a generic pass on the frame whose pipeline is specialized per shader, with the camera's depth and normal prepasses"
|
||||
|
||||
[dependencies]
|
||||
raea-sys-compose = { path = "../compose" }
|
||||
raea-sys-frame = { path = "../frame" }
|
||||
raea-sys-material = { path = "../material" }
|
||||
raea-sys-sampler = { path = "../sampler" }
|
||||
|
||||
@@ -132,7 +132,9 @@ pub fn module(source: &str, uniforms: &[(String, &'static str)], textures: &[Str
|
||||
if prepass {
|
||||
m += "@group(0) @binding(13) var raea_depth: texture_depth_2d;\n\
|
||||
@group(0) @binding(14) var raea_normal: texture_2d<f32>;\n\
|
||||
fn raea_texel(uv: vec2<f32>, size: vec2<u32>) -> vec2<i32> { return clamp(vec2<i32>(raea_view_uv(clamp(uv, vec2<f32>(0.0), vec2<f32>(0.99999))) * vec2<f32>(size)), vec2<i32>(0), vec2<i32>(size) - vec2<i32>(1)); }\n\
|
||||
// the main pass may have drawn the view smaller, in its Viewport's corner (a render scale), and wider (overscan):\n\
|
||||
// near.yz is the part of the Viewport the frame's own view takes, near.w how much wider a side it drew\n\
|
||||
fn raea_texel(uv: vec2<f32>, size: vec2<u32>) -> vec2<i32> { return clamp(vec2<i32>((raea_pass.view.zw + (clamp(uv, vec2<f32>(0.0), vec2<f32>(0.99999)) + raea_pass.near.w) * raea_pass.near.yz * raea_pass.view.xy) * vec2<f32>(size)), vec2<i32>(0), vec2<i32>(size) - vec2<i32>(1)); }\n\
|
||||
// reverse-Z: the depth is near / distance, 0 where nothing was drawn\n\
|
||||
fn depth(uv: vec2<f32>) -> f32 {\n\
|
||||
\x20 let d = textureLoad(raea_depth, raea_texel(uv, textureDimensions(raea_depth)), 0);\n\
|
||||
@@ -184,7 +186,8 @@ pub fn build(world: &mut World, v: &Value, mut image: impl FnMut(&mut World, &Va
|
||||
pub fn put(world: &mut World, cam: Entity, passes: Vec<Pass>) {
|
||||
let mut e = world.entity_mut(cam);
|
||||
if passes.iter().any(|p| p.prepass) {
|
||||
e.insert((bevy::core_pipeline::prepass::DepthPrepass, bevy::core_pipeline::prepass::NormalPrepass, Msaa::Off));
|
||||
// PrepassRead: msaa_for_3d turned a video's MSAA back on under the pass, refused at its third frame (as #159)
|
||||
e.insert((bevy::core_pipeline::prepass::DepthPrepass, bevy::core_pipeline::prepass::NormalPrepass, Msaa::Off, raea_sys_compose::passes::PrepassRead));
|
||||
}
|
||||
e.insert(FramePasses(passes));
|
||||
}
|
||||
@@ -301,7 +304,7 @@ fn queue(views: Query<(&ViewTarget, &FramePasses)>, pipelines: Option<ResMut<Pip
|
||||
}
|
||||
}
|
||||
|
||||
type Views<'w, 's> = ViewQuery<'w, 's, (&'static ViewTarget, &'static FramePasses, &'static ExtractedView, Option<&'static ViewPrepassTextures>, Option<&'static ExtractedCamera>)>;
|
||||
type Views<'w, 's> = ViewQuery<'w, 's, (&'static ViewTarget, &'static FramePasses, &'static ExtractedView, Option<&'static ViewPrepassTextures>, Option<&'static ExtractedCamera>, Option<&'static bevy::camera::MainPassResolutionOverride>, Option<&'static raea_sys_compose::passes::Overscan>)>;
|
||||
|
||||
/// The camera's Viewport in its target (x, y, w, h in px), and its size and corner over the target's (the uniforms'
|
||||
/// `view`); none without a Viewport, the pass then spanning the target.
|
||||
@@ -320,15 +323,24 @@ fn rect(at: UVec2, size: UVec2, target: UVec2) -> Option<([f32; 4], Vec4)> {
|
||||
Some(([at.x, at.y, size.x, size.y], Vec4::new(size.x / t.x, size.y / t.y, at.x / t.x, at.y / t.y)))
|
||||
}
|
||||
|
||||
/// Where the frame's own view lies in the depth and the normals: the share of the camera's Viewport it takes a side
|
||||
/// (x, y), and how much wider a side the main pass drew (z). The main pass draws a `part` of the Viewport, from its
|
||||
/// corner, when the view has a render scale, and `k` wider a side with overscan; the frame is the middle of that.
|
||||
fn deep(part: Option<UVec2>, port: Option<UVec2>, k: f32) -> Vec3 {
|
||||
let share = part.zip(port).filter(|(_, v)| v.x > 0 && v.y > 0).map_or(Vec2::ONE, |(p, v)| p.as_vec2() / v.as_vec2());
|
||||
(share / (1.0 + 2.0 * k)).extend(k)
|
||||
}
|
||||
|
||||
/// The passes placed before tone mapping (BEFORE) or after it.
|
||||
fn draw<const BEFORE: bool>(view: Views<'_, '_>, p: Option<Res<Pipelines>>, cache: Res<PipelineCache>, images: Res<RenderAssets<GpuImage>>, fallback: Res<FallbackImage>, mut ctx: RenderContext) {
|
||||
let Some(p) = p else { return };
|
||||
let at = if BEFORE { At::BeforeTonemap } else { At::AfterTonemap };
|
||||
let (target, passes, extracted, prepass, camera) = view.into_inner();
|
||||
let (target, passes, extracted, prepass, camera, part, over) = view.into_inner();
|
||||
// a perspective camera's near plane, from its infinite reverse-Z projection
|
||||
let near = extracted.clip_from_view.w_axis.z;
|
||||
let port = viewport(camera);
|
||||
let view_uv = port.map_or(Vec4::new(1.0, 1.0, 0.0, 0.0), |p| p.1);
|
||||
let deep = deep(part.map(|p| p.0), camera.and_then(|c| c.physical_viewport_size), raea_sys_compose::passes::Overscan::drawn(over));
|
||||
for pass in passes.0.iter().filter(|x| x.at == at) {
|
||||
if let Some(w) = &pass.written {
|
||||
let Some((layout, id)) = p.written.get(&(pass.shader, target.main_texture_format())) else { continue };
|
||||
@@ -350,7 +362,7 @@ fn draw<const BEFORE: bool>(view: Views<'_, '_>, p: Option<Res<Pipelines>>, cach
|
||||
continue;
|
||||
}
|
||||
let mut bytes: Vec<u8> = Vec::with_capacity(UNIFORM_BYTES as usize);
|
||||
for v in [Vec4::new(near, 0.0, 0.0, 0.0), view_uv].into_iter().chain(pass.slots.iter().copied()) {
|
||||
for v in [Vec4::new(near, deep.x, deep.y, deep.z), view_uv].into_iter().chain(pass.slots.iter().copied()) {
|
||||
for f in v.to_array() {
|
||||
bytes.extend_from_slice(&f.to_ne_bytes());
|
||||
}
|
||||
@@ -446,7 +458,16 @@ mod tests {
|
||||
assert!(d.contains("fn depth(") && d.contains("fn normal(") && !d.contains("raea_frame_pass("));
|
||||
// the frame, the depth and the normals are read at the Viewport's uv mapped onto their textures
|
||||
assert!(m.contains("textureSampleLevel(raea_frame, raea_frame_sampler, raea_view_uv(clamp(uv, h, 1.0 - h)), 0.0)"));
|
||||
assert!(d.contains("vec2<i32>(raea_view_uv(clamp(uv, vec2<f32>(0.0), vec2<f32>(0.99999))) * vec2<f32>(size))"));
|
||||
assert!(d.contains("(raea_pass.view.zw + (clamp(uv, vec2<f32>(0.0), vec2<f32>(0.99999)) + raea_pass.near.w) * raea_pass.near.yz * raea_pass.view.xy) * vec2<f32>(size)"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_depth_is_read_where_the_main_pass_drew_the_frame() {
|
||||
assert_eq!(deep(None, Some(UVec2::new(640, 360)), 0.0), Vec3::new(1.0, 1.0, 0.0));
|
||||
assert_eq!(deep(Some(UVec2::new(320, 180)), Some(UVec2::new(640, 360)), 0.0), Vec3::new(0.5, 0.5, 0.0));
|
||||
// 5% overscan drawn at 1 / 1.1 of the size, filling the Viewport: the frame is its middle, uv 0 at 0.05 / 1.1
|
||||
let d = deep(Some(UVec2::new(640, 360)), Some(UVec2::new(640, 360)), 0.05);
|
||||
assert!((d.x - 1.0 / 1.1).abs() < 1e-6 && ((0.0 + d.z) * d.x - 0.05 / 1.1).abs() < 1e-6 && ((1.0 + d.z) * d.x - 1.05 / 1.1).abs() < 1e-6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -451,7 +451,7 @@ fn start(cx: &mut FirewheelContext, block: u32) -> Result<(cpal::Stream, u32), S
|
||||
// the block size when the device's range takes it, else its own
|
||||
let fits = dev.supported_output_configs().map(|mut c| c.any(|r| r.channels() == channels && matches!(r.buffer_size(), cpal::SupportedBufferSize::Range { min, max } if *min <= block && block <= *max))).unwrap_or(false);
|
||||
let config = cpal::StreamConfig { channels, sample_rate: cpal::SampleRate(rate), buffer_size: if fits { cpal::BufferSize::Fixed(block) } else { cpal::BufferSize::Default } };
|
||||
let stream = dev.build_output_stream(&config, move |o: &mut [f32], i: &cpal::OutputCallbackInfo| callback(o, i), |e| eprintln!("raea mixer: {e}"), None).map_err(|e| format!("audio stream: {e}"))?;
|
||||
let stream = dev.build_output_stream(&config, move |o: &mut [f32], i: &cpal::OutputCallbackInfo| callback(o, i), raea_io_trace::once::said_once::<cpal::StreamError>("raea mixer"), None).map_err(|e| format!("audio stream: {e}"))?;
|
||||
stream.play().map_err(|e| format!("audio stream: {e}"))?;
|
||||
Ok((stream, rate))
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ pub(crate) fn behind(its: &[Item], parts: &[Part], me: usize, world: &Mat4, x: (
|
||||
}
|
||||
|
||||
/// Whether a part lets the words through: its material's opacity (else its own) under SEE_THROUGH.
|
||||
fn see_through(it: &Item) -> bool {
|
||||
pub fn see_through(it: &Item) -> bool {
|
||||
let material = match &it.material {
|
||||
Some(m) => opacity(&m.props),
|
||||
None => None,
|
||||
@@ -83,6 +83,12 @@ fn opacity(props: &serde_json::Map<String, Value>) -> Option<f64> {
|
||||
|
||||
/// Where the segment o to q first enters the box [lo, hi], as a share of its length, if it does before q.
|
||||
fn enters(o: Vec3, q: Vec3, lo: Vec3, hi: Vec3) -> Option<f32> {
|
||||
crossing(o, q, lo, hi).map(|c| c.0)
|
||||
}
|
||||
|
||||
/// Where the segment o to q enters the box [lo, hi] and where it leaves it, as shares of its length (1 when q is
|
||||
/// inside), if it meets it before q.
|
||||
pub fn crossing(o: Vec3, q: Vec3, lo: Vec3, hi: Vec3) -> Option<(f32, f32)> {
|
||||
let d = q - o;
|
||||
let (mut t0, mut t1) = (0.0f32, 1.0f32);
|
||||
for a in 0..3 {
|
||||
@@ -102,7 +108,7 @@ fn enters(o: Vec3, q: Vec3, lo: Vec3, hi: Vec3) -> Option<f32> {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some(t0)
|
||||
Some((t0, t1))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -21,7 +21,8 @@ mod view;
|
||||
pub use framing::{model_box, on_screen, own_box};
|
||||
pub use manifest::{Mounts, pages, seen};
|
||||
pub use page::{Page, Words};
|
||||
pub use view::View;
|
||||
pub use cover::{crossing, see_through};
|
||||
pub use view::{View, corners};
|
||||
|
||||
/// Who says these findings, in a render.
|
||||
pub const BY: &str = "raea render";
|
||||
|
||||
@@ -7,5 +7,6 @@ publish = false
|
||||
description = "The view a camera on the Engine's target draws: the frame above its tag row, or the box a page lays out for it (Engine::set_view_box, #130)"
|
||||
|
||||
[dependencies]
|
||||
raea-sys-compose = { path = "../compose" }
|
||||
raea-sys-frame = { path = "../frame" }
|
||||
bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render"] }
|
||||
@@ -12,34 +12,59 @@ pub struct TagRowTarget(pub Handle<Image>);
|
||||
#[derive(Resource, Default)]
|
||||
pub struct ViewBox(pub Option<[u32; 4]>);
|
||||
|
||||
pub use raea_sys_compose::passes::Overscan;
|
||||
|
||||
/// A sub view drawn `k` wider on every side, about its target's middle.
|
||||
pub fn widened(v: bevy::camera::SubCameraView, k: f32) -> bevy::camera::SubCameraView {
|
||||
if k <= 0.0 {
|
||||
return v;
|
||||
}
|
||||
// only the ratios count: in hundredths of a pixel, so the wider size isn't rounded to whole ones
|
||||
let (full, size) = (v.full_size * 100, v.size.as_vec2() * 100.0);
|
||||
bevy::camera::SubCameraView { full_size: full, offset: v.offset * 100.0 - size * k, size: (size * (1.0 + 2.0 * k)).round().as_uvec2() }
|
||||
}
|
||||
|
||||
/// A camera drawing to the Engine's target draws a w x h Viewport of it, the frame's own, above the tag row: a view of
|
||||
/// w x (h + 1) drew the 3D 0.14% larger and half a pixel low against a camera on a w x h target, a plain App's
|
||||
/// (docs/blitz-bevy.feature B3 H10), and against the looks' cells. With a view box, its own view is the box's (the
|
||||
/// target a sub view of it, offset by the box's place). The Viewport this gave a camera (`ours`) is taken off when a
|
||||
/// box comes: a camera given it on the frames before the page had laid the box out (a render's first draws) kept it,
|
||||
/// and drew the whole page's view, cropped to the box (#130).
|
||||
pub fn tag_row_view(t: Res<TagRowTarget>, images: Res<Assets<Image>>, view_box: Option<Res<ViewBox>>, mut ours: Local<bevy::platform::collections::HashSet<Entity>>, mut q: Query<(Entity, &mut Camera, &RenderTarget), Without<raea_sys_frame::TagCamera>>) {
|
||||
pub fn tag_row_view(t: Res<TagRowTarget>, images: Res<Assets<Image>>, view_box: Option<Res<ViewBox>>, mut ours: Local<bevy::platform::collections::HashSet<Entity>>, mut q: Query<(Entity, &mut Camera, &RenderTarget, Option<&mut Overscan>), Without<raea_sys_frame::TagCamera>>) {
|
||||
let Some(img) = images.get(&t.0) else { return };
|
||||
let s = img.size();
|
||||
let view = match view_box.and_then(|v| v.0) {
|
||||
Some([x, y, w, h]) => bevy::camera::SubCameraView { full_size: UVec2::new(w, h), offset: Vec2::new(-(x as f32), -(y as f32)), size: s },
|
||||
None => bevy::camera::SubCameraView { full_size: UVec2::new(s.x, s.y - 1), offset: Vec2::ZERO, size: s },
|
||||
};
|
||||
for (e, mut c, rt) in &mut q {
|
||||
for (e, mut c, rt, mut over) in &mut q {
|
||||
let k = Overscan::of(over.as_deref());
|
||||
// drawn wider only below, where this gives the camera its view
|
||||
let mut drawn = 0.0;
|
||||
// a camera with its own Viewport (a ViewportNode's) sees its viewport's shape, as Bevy sizes it, never the tag row
|
||||
if c.viewport.is_some() && !ours.contains(&e) { if c.sub_camera_view.is_some() { c.sub_camera_view = None; } continue; }
|
||||
if !matches!(rt, RenderTarget::Image(i) if i.handle == t.0) { continue; }
|
||||
let own = c.viewport.is_some() && !ours.contains(&e);
|
||||
if own || !matches!(rt, RenderTarget::Image(i) if i.handle == t.0) {
|
||||
if own && c.sub_camera_view.is_some() { c.sub_camera_view = None; }
|
||||
if let Some(o) = over.as_mut() && o.drawn != 0.0 { o.drawn = 0.0; }
|
||||
continue;
|
||||
}
|
||||
if view.offset == Vec2::ZERO {
|
||||
// a w x h Viewport: Bevy's orthographic sub view takes its area from the w x (h + 1) target, 0.14% small
|
||||
// (2d/sprite_slice), and a draw in clip space (a PhaseItem, custom_phase_item) maps to its h + 1 rows
|
||||
if c.viewport.as_ref().is_none_or(|v| v.physical_position != UVec2::ZERO || v.physical_size != view.full_size) { c.viewport = Some(bevy::camera::Viewport { physical_size: view.full_size, ..default() }); }
|
||||
if c.sub_camera_view.is_some() { c.sub_camera_view = None; }
|
||||
// overscan: the Viewport's own view, wider
|
||||
let wide = (k > 0.0).then(|| widened(bevy::camera::SubCameraView { full_size: view.full_size, offset: Vec2::ZERO, size: view.full_size }, k));
|
||||
if c.sub_camera_view != wide { c.sub_camera_view = wide; }
|
||||
ours.insert(e);
|
||||
drawn = k;
|
||||
} else {
|
||||
if c.viewport.is_some() { c.viewport = None; }
|
||||
let view = widened(view, k);
|
||||
if c.sub_camera_view != Some(view) { c.sub_camera_view = Some(view); }
|
||||
ours.remove(&e);
|
||||
drawn = k;
|
||||
}
|
||||
if let Some(o) = over.as_mut() && o.drawn != drawn { o.drawn = drawn; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +104,28 @@ mod tests {
|
||||
assert!(c.sub_camera_view.is_none() && c.viewport.as_ref().is_some_and(|v| v.physical_size == UVec2::new(600, 600)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn overscan_widens_the_view_about_its_middle() {
|
||||
let (mut app, cam, _) = app();
|
||||
app.world_mut().entity_mut(cam).insert(Overscan { margin: 0.05, drawn: 0.0 });
|
||||
app.update();
|
||||
let c = app.world().get::<Camera>(cam).unwrap();
|
||||
assert_eq!(c.viewport.as_ref().map(|v| v.physical_size), Some(UVec2::new(600, 600)), "the Viewport stays");
|
||||
let v = c.sub_camera_view.expect("a wider sub view");
|
||||
assert_eq!(app.world().get::<Overscan>(cam).unwrap().drawn, 0.05);
|
||||
assert_eq!((v.full_size, v.offset, v.size), (UVec2::new(60000, 60000), Vec2::new(-3000.0, -3000.0), UVec2::new(66000, 66000)));
|
||||
// with a view box: wider about the target's middle, the box's view in the middle of it
|
||||
app.world_mut().resource_mut::<ViewBox>().0 = Some([100, 100, 400, 400]);
|
||||
app.update();
|
||||
let v = app.world().get::<Camera>(cam).unwrap().sub_camera_view.unwrap();
|
||||
assert_eq!((v.full_size, v.offset, v.size), (UVec2::new(40000, 40000), Vec2::new(-13000.0, -13005.0), UVec2::new(66000, 66110)));
|
||||
// taken off: the frame's Viewport and no sub view
|
||||
app.world_mut().resource_mut::<ViewBox>().0 = None;
|
||||
app.world_mut().entity_mut(cam).remove::<Overscan>();
|
||||
app.update();
|
||||
assert!(app.world().get::<Camera>(cam).unwrap().sub_camera_view.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_cameras_own_viewport_is_left_as_it_is() {
|
||||
let (mut app, _, h) = app();
|
||||
|
||||
@@ -188,6 +188,8 @@ raea-runtime-view = "runtime"
|
||||
raea-runtime-world = "runtime"
|
||||
raea-runtime-encode = "runtime"
|
||||
raea-runtime-endchecks = "runtime"
|
||||
raea-runtime-lod-plan = "runtime" # MK21: a part planned far or as a grey box that a shot shows closer than its plan
|
||||
raea-runtime-cut-plan = "runtime" # MK25: a cut job held to its client's brief, from the files on disk
|
||||
raea-runtime-plugins = "runtime"
|
||||
raea-runtime-live = "runtime"
|
||||
raea-runtime-look = "runtime"
|
||||
|
||||
Executable
+93
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env bash
|
||||
# Package the Linux archive produced and checked by tools/release.sh; no Rust rebuild.
|
||||
# bash tools/release-appimage.sh VERSION ARCHIVE [OUT_DIR]
|
||||
# Build on Ubuntu 24.04 x86_64, as release.yml does. Nothing is published here.
|
||||
set -euo pipefail
|
||||
die() { echo "appimage: $*" >&2; exit 1; }
|
||||
version=${1:?usage: release-appimage.sh VERSION ARCHIVE [OUT_DIR]}
|
||||
archive=${2:?usage: release-appimage.sh VERSION ARCHIVE [OUT_DIR]}
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
out=${3:-$root/dist}
|
||||
[[ $version =~ ^[0-9][0-9A-Za-z.+-]*$ ]] || die "invalid version: $version"
|
||||
[[ $(uname -s) = Linux && $(uname -m) = x86_64 ]] || die "Linux x86_64 is required"
|
||||
for tool in curl sha256sum tar readelf dpkg-query; do
|
||||
command -v "$tool" >/dev/null || die "missing tool: $tool"
|
||||
done
|
||||
archive=$(realpath "$archive")
|
||||
[[ -f $archive && -f $archive.sha256 ]] || die "need the Linux archive and its .sha256"
|
||||
[[ $(basename "$archive") = raea-$version-linux-x86_64.tar.gz ]] || die "archive name does not match version/platform"
|
||||
(cd "$(dirname "$archive")" && sha256sum -c "$(basename "$archive").sha256")
|
||||
mkdir -p "$out"
|
||||
out=$(cd "$out" && pwd)
|
||||
name=raea-$version-linux-x86_64.AppImage
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
appdir=$work/raea.AppDir
|
||||
mkdir -p "$appdir/usr"
|
||||
tar -xzf "$archive" -C "$work"
|
||||
for binary in raea raea-perceive raea-rune-host raea-page-host libraea_bundle.so; do
|
||||
[[ -f $work/raea/bin/$binary ]] || die "archive is missing bin/$binary"
|
||||
readelf -h "$work/raea/bin/$binary" | grep -q 'Machine:.*Advanced Micro Devices X86-64' \
|
||||
|| die "$binary is not an x86_64 ELF file"
|
||||
done
|
||||
[[ $(cat "$work/raea/share/raea/VERSION") = "$version" ]] || die "archive's VERSION does not match $version"
|
||||
mv "$work/raea/bin" "$work/raea/share" "$appdir/usr/"
|
||||
mkdir -p "$appdir/usr/share/doc/raea"
|
||||
cp "$root/LICENSE" "$root/NOTICE" "$appdir/usr/share/doc/raea/"
|
||||
cp -R "$root/LICENSES" "$appdir/usr/share/doc/raea/"
|
||||
cp "$work/raea/README" "$appdir/usr/share/doc/raea/README-linux"
|
||||
|
||||
# The bundler is opened with dlopen beside raea, so keep it in usr/bin and ask
|
||||
# linuxdeploy to process its dependencies there, rather than move it to usr/lib.
|
||||
# A pinned linuxdeploy also carries its AppImage output plugin and appimagetool.
|
||||
deploy_version=1-alpha-20251107-1
|
||||
deploy_sha=c20cd71e3a4e3b80c3483cef793cda3f4e990aca14014d23c544ca3ce1270b4d
|
||||
# An existing download can be supplied for offline packaging; it is still verified.
|
||||
deploy=${RAEA_LINUXDEPLOY:-$work/linuxdeploy-x86_64.AppImage}
|
||||
if [[ -z ${RAEA_LINUXDEPLOY:-} ]]; then
|
||||
curl -fLsS --retry 3 "https://github.com/linuxdeploy/linuxdeploy/releases/download/$deploy_version/linuxdeploy-x86_64.AppImage" -o "$deploy"
|
||||
fi
|
||||
deploy=$(realpath "$deploy")
|
||||
echo "$deploy_sha $deploy" | sha256sum -c -
|
||||
chmod +x "$deploy"
|
||||
# appimagetool otherwise downloads a mutable runtime from the continuous release.
|
||||
runtime_version=20251108
|
||||
runtime_sha=2fca8b443c92510f1483a883f60061ad09b46b978b2631c807cd873a47ec260d
|
||||
runtime=${RAEA_APPIMAGE_RUNTIME:-$work/runtime-x86_64}
|
||||
if [[ -z ${RAEA_APPIMAGE_RUNTIME:-} ]]; then
|
||||
curl -fLsS --retry 3 "https://github.com/AppImage/type2-runtime/releases/download/$runtime_version/runtime-x86_64" -o "$runtime"
|
||||
fi
|
||||
runtime=$(realpath "$runtime")
|
||||
echo "$runtime_sha $runtime" | sha256sum -c -
|
||||
# Extract the packaging tool once: building needs no FUSE or privileged mount.
|
||||
(cd "$work" && "$deploy" --appimage-extract >/dev/null)
|
||||
deploy=$work/squashfs-root/AppRun
|
||||
export ARCH=x86_64 LINUXDEPLOY_OUTPUT_VERSION="$version" NO_STRIP=1 APPIMAGE_EXTRACT_AND_RUN=1
|
||||
export LDAI_RUNTIME_FILE="$runtime"
|
||||
"$deploy" --appdir "$appdir" --deploy-deps-only "$appdir/usr/bin" \
|
||||
--desktop-file "$root/tools/release/appimage/raea.desktop" \
|
||||
--icon-file "$root/docs/logo/cat-black.svg" --icon-filename raea \
|
||||
--custom-apprun "$root/tools/release/appimage/AppRun"
|
||||
|
||||
# Keep Debian/Ubuntu's copyright and source notices beside the bundled libraries.
|
||||
mkdir -p "$appdir/usr/share/doc/raea/bundled-libraries"
|
||||
while IFS= read -r lib; do
|
||||
packages=$(dpkg-query -S "*/$(basename "$lib")" | sed 's/: \/.*//' | sort -u)
|
||||
[[ -n $packages ]] || die "no distribution copyright record for $lib"
|
||||
while IFS= read -r package; do
|
||||
copyright=/usr/share/doc/${package%%:*}/copyright
|
||||
[[ -f $copyright ]] || die "no copyright notice for $package"
|
||||
cp -L "$copyright" "$appdir/usr/share/doc/raea/bundled-libraries/$package.copyright"
|
||||
done <<< "$packages"
|
||||
done < <(find "$appdir/usr/lib" -type f -name '*.so*')
|
||||
|
||||
LDAI_OUTPUT="$work/$name" "$deploy" --appdir "$appdir" --output appimage
|
||||
[[ -s $work/$name ]] || die "linuxdeploy produced no AppImage"
|
||||
chmod +x "$work/$name"
|
||||
# Exercise the outer runtime without FUSE, then run the archive's full release
|
||||
# checks against the extracted payload through AppRun (SDK, bundler and hosts too).
|
||||
RAEA_NO_TREE=1 "$work/$name" --appimage-extract-and-run --version
|
||||
bash "$root/tools/release-check.sh" "$work/$name"
|
||||
mv "$work/$name" "$out/$name"
|
||||
(cd "$out" && sha256sum "$name" > "$name.sha256")
|
||||
echo "appimage: $out/$name"
|
||||
+44
-2
@@ -6,13 +6,25 @@
|
||||
# key, and a Windows archive holds no Microsoft file (the CRT comes from the VC++ redistributable;
|
||||
# docs/handoff/ports.md).
|
||||
#
|
||||
# tools/release-check.sh ARCHIVE raea-VERSION-PLATFORM.tar.gz or .zip
|
||||
# tools/release-check.sh ARCHIVE raea-VERSION-PLATFORM.tar.gz, .zip or .AppImage
|
||||
set -eu
|
||||
archive=${1:?usage: release-check.sh ARCHIVE}
|
||||
# RAEA_CHECK_DIR keeps the check's folder where a CI job can upload it when a check fails (release.yml)
|
||||
check=${RAEA_CHECK_DIR:-$(mktemp -d)}
|
||||
mkdir -p "$check"
|
||||
check=$(cd "$check" && pwd)
|
||||
case $archive in
|
||||
*.AppImage)
|
||||
archive=$(cd "$(dirname "$archive")" && pwd)/$(basename "$archive")
|
||||
(cd "$check" && "$archive" --appimage-extract >/dev/null)
|
||||
ln -s "$check/squashfs-root/usr" "$check/raea"
|
||||
# Every command goes through AppRun's environment, as a mounted image would.
|
||||
cat > "$check/appimage-raea" <<'SH'
|
||||
#!/bin/sh
|
||||
exec "$(dirname "$0")/squashfs-root/AppRun" "$@"
|
||||
SH
|
||||
chmod +x "$check/appimage-raea"
|
||||
;;
|
||||
*.zip) if command -v unzip >/dev/null; then unzip -q "$archive" -d "$check"; else 7z x -y -o"$check" "$archive" >/dev/null; fi ;;
|
||||
*) tar -xzf "$archive" -C "$check" ;;
|
||||
esac
|
||||
@@ -20,6 +32,7 @@ fail() { echo "release: $* (see $check)" >&2; exit 1; }
|
||||
raea=$check/raea/bin/raea
|
||||
[ -f "$raea.exe" ] && raea=$raea.exe
|
||||
[ -f "$raea" ] || fail "no raea in bin/"
|
||||
[ ! -f "$check/appimage-raea" ] || raea=$check/appimage-raea
|
||||
# the edit in a folder of its own: raea reads every file under a project, and the install isn't the user's project
|
||||
mkdir -p "$check/p"
|
||||
cat > "$check/p/hello.tsx" <<'TSX'
|
||||
@@ -143,7 +156,8 @@ open my $f, '>:raw', $out or die "$out: $!";
|
||||
print $f 'RIFF', pack('V', 36 + 2 * $n), 'WAVEfmt ', pack('VvvVVvv', 16, 1, 1, $sr, 2 * $sr, 2, 16), 'data', pack('V', 2 * $n), pack('s<*', @s);
|
||||
PL
|
||||
(cd "$check/song" && HOME="$check/song/home" LOCALAPPDATA="$check/song/home" RAEA_NO_TREE=1 "$raea" song loop.wav > song.log 2>&1) || { tail -20 "$check/song/song.log" >&2; fail "the unpacked raea didn't map a song"; }
|
||||
tempo=$(jq -r '.tempo' "$check/song/loop.song.json" | tr -d '\r')
|
||||
# (read without jq: a person's PC has none, tools/release-machines.sh)
|
||||
tempo=$(tr -d '\r\n' < "$check/song/loop.song.json" | sed -n 's/.*"tempo"[[:space:]]*:[[:space:]]*\([0-9.eE+-]*\).*/\1/p')
|
||||
awk -v t="$tempo" 'BEGIN { exit !(t >= 118 && t <= 122) }' || fail "raea song read the 120 BPM loop as $tempo BPM"
|
||||
# engine only: no raea API in the binaries, nothing key-shaped anywhere
|
||||
api=$(cat "$check"/raea/bin/* | grep -aoE '(api|sign)\.raea\.io|RAEA_(SIGN|GEN)_TOKEN' | sort -u | tr '\n' ' ' || true)
|
||||
@@ -172,5 +186,33 @@ if [ -f "$check/raea/bin/raea.exe" ]; then
|
||||
done
|
||||
"$check/raea/bin/uv.exe" --version 2>&1 | grep -q '^uv ' || fail "bin/uv.exe doesn't run"
|
||||
fi
|
||||
# RAEA_CHECK_HARD=1 (tools/release-machines.sh, on real machines: a PC's own GPU, the Linux box): what reports from
|
||||
# other systems needed and a runner's one pass doesn't show.
|
||||
if [ "${RAEA_CHECK_HARD:-}" = 1 ]; then
|
||||
# a project in a folder with a space and letters outside ASCII, as a person's own folders have ("C:\Users\José M\"):
|
||||
# the page, its 3D, and an MP4 of it (#40-#42, #78, #169: paths read as URLs, as \\?\ paths, with backslashes kept)
|
||||
hard="$check/José's work/proj é"
|
||||
mkdir -p "$hard" && cp "$check/p/hello.tsx" "$check/3d/cube.tsx" "$hard/"
|
||||
(cd "$hard" && RAEA_NO_TREE=1 RUST_BACKTRACE=1 "$raea" render hello.tsx --frame 3 -o "héllo out.png" > render.log 2>&1 && [ -s "héllo out.png" ]) || { tail -20 "$hard/render.log" >&2; fail "no frame from a folder with a space and letters outside ASCII"; }
|
||||
! grep -q "is all black" "$hard/render.log" || fail "the frame from a folder with a space and letters outside ASCII is all black"
|
||||
# 3D on this machine's own GPU: Windows too, which a runner (WARP, lavapipe) never draws on (#66: an AMD GPU drew nothing)
|
||||
(cd "$hard" && RAEA_NO_TREE=1 RUST_BACKTRACE=1 "$raea" render cube.tsx --frame 3 -o cube.png > cube.log 2>&1 && [ -s cube.png ]) || { tail -20 "$hard/cube.log" >&2; fail "no 3D frame on this machine's GPU"; }
|
||||
! grep -q "is all black" "$hard/cube.log" || fail "the 3D frame on this machine's GPU is all black"
|
||||
(cd "$hard" && RAEA_NO_TREE=1 RUST_BACKTRACE=1 "$raea" render hello.tsx -o hello.mp4 > mp4.log 2>&1 && [ -s hello.mp4 ]) || { tail -20 "$hard/mp4.log" >&2; fail "no MP4 from a folder with a space and letters outside ASCII"; }
|
||||
# the same render over and over: a crash one run in many is still a crash (#65: a segfault at exit, 1 run in 160, after
|
||||
# the frames were written), so every run's exit is read, not only its file
|
||||
n=${RAEA_CHECK_REPEATS:-40}
|
||||
for i in $(seq "$n"); do
|
||||
(cd "$hard" && RAEA_NO_TREE=1 "$raea" render cube.tsx --frame $((i % 9)) -o "again.png" > again.log 2>&1) || { s=$?; tail -20 "$hard/again.log" >&2; fail "run $i of $n of the same 3D render ended with exit $s"; }
|
||||
done
|
||||
# two renders at once, each in its own folder: neither takes the other's work folder away (#29)
|
||||
mkdir -p "$hard/a" "$hard/b" && cp "$hard/hello.tsx" "$hard/a/" && cp "$hard/hello.tsx" "$hard/b/"
|
||||
(cd "$hard/a" && RAEA_NO_TREE=1 "$raea" render hello.tsx -o out.mp4 > render.log 2>&1) & pa=$!
|
||||
(cd "$hard/b" && RAEA_NO_TREE=1 "$raea" render hello.tsx -o out.mp4 > render.log 2>&1) & pb=$!
|
||||
wait $pa || { tail -20 "$hard/a/render.log" >&2; fail "one of two renders running at once failed"; }
|
||||
wait $pb || { tail -20 "$hard/b/render.log" >&2; fail "one of two renders running at once failed"; }
|
||||
[ -s "$hard/a/out.mp4" ] && [ -s "$hard/b/out.mp4" ] || fail "two renders at once didn't both write their MP4"
|
||||
echo "release: the hard pass too: a folder with a space and letters outside ASCII, 3D on this GPU, $n runs of one render, two at once"
|
||||
fi
|
||||
echo "release: $archive checked: an unpacked copy rendered a frame and checked an app on both targets with RAEA_NO_TREE=1"
|
||||
rm -rf "$check"
|
||||
@@ -0,0 +1,82 @@
|
||||
#!/bin/bash
|
||||
# The engine's release check run on real machines, hard pass and all (tools/release-check.sh with RAEA_CHECK_HARD=1):
|
||||
# a release's Windows zip on the Windows PC, on its own GPU, and its Linux tarball on the Linux box. release.yml's
|
||||
# runners check each archive once, on a software GPU on Windows; what people reported from their own machines (a folder
|
||||
# with a space or an accent in its name, an AMD or NVIDIA GPU, a crash one run in many, two renders at once) only shows
|
||||
# on a machine like theirs. This is the engine's half of the app's tools/raea-app/everywhere.sh (raea-platform).
|
||||
# tools/release-machines.sh VERSION [linux windows] e.g. tools/release-machines.sh 0.1.10-rc3
|
||||
# The archives come from the release (kept in ~/.cache/raea-app/engine-VERSION, as everywhere.sh keeps them), go to each
|
||||
# machine, are checked there and removed. One line per machine at the end; exit 1 names what failed.
|
||||
# RAEA_WIN_CHECK_HOST names the PC; RAEA_LINUX_BOX the Sprite; RAEA_CHECK_REPEATS how many times the one render repeats (40).
|
||||
set -uo pipefail
|
||||
version=${1:?usage: release-machines.sh VERSION [linux windows]}
|
||||
version=${version#v}
|
||||
shift
|
||||
machines=("$@"); [ ${#machines[@]} -gt 0 ] || machines=(linux windows)
|
||||
REPO=shinyobjectz/raea
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
cache="$HOME/.cache/raea-app/engine-$version"; mkdir -p "$cache"
|
||||
logs=${RAEA_MACHINES_LOGS:-$(mktemp -d)}; mkdir -p "$logs"
|
||||
repeats=${RAEA_CHECK_REPEATS:-40}
|
||||
archive() {
|
||||
local name=$1
|
||||
[ -f "$cache/$name" ] || gh release download "v$version" -R "$REPO" -p "$name" -p "$name.sha256" -D "$cache" --clobber >&2 || return 1
|
||||
(cd "$cache" && shasum -a 256 -c "$name.sha256" >/dev/null) || { echo "FAIL $name doesn't match its .sha256" >&2; return 1; }
|
||||
echo "$cache/$name"
|
||||
}
|
||||
# the check and what it reads beside itself (release/win-bundle.files), as one small tarball
|
||||
kit="$logs/kit.tar"
|
||||
tar -cf "$kit" -C "$root/tools" release-check.sh release/win-bundle.files || exit 1
|
||||
|
||||
linux() {
|
||||
local a; a=$(archive "raea-$version-linux-x86_64.tar.gz") || return 1
|
||||
# shellcheck disable=SC1091
|
||||
. "$root/sdk/cloud/deploy/sprites/org.sh" || { echo "FAIL no Sprite org"; return 1; }
|
||||
local S=(-o "$ORG" -s "${RAEA_LINUX_BOX:-raea-linux}") dir="raea-engine-check-$(date +%s)-$$"
|
||||
sprite exec --no-stdin "${S[@]}" -- bash -c "mkdir -p ~/$dir" || { echo "FAIL the Linux box isn't reachable"; return 1; }
|
||||
local want got
|
||||
want=$(wc -c < "$a" | tr -d ' ')
|
||||
got=$(sprite exec "${S[@]}" -- bash -c "cat > ~/$dir/raea.tar.gz && wc -c < ~/$dir/raea.tar.gz" < "$a" | tr -dc 0-9)
|
||||
[ "$got" = "$want" ] || { echo "FAIL the archive didn't reach the Linux box whole (${got:-0} of $want bytes)"; return 1; }
|
||||
sprite exec "${S[@]}" -- bash -c "tar -xf - -C ~/$dir" < "$kit" || { echo "FAIL copying the check"; return 1; }
|
||||
echo "machines: the check is running on the Linux box"
|
||||
# (no stdin of ours held open: a check started with it open sits silent, 11-25; under Xvfb, as release.yml runs it:
|
||||
# the app check opens a window, and the box has no screen)
|
||||
sprite exec --no-stdin "${S[@]}" -- bash -c "cd ~/$dir && RAEA_CHECK_HARD=1 RAEA_CHECK_REPEATS=$repeats timeout 2400 xvfb-run -a -s '-screen 0 1280x1024x24' bash release-check.sh ~/$dir/raea.tar.gz > check.out 2>&1 < /dev/null; code=\$?; tail -40 check.out; cd ~ && rm -rf ~/$dir; exit \$code"
|
||||
}
|
||||
|
||||
windows() {
|
||||
local a; a=$(archive "raea-$version-windows-x86_64.zip") || return 1
|
||||
local host=${RAEA_WIN_CHECK_HOST:-cuda-box} dir="raea-engine-check-$(date +%s)-$$"
|
||||
ssh -o ConnectTimeout=15 "$host" "mkdir $dir" >/dev/null || { echo "FAIL the PC isn't reachable over ssh"; return 1; }
|
||||
# shellcheck disable=SC2064
|
||||
trap "ssh -o ConnectTimeout=15 '$host' 'rmdir /s /q $dir' >/dev/null 2>&1" RETURN
|
||||
local free
|
||||
free=$(ssh "$host" "powershell -NoProfile -Command [math]::Floor((Get-PSDrive C).Free/1MB)" | tr -dc 0-9)
|
||||
[ "${free:-0}" -ge 3000 ] || { echo "FAIL the PC has ${free:-?} MB free on C:, and the check needs 3000"; return 1; }
|
||||
scp -q "$a" "$host:$dir/raea.zip" && scp -q "$kit" "$host:$dir/kit.tar" || { echo "FAIL copying the archive to the PC"; return 1; }
|
||||
# the PC's ssh shell is cmd, which takes `>` and `&&` in a command for itself: the check's line goes as a file
|
||||
printf 'cd ~/%s && tar -xf kit.tar && RAEA_CHECK_HARD=1 RAEA_CHECK_REPEATS=%s RAEA_CHECK_DIR="$PWD/c" bash release-check.sh "$PWD/raea.zip" > check.out 2>&1; code=$?; tail -40 check.out; exit $code\n' "$dir" "$repeats" > "$logs/win-run.sh"
|
||||
scp -q "$logs/win-run.sh" "$host:$dir/run.sh" || { echo "FAIL copying the check to the PC"; return 1; }
|
||||
echo "machines: the check is running on the PC"
|
||||
ssh "$host" "\"C:\\Program Files\\Git\\bin\\bash.exe\" $dir/run.sh"
|
||||
}
|
||||
|
||||
echo "machines: the engine $version on: ${machines[*]} (logs: $logs)"
|
||||
pids=()
|
||||
for m in "${machines[@]}"; do
|
||||
case $m in linux | windows) ;; *) echo "machines: linux or windows, not $m"; exit 2 ;; esac
|
||||
"$m" > "$logs/$m.log" 2>&1 &
|
||||
pids+=($!)
|
||||
done
|
||||
failed=()
|
||||
for i in "${!machines[@]}"; do
|
||||
m=${machines[$i]}
|
||||
if wait "${pids[$i]}"; then
|
||||
echo "machines: $m ok $(grep -h 'the hard pass too' "$logs/$m.log" | tail -1)"
|
||||
else
|
||||
echo "machines: $m FAILED $(grep -h -E '^(FAIL|release: )' "$logs/$m.log" | tail -1)"; failed+=("$m")
|
||||
fi
|
||||
done
|
||||
[ ${#failed[@]} -eq 0 ] || { echo "FAIL ${failed[*]} (engine $version; logs in $logs)"; exit 1; }
|
||||
echo "ok the engine $version on ${machines[*]}"
|
||||
@@ -206,6 +206,12 @@ for md in "$stage"/share/raea/skills/*/SKILL.md; do
|
||||
perl -0pi -e 's/\A---\n(.*?)\n---\n/"---\n" . join("\n", grep { !\/^version:\/ } split(\/\n\/, $1)) . "\nversion: '"$version"'\n---\n"/se' "$md"
|
||||
done
|
||||
if [ $platform = windows-x86_64 ]; then
|
||||
# RAEA_WIN_SIGN=1: raea's own programs signed before they're zipped (tools/release/win-sign.sh, #221). Off, the zip is
|
||||
# as it was: unsigned, which Smart App Control blocks on a PC that has it on
|
||||
if [ "${RAEA_WIN_SIGN:-}" = 1 ]; then
|
||||
bash "$root/tools/release/win-sign.sh" "$stage/bin/raea.exe" "$stage/bin/raea_bundle.dll" "$stage/bin/raea-perceive.exe" "$stage/bin/raea-rune-host.exe" "$stage/bin/raea-page-host.exe" ||
|
||||
{ echo "release.sh: raea's Windows programs couldn't be signed (RAEA_WIN_SIGN=1)" >&2; exit 1; }
|
||||
fi
|
||||
archive=$name.zip
|
||||
rm -f "$out/$archive"
|
||||
(cd "$(dirname "$stage")" && 7z a -tzip -bso0 -bsp0 "$out/$archive" raea)
|
||||
|
||||
@@ -1,5 +1,63 @@
|
||||
# Release recipes
|
||||
|
||||
## Linux AppImage
|
||||
|
||||
`release.yml` builds an x86_64 AppImage after the Linux tarball passes its checks,
|
||||
for both source builds and promoted candidates. It attaches
|
||||
`raea-VERSION-linux-x86_64.AppImage` and `.AppImage.sha256` beside the existing
|
||||
archives and attests the AppImage. Tag pushes (`v*`) and manual runs use the same
|
||||
steps; a manual `dry_run` keeps the files as workflow artifacts without publishing.
|
||||
The existing skills gate still applies (`skills_passed` or the tag's
|
||||
`skills-passed:` line when the feed app is absent).
|
||||
|
||||
To package an existing, checked Linux release locally on Ubuntu 24.04 x86_64:
|
||||
|
||||
```sh
|
||||
bash tools/release-appimage.sh 0.1.6 dist/raea-0.1.6-linux-x86_64.tar.gz
|
||||
```
|
||||
|
||||
Keep the tarball's `.sha256` beside it. The script verifies it and its version,
|
||||
preserves the SDK, model, skills and companion hosts, then uses a version and
|
||||
SHA256 pinned [linuxdeploy](https://github.com/linuxdeploy/linuxdeploy/releases/tag/1-alpha-20251107-1)
|
||||
to collect linked libraries and package the image. The bundler stays beside the
|
||||
executables because RAEA loads it at runtime. Project licenses and the distribution's
|
||||
copyright notices for bundled libraries travel with the image. `curl`, `binutils`,
|
||||
`coreutils`, `tar` and `dpkg-query` are required, alongside the normal release's
|
||||
runtime libraries and Xvfb for the checks. `RAEA_LINUXDEPLOY=/path/to/linuxdeploy-x86_64.AppImage`
|
||||
uses a previously downloaded copy, with the same checksum verification. The AppImage
|
||||
runtime is also version and checksum pinned; `RAEA_APPIMAGE_RUNTIME=/path/to/runtime-x86_64`
|
||||
supplies a local copy. With both overrides, the packaging tools need no downloads.
|
||||
An optional third argument selects the output directory (default: `dist/`).
|
||||
|
||||
The AppImage runtime is smoke tested without FUSE, and the full
|
||||
`tools/release-check.sh` suite runs through the extracted image's `AppRun` before
|
||||
the output and its checksum are written. `RAEA_CHECK_DIR` keeps failed checks'
|
||||
frames and logs, as for the tarball.
|
||||
|
||||
This packages the public `raea` engine command and its app hosts. The desktop editor
|
||||
is a separate distribution whose source is absent from this checkout. `AppRun`
|
||||
preserves the caller's working directory and arguments; it does not install RAEA
|
||||
or the agent skills into the user's home.
|
||||
|
||||
```sh
|
||||
sha256sum -c raea-0.1.6-linux-x86_64.AppImage.sha256
|
||||
chmod +x raea-0.1.6-linux-x86_64.AppImage
|
||||
./raea-0.1.6-linux-x86_64.AppImage --help
|
||||
./raea-0.1.6-linux-x86_64.AppImage render hello.tsx -o hello.mp4
|
||||
# Without FUSE (extracts to temporary storage for this invocation):
|
||||
./raea-0.1.6-linux-x86_64.AppImage --appimage-extract-and-run --help
|
||||
```
|
||||
|
||||
The Ubuntu 24.04 build still requires glibc 2.39 or newer, a Vulkan loader and GPU
|
||||
driver (or Mesa's software Vulkan), and a display for windowed apps. System
|
||||
libraries excluded by linuxdeploy, including ALSA and fontconfig, and optional
|
||||
tools such as FFmpeg are still host requirements, as in the tarball's README.
|
||||
Install a CJK font for Japanese, Chinese and Korean text. Normal mounted execution
|
||||
also needs FUSE; [AppImage's fallback options](https://docs.appimage.org/user-guide/troubleshooting/fuse.html)
|
||||
cover machines without it.
|
||||
|
||||
## Earlier release recipes
|
||||
|
||||
How 0.1.0-canary.2 and canary.3 were built and checked beyond `tools/release.sh` (kept for the next):
|
||||
|
||||
- `linux/Dockerfile`: the Ubuntu 24.04 build root (glibc 2.39), run under Rosetta; bun's x64 baseline build, as the
|
||||
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
appdir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
export PATH="$appdir/usr/bin:$PATH"
|
||||
export LD_LIBRARY_PATH="$appdir/usr/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
||||
export RAEA_HOME="$appdir/usr/share/raea"
|
||||
export RAEA_BUNDLE_LIB="$appdir/usr/bin/libraea_bundle.so"
|
||||
export RAEA_NO_TREE=1
|
||||
# Preserve the caller's working directory: composition and output paths are relative to it.
|
||||
exec "$appdir/usr/bin/raea" "$@"
|
||||
@@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=raea
|
||||
Comment=Render videos, motion graphics and 3D from React and TypeScript
|
||||
Exec=raea
|
||||
Icon=raea
|
||||
Terminal=true
|
||||
Categories=AudioVideo;Video;
|
||||
Loaded 100 of 120 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user