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.

Overscan's component lives in raea-sys-compose's passes, the facility framepass already reads PrepassRead from, so framepass doesn't depend on viewbox (viewbox re-exports it)

shinyobjectz0d92089f7d84
diff --git a/Cargo.lock b/Cargo.lock
index dc1824ea..1ef4d0a1 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -16179,7 +16179,6 @@ dependencies = [
"raea-sys-material",
"raea-sys-sampler",
"raea-sys-shader",
- "raea-sys-viewbox",
"serde_json",
]
@@ -16767,6 +16766,7 @@ name = "raea-sys-viewbox"
version = "0.1.0"
dependencies = [
"bevy",
+ "raea-sys-compose",
"raea-sys-frame",
]
diff --git a/systems/compose/src/passes.rs b/systems/compose/src/passes.rs
index 5cae6882..f4b0b5aa 100644
--- a/systems/compose/src/passes.rs
+++ b/systems/compose/src/passes.rs
@@ -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");
diff --git a/systems/framepass/Cargo.toml b/systems/framepass/Cargo.toml
index f004fb99..b6d38bdb 100644
--- a/systems/framepass/Cargo.toml
+++ b/systems/framepass/Cargo.toml
@@ -12,6 +12,5 @@ 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.rs
index 769fbf6b..0eaea68d 100644
--- a/systems/framepass/src/lib.rs
+++ b/systems/framepass/src/lib.rs
@@ -304,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>, Option<&'static bevy::camera::MainPassResolutionOverride>, Option<&'static raea_sys_viewbox::Overscan>)>;
+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.
@@ -340,7 +340,7 @@ fn draw<const BEFORE: bool>(view: Views<'_, '_>, p: Option<Res<Pipelines>>, cach
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_viewbox::Overscan::drawn(over));
+ 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 };
diff --git a/systems/viewbox/Cargo.toml b/systems/viewbox/Cargo.toml
index 9aaa7b47..1d7f9361 100644
--- a/systems/viewbox/Cargo.toml
+++ b/systems/viewbox/Cargo.toml
@@ -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"] }
diff --git a/systems/viewbox/src/lib.rs b/systems/viewbox/src/lib.rs
index 8ce2f968..76dd95fe 100644
--- a/systems/viewbox/src/lib.rs
+++ b/systems/viewbox/src/lib.rs
@@ -12,29 +12,7 @@ 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)
- }
-}
+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 {