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
Solari overscan (RT40), off by default: <SolariLighting overscan={0.05}> traces the view a twentieth wider on every side and crops the middle back out, so the frame's border has neighbours and history to gather from (a held wall at the edge: jitter's worst square 16% to 5.6%; the same picture with it off). FramePass's depth() and normal() read where the main pass drew, which also corrects them under a render scale below 1, and a camera with a prepass pass keeps PrepassRead, so a raster video with one isn't refused at its third frame. By the Solari session
shinyobjectze02151cf49e0
diff --git a/Cargo.lock b/Cargo.lockindex d934db83..dc1824ea 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -15069,6 +15069,7 @@ dependencies = ["raea-sys-engine-shaders","raea-sys-post","raea-sys-rt",+ "raea-sys-viewbox","serde_json","wgpu",]@@ -16173,10 +16174,12 @@ name = "raea-sys-framepass"version = "0.1.0"dependencies = ["bevy",+ "raea-sys-compose","raea-sys-frame","raea-sys-material","raea-sys-sampler","raea-sys-shader",+ "raea-sys-viewbox","serde_json",]diff --git a/docs/manual/reference/sdk/light.md b/docs/manual/reference/sdk/light.mdindex 5e7e3887..dd9c7623 100644--- a/docs/manual/reference/sdk/light.md+++ b/docs/manual/reference/sdk/light.md@@ -224,6 +224,7 @@ raster-lit: Bevy 0.20's Solari can't trace it, unless `dynamic` gives a skinned| `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`diff --git a/docs/solari-efficiency.md b/docs/solari-efficiency.mdindex 4ec1367a..2e904fc4 100644--- a/docs/solari-efficiency.md+++ b/docs/solari-efficiency.md@@ -88,12 +88,26 @@ jitter, or a cache sized to the take. So the live steady history is tried first:the cells the camera sees (they are read each frame, so never die) with no file and no capacity limit. It costs a lagon light that moves, as long as the history: t8's power cut needs a short `frames`, as it has today.-## The cache's level drifts with time and resolution (11-25)--The same t2 frame (1188), median scene luminance: a cold single frame at 1440 x 1080 reads 0.0189 and at 160 x 240-(the meter) 0.0177. Inside the long renders, the view reads 0.130 (7x) and the meter 0.0034 (0.2x). So the cache's-long-run level depends on how many pixels feed it, and the camcorder's auto-exposure, metered at 160 x 240, set the-final 14-40x too bright: Shane's overexposed daylight. The path tracer at t2's hold frame (t2-pt) says which is right.+## 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)@@ -249,8 +263,15 @@ With the firefly filter at 6 on every take, 19 of 24 holds read STEADY (8 of 22(`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 is- docs/raytracing.feature RT40, designed and not built.+ 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 readSTEADY minutes later): what's left there is chance, a firefly landing in the 75 frames or not.diff --git a/engine/render/raytrace/Cargo.toml b/engine/render/raytrace/Cargo.tomlindex 47f0cc05..80e93a63 100644--- a/engine/render/raytrace/Cargo.toml+++ b/engine/render/raytrace/Cargo.toml@@ -11,6 +11,8 @@ description = "raea-render's ray tracing: Bevy's Solari for a scene whose cameraraea-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 onesraea-sys-engine-shaders = { path = "../../../systems/engine-shaders" }diff --git a/engine/render/raytrace/src/lib.rs b/engine/render/raytrace/src/lib.rsindex 8bb789ec..0a73b4b4 100644--- a/engine/render/raytrace/src/lib.rs+++ b/engine/render/raytrace/src/lib.rs@@ -84,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 {@@ -102,6 +107,7 @@ impl Default for SolariSettings {emissive_sharpness: 6.0,jitter_frames: 8.0,dynamic: false,+ overscan: 0.0,}}}diff --git a/engine/render/raytrace/src/metalfx.rs b/engine/render/raytrace/src/metalfx.rsindex f6e9bb79..4f5aeba2 100644--- a/engine/render/raytrace/src/metalfx.rs+++ b/engine/render/raytrace/src/metalfx.rs@@ -89,6 +89,8 @@ 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)]@@ -162,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,})}}@@ -205,13 +207,28 @@ impl View {s.setShouldResetHistory(reset || self.fresh);matrices(s, view.world_from_view.to_matrix().inverse(), view.clip_from_view);s.encodeToCommandBuffer(cb);+ 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 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);+ 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();}- self.fresh = false;Ok(())}}@@ -241,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.@@ -284,7 +301,7 @@ fn denoise_up(view: ViewQuery<Viewed>, device: Res<RenderDevice>, mut kit: Localrun(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.@@ -292,7 +309,7 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDeif 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'slet 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 };@@ -302,7 +319,12 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDelet 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@@ -318,6 +340,7 @@ 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;}@@ -339,11 +362,12 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDelet 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 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() {@@ -384,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![@@ -419,6 +446,19 @@ fn run(entity: Entity, item: Item, st: &super::SolariSettings, device: &RenderDepass.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);@@ -427,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");}}diff --git a/engine/render/raytrace/src/settings.rs b/engine/render/raytrace/src/settings.rsindex cc6f670a..6635527b 100644--- a/engine/render/raytrace/src/settings.rs+++ b/engine/render/raytrace/src/settings.rs@@ -19,6 +19,7 @@ struct Overrides {jitter: Option<String>,emissive_sharpness: Option<f32>,dynamic: Option<bool>,+ overscan: Option<f32>,}fn overrides() -> &'static Overrides {@@ -41,6 +42,7 @@ fn overrides() -> &'static Overrides {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)),}})}@@ -61,6 +63,7 @@ pub(crate) fn of(s: Option<&SolariSettings>) -> SolariSettings {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}@@ -77,6 +80,7 @@ const VARS: &[(&str, &str)] = &[("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"),];@@ -97,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<_>>(),}),);diff --git a/engine/render/raytrace/src/upscale.rs b/engine/render/raytrace/src/upscale.rsindex 559c3996..d9413439 100644--- a/engine/render/raytrace/src/upscale.rs+++ b/engine/render/raytrace/src/upscale.rs@@ -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, Oppub(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)>();}_ => {}}diff --git a/sdk/guides/craft/bevy/solari.md b/sdk/guides/craft/bevy/solari.mdindex 49432427..ee916458 100644--- a/sdk/guides/craft/bevy/solari.md+++ b/sdk/guides/craft/bevy/solari.md@@ -156,7 +156,11 @@ Jitter has its own causes, measured on MALL RAT (t1 against its sky: worst squarits history is cut to black on those frames. `constants={{ emissiveClamp: { stillHold: 0.25 } }}` eases that forthin 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. There's no setting for it yet; frame a held shot so a flat lit wall doesn't end at the frame's edge.+ 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.## Whydiff --git a/sdk/render/src/bevy3d/raytracing.tsx b/sdk/render/src/bevy3d/raytracing.tsxindex 91949011..a7f6299d 100644--- a/sdk/render/src/bevy3d/raytracing.tsx+++ b/sdk/render/src/bevy3d/raytracing.tsx@@ -106,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 */@@ -231,6 +237,7 @@ export function solariSettings(p: SolariLightingProps): Record<string, unknown>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;}diff --git a/systems/framepass/Cargo.toml b/systems/framepass/Cargo.tomlindex 3b92cc14..f004fb99 100644--- a/systems/framepass/Cargo.toml+++ b/systems/framepass/Cargo.toml@@ -7,9 +7,11 @@ publish = falsedescription = "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" }raea-sys-shader = { path = "../shader" }+raea-sys-viewbox = { path = "../viewbox" }bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render"] }serde_json = "1"diff --git a/systems/framepass/src/lib.rs b/systems/framepass/src/lib.rsindex 061de04a..769fbf6b 100644--- a/systems/framepass/src/lib.rs+++ b/systems/framepass/src/lib.rs@@ -132,7 +132,9 @@ pub fn module(source: &str, uniforms: &[(String, &'static str)], textures: &[Strif 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, &Vapub 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_viewbox::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 projectionlet 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_viewbox::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>>, cachcontinue;}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 texturesassert!(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]diff --git a/systems/viewbox/src/lib.rs b/systems/viewbox/src/lib.rsindex c3f72e64..8ce2f968 100644--- a/systems/viewbox/src/lib.rs+++ b/systems/viewbox/src/lib.rs@@ -12,34 +12,81 @@ pub struct TagRowTarget(pub Handle<Image>);#[derive(Resource, Default)]pub struct ViewBox(pub Option<[u32; 4]>);+/// 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 (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)+ }+}++/// 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 rowsif 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 +126,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();