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.

#38: a live scene's camera multisamples once a frame brings 3D (part of #38)

shinyobjectza6d7ab2c6ba8
diff --git a/bench/live-3d/check.sh b/bench/live-3d/check.sh
index 70d3829d..118af72f 100755
--- a/bench/live-3d/check.sh
+++ b/bench/live-3d/check.sh
@@ -18,7 +18,8 @@ trap 'rm -rf "$OUT"' EXIT
status=0
for f in bench/at-3d/scene.tsx sdk/raea/bench/bevy-parity/3d/spotlight.tsx sdk/raea/bench/bevy-parity/3d/spherical_area_lights.tsx \
sdk/raea/bench/bevy-parity/3d/atmospheric_fog.tsx examples/games/screenshake.tsx examples/games/shapes.tsx examples/games/lighting.tsx \
- sdk/raea/bench/bevy/environment/edit.tsx sdk/raea/bench/bevy-ts/cases/material-field-0.tsx; do
+ sdk/raea/bench/bevy/environment/edit.tsx sdk/raea/bench/bevy-ts/cases/material-field-0.tsx \
+ sdk/raea/bench/bevy-ts/cases/kept-mount.tsx sdk/raea/bench/bevy-ts/cases/kept-unmount.tsx; do
n=$(basename "$f" .tsx)
RAEA_3D=program "$BIN" render "$f" -o "$OUT/$n.program.txt" > "$OUT/$n.program.log" 2>&1 || { echo "FAIL $f: the programmed render failed"; tail -3 "$OUT/$n.program.log"; status=1; continue; }
RAEA_3D=live RAEA_LIVE3D_CHECK=1 "$BIN" render "$f" -o "$OUT/$n.live.txt" > "$OUT/$n.live.log" 2>&1 || { echo "FAIL $f: the live render failed: $(grep -o 'RAEA_LIVE3D_CHECK.\{0,160\}' "$OUT/$n.live.log" | head -1)"; status=1; continue; }
diff --git a/engine/render/src/engine.rs b/engine/render/src/engine.rs
index 389e63d1..5a95a23e 100644
--- a/engine/render/src/engine.rs
+++ b/engine/render/src/engine.rs
@@ -263,6 +263,7 @@ impl Engine {
self.app.world_mut().resource_mut::<FrameRows>().parse_looks();
// a glTF model, and a panorama a live frame showed first (#38), set up before the frame that shows it draws
if spawned { scene3d::await_models(&mut self.app)?; }
+ raea_sys_post::msaa_for_3d(self.app.world_mut(), has_3d(rows));
environment::live_rows(&mut self.app, rows, &self.dir)
}
diff --git a/systems/post/src/lib.rs b/systems/post/src/lib.rs
index 21b654b0..b5f9b9ee 100644
--- a/systems/post/src/lib.rs
+++ b/systems/post/src/lib.rs
@@ -13,3 +13,20 @@ pub mod motion_blur;
pub mod dof;
pub mod effect_stack;
pub mod outline;
+
+/// A live scene's camera made before its first 3D part (MSAA off, as a 2D scene's is) multisamples once a frame brings
+/// one, as a render's camera does from its load, which sees every frame's rows (#38: kept-mount's cube mounts at frame
+/// 10 and had hard edges live). Not one whose row asks for a single-sampled frame (ssao, aa, outline, frame_looks,
+/// passes: spawn_camera's rule), and not in preview.
+pub fn msaa_for_3d(world: &mut World, has_3d: bool) {
+ if !has_3d || preview() {
+ return;
+ }
+ let cams: Vec<Entity> = world.query_filtered::<Entity, With<Camera3d>>().iter(world).collect();
+ for e in cams {
+ let single = world.resource::<FrameRows>().vals(e).is_none_or(|v| ["ssao", "aa", "outline", "frame_looks", "passes"].iter().any(|k| v.contains_key(*k)));
+ if !single && world.get::<Msaa>(e) == Some(&Msaa::Off) {
+ world.entity_mut(e).insert(Msaa::default());
+ }
+ }
+}