Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

SG11, SG14: the manifest lists the page's pictures and the words that may sit on a part

shinyobjectz590ec633f8a6
diff --git a/docs/manual/reference/cli/render.md b/docs/manual/reference/cli/render.md
index 822d4efd..f3266086 100644
--- a/docs/manual/reference/cli/render.md
+++ b/docs/manual/reference/cli/render.md
@@ -38,12 +38,13 @@ and the command says so.
Every render writes its manifest beside its output: `OUT.render.json` (`DIR/NAME.render.json` for a folder of
frames), or where `--manifest` says. It holds what each frame showed as laid out (each text's words, box, colour and
-size, each video's source and time), the sounds heard and what the render found. `raea check` reads it, and so does
+size, each video's source and time, each picture's box), the sounds heard and what the render found. `raea check` reads it, and so does
[`raea world`](world.md), which measures the output against it when a check asks.
A render checks what it draws: 3D parts passing into each other (the clipping check), how its 3D is staged (3D type
too small or turned to read, page type over a part, parts that snap, a camera that lurches, frames with almost nothing
-on screen; `raea scene stage` runs these without drawing, all but the page's) and its pictures' exposure (clipping to white, crushing to black). A video with 3D
+on screen; `raea scene stage` runs these without drawing, all but the page's). Page words meant to sit on a part go
+in an element with `data-allow-overlap` and its pictures' exposure (clipping to white, crushing to black). A video with 3D
in it, longer than 60 frames, is also checked for frame purity: every 300th frame, its last, and the frame after each
change of more than 20 parts are rendered again on their own and held to the video's. A patch that differs is an error
naming the frame and the parts under it, with both pictures kept beside the video (`OUT.frame-pure/`), since a part
diff --git a/docs/stage-guards.feature b/docs/stage-guards.feature
index ceb8d0a0..5babe61c 100644
--- a/docs/stage-guards.feature
+++ b/docs/stage-guards.feature
@@ -327,6 +327,8 @@ Feature: Stage guards: a 3D render an agent can't break
| raea-sys-stage | systems/stage/src/lib.rs | +14 | check_with and told take each frame's page |
| raea-sys-stage | systems/stage/src/framing.rs | +16 | the backdrop rule shared; the page's words and videos fill the frame (SG14) |
| raea-runtime-export | runtime/export/src/run.rs | +5 | a still's end checks wait for its page |
+ | raea-page | engine/page/src/motion/manifest.rs | +45 | the manifest's pictures (img, svg, background image or colour) and words marked allowOverlap |
+ | raea-runtime-page | runtime/page/src/bevy_page.rs | +2 | a frame's manifest entry carries them |
Then a page text box that covers more than 10% of a 3D part's projected box is an error, unless one of them says
allowOverlap
And on the film this flags the words over the curves at 2:08 and the headline on the AppLovin card at 6:40
@@ -338,8 +340,11 @@ Feature: Stage guards: a 3D render an agent can't break
# at 28%), the words over the brand cards from 6:33 to 6:37 (the first card at 61%) and 'social winners often
# don't' over the hero and the network's logo from 6:38 to 6:41. Some are words over a wall of small parts (54 ad tiles
# under '185 ads · 11 games' at 5:01, a chart's points at 1:03), which the rule as written counts: a wall of
- # tiles isn't a backdrop by the slab rule. Left: page text can't say allowOverlap (the manifest has a text's
- # words and box, not its props), and `raea scene stage` doesn't know the page, since it draws none.
+ # tiles isn't a backdrop by the slab rule. Branch stage-guards-9: words in an element that says
+ # data-allow-overlap may sit on any part (the manifest marks them allowOverlap): a headline across a card is an
+ # error, the same words under data-allow-overlap pass. Stay's page text over its pool room (frames 60-580 and
+ # 860-1460) says none. Left: `raea scene stage` doesn't know the page, since it draws none; the 3D guide's rule 9
+ # doesn't name type-over-part yet (the guide's copy in the skills goes with a raea-skills change).
Scenario: SG12. Nothing snaps
Given the plan
@@ -391,7 +396,13 @@ Feature: Stage guards: a 3D render an agent can't break
# (the notes' 3:40), and 21 subject cuts. Branch stage-guards-8: the page's words and videos fill the frame too
# (the manifest's, as SG11 reads them), so a headline over an empty 3D isn't an empty frame. Still warnings: the
# page's pictures (img, svg, a CSS background) aren't in the manifest, so one over an empty 3D would be a false
- # error. Left: those pictures in the manifest, then errors; the subject a Label points at.
+ # error. Branch stage-guards-9: the manifest lists the page's pictures (each img, inline svg, background image or
+ # colour at least half opaque, past a quarter percent of the frame), and they fill the frame too. Measured on
+ # Stay (approved) with its page known: its stretches at 0:39 and 0:45 clear (the page's words), and 0:02-0:18 and
+ # 0:29-0:33 still read empty. Those frames show a pool room whose walls, floor and water are backdrop by the slab
+ # rule, so frame-empty stays a warning: a room's inside is content the rule can't see. (Stay's frames past 1699
+ # couldn't be rendered on the 0.1.9 workspace build: Solari's traced vertex is 64 bytes since 7c12c971c4, and a
+ # mesh there binds 48.) Left: the subject a Label points at; a room's inside as content.
@done
Scenario: SG15. A broken render can't be posted
diff --git a/engine/page/src/motion/manifest.rs b/engine/page/src/motion/manifest.rs
index 8333a453..6cec4e81 100644
--- a/engine/page/src/motion/manifest.rs
+++ b/engine/page/src/motion/manifest.rs
@@ -1,4 +1,4 @@
-//! The render manifest's videos and text (render.json, `raea render --manifest`), as the page laid them out.
+//! The render manifest's videos, text and pictures (render.json, `raea render --manifest`), as the page laid them out.
use super::*;
@@ -7,16 +7,18 @@ impl BlitzPage {
/// each shown element with a `data-raea-src` (a video: its source, time and box), and each element's own words
/// (its text children's, inline elements' words going to the nearest element up with a box) with that box, its
/// opacity, colour, size, weight and alignment as computed. In document order, as raea-runtime-js's page gave them.
- pub fn manifest(&mut self) -> (Vec<serde_json::Value>, Vec<serde_json::Value>) {
+ /// And the page's pictures (picture()): what fills the frame besides its words and videos.
+ pub fn manifest(&mut self) -> (Vec<serde_json::Value>, Vec<serde_json::Value>, Vec<serde_json::Value>) {
use serde_json::json;
use style::values::specified::text::TextAlignKeyword;
let docs = self.app.world().non_send::<Docs>();
- let Some(doc) = docs.0.get(&self.page) else { return (vec![], vec![]) };
+ let Some(doc) = docs.0.get(&self.page) else { return (vec![], vec![], vec![]) };
+ let least = PICTURE_LEAST * self.w as f64 * self.h as f64;
let r = |v: f64| (v * 10.0).round() / 10.0;
let rect = |n: blitz_dom::NodeId| doc.get_client_bounding_rect(n).filter(|b| b.width > 0.0 && b.height > 0.0);
let alpha = |n: blitz_dom::NodeId| alpha(doc, n);
let stamps = |n: blitz_dom::NodeId, entry: &mut serde_json::Value| stamps(doc, n, entry);
- let (mut videos, mut text) = (Vec::new(), Vec::new());
+ let (mut videos, mut text, mut pictures) = (Vec::new(), Vec::new(), Vec::new());
let mut owned: Vec<(blitz_dom::NodeId, Vec<String>)> = Vec::new();
// the whole document: a composition's sequences and screens are pages of their own under the root's
let mut stack = vec![doc.root_node().id];
@@ -28,6 +30,9 @@ impl BlitzPage {
// an inline <svg> is drawn as one picture (usvg's): its <text>s are runs of their own, where usvg set them
if let Some(tree) = node.element_data().and_then(|e| e.svg_data()) {
if let (Some(b), a) = (rect(n), alpha(n)) {
+ if a > 0.01 && b.width * b.height >= least {
+ pictures.push(json!({"kind": "svg", "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (a * 100.0).round() / 100.0}));
+ }
let (sx, sy) = (b.width / tree.size().width().max(1e-6) as f64, b.height / tree.size().height().max(1e-6) as f64);
for (words, t, o) in svg_runs(tree.root(), a) {
let bb = [r(b.x + t.x() as f64 * sx), r(b.y + t.y() as f64 * sy), r(t.width() as f64 * sx), r(t.height() as f64 * sy)];
@@ -86,6 +91,14 @@ impl BlitzPage {
}
continue;
}
+ if let Some(kind) = picture(node) {
+ let a = alpha(n);
+ if let (Some(b), true) = (rect(n), a > 0.01) {
+ if b.width * b.height >= least {
+ pictures.push(json!({"kind": kind, "box": [r(b.x), r(b.y), r(b.width), r(b.height)], "opacity": (a * 100.0).round() / 100.0}));
+ }
+ }
+ }
if !node.is_text_node() {
continue;
}
@@ -191,11 +204,36 @@ impl BlitzPage {
if in_caption(doc, owner) {
t["caption"] = json!(true);
}
+ // words meant to sit on a 3D part (raea-sys-stage's type-over-part leaves them be, SG11)
+ if up(doc, owner, |node| node.attr(LocalName::from("data-allow-overlap")).is_some()) {
+ t["allowOverlap"] = json!(true);
+ }
stamps(owner, &mut t);
text.push(t);
}
- (videos, text)
+ (videos, text, pictures)
+ }
+}
+
+/// A picture smaller than this share of the frame is left out of the manifest: an icon or a rule fills none of it
+/// that a check counts (raea-sys-stage's coverage is a grid of 3% cells), and a page can hold hundreds.
+const PICTURE_LEAST: f64 = 0.0025;
+
+/// What an element paints over the frame besides words: "img" (an <img>), "background" (a CSS background image), or
+/// "fill" (a background colour at least half opaque). None for one that paints nothing of its own.
+fn picture(node: &blitz_dom::Node) -> Option<&'static str> {
+ if !node.is_element() {
+ return None;
}
+ if node.element_data().is_some_and(|e| &*e.name.local == "img") {
+ return Some("img");
+ }
+ let s = node.primary_styles()?;
+ let bg = s.get_background();
+ if bg.background_image.0.iter().any(|i| !matches!(i, style::values::computed::image::Image::None)) {
+ return Some("background");
+ }
+ (bg.background_color.resolve_to_absolute(&s.clone_color()).alpha >= 0.5).then_some("fill")
}
impl BlitzPage {
@@ -312,10 +350,15 @@ fn stamps(doc: &blitz_dom::BaseDocument, n: blitz_dom::NodeId, entry: &mut serde
/// Whether `n` is a caption or inside one: it or an element up from it carries data-raea-role="caption".
fn in_caption(doc: &blitz_dom::BaseDocument, n: blitz_dom::NodeId) -> bool {
+ up(doc, n, |node| node.attr(LocalName::from("data-raea-role")) == Some("caption"))
+}
+
+/// Whether `n` or an element it's in passes `test`.
+fn up(doc: &blitz_dom::BaseDocument, n: blitz_dom::NodeId, test: impl Fn(&blitz_dom::Node) -> bool) -> bool {
let mut at = Some(n);
while let Some(x) = at {
let Some(node) = doc.get_node(x) else { break };
- if node.attr(LocalName::from("data-raea-role")) == Some("caption") {
+ if test(node) {
return true;
}
at = node.parent;
diff --git a/runtime/page/src/bevy_page.rs b/runtime/page/src/bevy_page.rs
index f3d9d881..67f3978f 100644
--- a/runtime/page/src/bevy_page.rs
+++ b/runtime/page/src/bevy_page.rs
@@ -214,10 +214,10 @@ impl BevyPage {
self.page.boxes()
}
- /// Frame `f` of the render's manifest (render.json): the videos and text the page shows, as laid out.
+ /// Frame `f` of the render's manifest (render.json): the videos, text and pictures the page shows, as laid out.
pub fn manifest_frame(&mut self, f: i64) -> Value {
- let (videos, text) = self.page.manifest();
- serde_json::json!({"frame": f, "videos": videos, "text": text})
+ let (videos, text, pictures) = self.page.manifest();
+ serde_json::json!({"frame": f, "videos": videos, "text": text, "pictures": pictures})
}
/// The page laid out, nothing drawn (`raea world`): what `manifest_frame` and `boxes` read after a `sync`.
diff --git a/systems/stage/src/page.rs b/systems/stage/src/page.rs
index 2f3cf80c..043f225f 100644
--- a/systems/stage/src/page.rs
+++ b/systems/stage/src/page.rs
@@ -87,7 +87,7 @@ pub(crate) fn check(st: &Stage, page: &[Page]) -> Vec<Finding> {
let named: Vec<String> = most.iter().take(3).map(|(n, s)| format!("'{n}' ({:.0}%)", s * 100.0)).collect();
let more = if most.len() > 3 { format!(" and {} more", most.len() - 3) } else { String::new() };
let says = format!("'{}' in the page covers {}{more} from {} to {}", short(&text), named.join(", "), st.at(a), st.at(b));
- out.push(st.finding("type-over-part", Level::Error, a, b, says).fix("move the words off it, or beside it with a Label (raea/camera) that points at it; give the part allowOverlap when the words belong on it"));
+ out.push(st.finding("type-over-part", Level::Error, a, b, says).fix("move the words off it, or beside it with a Label (raea/camera) that points at it; words meant to sit on it go in an element with data-allow-overlap"));
}
}
out