Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
render --alpha: a frame with 3D is transparent where nothing is drawn, as a 2D page is (#114)
shinyobjectzd1e61bee2baa
diff --git a/runtime/export/src/bevy_frame.rs b/runtime/export/src/bevy_frame.rsindex 3bce23c4..59bc579a 100644--- a/runtime/export/src/bevy_frame.rs+++ b/runtime/export/src/bevy_frame.rs@@ -28,7 +28,7 @@ pub(crate) fn snapshot_bevy(world: &mut World, page: &mut raea_runtime_page::Bev/// One frame on the bevy_ui page over its 3D drawn live (cx.scene3d, the engine render_fed opens: handles resolved from/// the edit's folder, world calls answered): each <Screen>'s picture handed to the engine, the 3D drawn as the fed render-/// draws it and its target read back, and the page laid over it. Straight RGBA, opaque.+/// draws it and its target read back, and the page laid over it. Straight RGBA, opaque (with --alpha, transparent where nothing is drawn: #114)./// The 3D's target (premultiplied: Bevy blends into a transparent clear) as a straight picture. Light in the clear/// (colour above its alpha) can't be straight: its alpha is raised to its brightest channel, which is exact over black/// and darkens a lit page under it only by that light's own share.@@ -52,8 +52,10 @@ pub(crate) fn bevy_over_3d(world: &mut World, page: &mut raea_runtime_page::Bevylive_scene(world, ls, &mut cx.scene3d, (page.w, page.h), fps, cx.dir)?;}let (px, pics) = bevy_page_frame(world, page, cx)?;+ // with --alpha (#114) what the page and its 3D leave empty stays transparent, as a page alone does; else over black+ let alpha = crate::ALPHA.load(std::sync::atomic::Ordering::Relaxed);let opaque = |mut px: Vec<u8>| {- for p in px.chunks_exact_mut(4) {+ for p in px.chunks_exact_mut(4).filter(|_| !alpha) {p[3] = 255;}px@@ -106,6 +108,8 @@ pub(crate) fn bevy_over_3d(world: &mut World, page: &mut raea_runtime_page::Bevy// alpha-to-coverage fragment wrote (3d/transparency_3d). The// page goes over as the fed render's compositor lays a page's fills and layers (Skia's SrcOver on the u8 grid:// dst * (256 - srcA) >> 8, plus the source), so a near-black 3D under a faded layer floors as it did there+ // with --alpha the 3D is over nothing: its alpha (its clear's, transparent) is laid under the page's the same way,+ // and the premultiplied result made straight for the PNGlet mut out = three;for (d, s) in out.chunks_exact_mut(4).zip(px.chunks_exact(4)) {let k = 256 - s[3] as u32;@@ -113,8 +117,9 @@ pub(crate) fn bevy_over_3d(world: &mut World, page: &mut raea_runtime_page::Bevylet t = d[c] as u32;d[c] = (s[c] as u32 + ((t * k) >> 8)).min(255) as u8;}- d[3] = 255;+ d[3] = if alpha { (s[3] as u32 + ((d[3] as u32 * k) >> 8)).min(255) as u8 } else { 255 };}+ if alpha { scene_straight(&mut out); }Ok(out)}diff --git a/runtime/export/src/program.rs b/runtime/export/src/program.rsindex d29d8524..640e3c8d 100644--- a/runtime/export/src/program.rs+++ b/runtime/export/src/program.rs@@ -19,9 +19,6 @@ pub(crate) fn program(frames: &[(i64, Frame)], w: u32, h: u32, fps: f64) -> raea// resource (srgb 43, 44, 47 unless a <BevyResource type="bevy_camera::clear_color::ClearColor"> sets it), as a Bevy// scene does (docs/control conventions C17)let clear = if ALPHA.load(std::sync::atomic::Ordering::Relaxed) { Some("#00000000".into()) } else { frames.first().and_then(|(_, f)| f.clear.clone()).and_then(|c| hex_of(&c)).or_else(|| (!has3d).then(|| "#000000".into())) };- if has3d && ALPHA.load(std::sync::atomic::Ordering::Relaxed) {- eprintln!("raea: --alpha keeps 2D pages and <Video> clips transparent; the frames with 3D are drawn over the 3D and come out opaque");- }let mut cam = row("cam", clear.map(|c| ("bg", V::S(c))).into_iter().collect());// a holder's background that changes over the frames: the clear keyed frame by frame (bg_r, bg_g, bg_b, bg_a, sRGB),// as the page over it changes. Before, the first frame's clear held for the whole render.