M13.5: extended viewer (custom 3D views / Draft 3D render the pasteboard around the comp frame; view.extendedViewer)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brandon Thomas
2026-10-03 05:14:12 -04:00
co-authored by Claude Opus 5.5
parent ed46bc0cce
commit baf4716246
11 changed files with 219 additions and 16 deletions
+8
View File
@@ -89,6 +89,8 @@ pub enum Icon {
MaskVis,
Checker,
Region,
/// Extended Viewer: a small frame with corner ticks reaching outward.
ExtendedViewer,
Plus,
Minus,
Close,
@@ -513,6 +515,12 @@ pub fn paint(painter: &Painter, rect: Rect, icon: Icon, color: Color32) {
pen.rect(2.5, 2.5, 13.5, 13.5);
pen.rect(5.5, 5.5, 10.5, 10.5);
}
ExtendedViewer => {
pen.rect(5.0, 5.0, 11.0, 11.0);
for (x, y, dx, dy) in [(2.0, 2.0, 1.0, 1.0), (14.0, 2.0, -1.0, 1.0), (2.0, 14.0, 1.0, -1.0), (14.0, 14.0, -1.0, -1.0)] {
pen.line(&[(x + dx * 3.0, y), (x, y), (x, y + dy * 3.0)]);
}
}
Plus => {
pen.line(&[(8.0, 3.0), (8.0, 13.0)]);
pen.line(&[(3.0, 8.0), (13.0, 8.0)]);
+12 -2
View File
@@ -344,6 +344,7 @@ impl EffectcraftApp {
&& v.channel == effectcraft_engine::viewer::Channel::Rgb
&& v.exposure == 0.0
&& self.session.state.region_of_interest.is_none()
&& self.ui.viewer.extended.is_none()
}
/// Set up the GPU compositor on egui-wgpu's device (once). Without an adapter that runs
@@ -439,7 +440,7 @@ impl EffectcraftApp {
use std::hash::{Hash, Hasher};
let mut h = std::collections::hash_map::DefaultHasher::new();
// The region of interest changes what is rendered too.
let roi = self.session.state.region_of_interest.filter(|_| self.session.active_comp_id() == Some(comp));
let roi = self.viewer_region(comp);
if let Some(r) = roi {
r.map(f64::to_bits).hash(&mut h);
}
@@ -454,6 +455,15 @@ impl EffectcraftApp {
h.finish() | 1
}
/// The comp-space region viewer frames of `comp` cover: the region of interest, else the
/// Extended Viewer's area (frame plus pasteboard), else `None` (the whole frame).
pub fn viewer_region(&self, comp: ItemId) -> Option<[f64; 4]> {
if self.session.active_comp_id() != Some(comp) {
return None;
}
self.session.state.region_of_interest.or(self.ui.viewer.extended)
}
/// Request a prefetch frame render (no-op if cached/in flight).
pub fn request_frame(&self, comp: ItemId, frame: i64, scale: f64) {
self.request_frame_with(comp, frame, scale, false);
@@ -467,7 +477,7 @@ impl EffectcraftApp {
/// Render options of viewer frames of `comp` at `scale`.
pub fn frame_opts(&self, comp: ItemId, scale: f64) -> RenderOpts {
let (draft, _) = self.session.state.viewer.fast_previews.render(self.ui.viewer.interacting);
let roi = self.session.state.region_of_interest.filter(|_| self.session.active_comp_id() == Some(comp));
let roi = self.viewer_region(comp);
RenderOpts {
scale,
motion_blur: true,
+39 -2
View File
@@ -461,6 +461,9 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
ctx.data_mut(|d| d.insert_temp(map_id(), map));
let comp_rect = Rect::from_min_size(origin, vec2(cw * zoom, ch * zoom));
let painter = p.with_clip_rect(area);
// Settings ▸ 3D ▸ Extended Viewer: custom 3D views (and Draft 3D) render the visible
// pasteboard too, so 3D layers reaching past the comp frame stay visible there.
app.ui.viewer.extended = extended_region(app, &comp, cid, map);
// Frame.
let ppp = ctx.pixels_per_point();
@@ -491,7 +494,13 @@ pub fn show(app: &mut EffectcraftApp, ui: &mut egui::Ui, rect: Rect) {
let ectx = EvalCtx { project: &snap_project, comp_id: cid, comp: &comp, time, expr: snap_expr.as_deref(), footage: None };
// The frame (or snapshot) through Show Channel and exposure; ROI frames cover the region.
vt::draw_frame(app, &ctx, &painter, comp_rect, cid, &ectx);
painter.rect_stroke(comp_rect, 0.0, Stroke::new(1.0, Color32::from_black_alpha(160)), StrokeKind::Outside);
if app.ui.viewer.extended.is_some() {
// The comp frame outlined over the extended render.
painter.rect_stroke(comp_rect, 0.0, Stroke::new(1.0, Color32::from_gray(150)), StrokeKind::Outside);
app.auto.add("viewer.extendedArea", rect_of(&map, app.ui.viewer.extended), "Extended Viewer area");
} else {
painter.rect_stroke(comp_rect, 0.0, Stroke::new(1.0, Color32::from_black_alpha(160)), StrokeKind::Outside);
}
app.auto.add("viewer.comp", comp_rect, &comp_name);
app.auto.add("viewer.area", area, "Composition viewer");
@@ -1654,6 +1663,34 @@ pub(crate) fn hex_rgb(s: &str) -> Option<[u8; 3]> {
Some([p(0)?, p(2)?, p(4)?])
}
/// The Extended Viewer's render region for this frame (see [`ViewerState::extended`]):
/// Settings ▸ 3D ▸ Extended Viewer on, the comp has 3D layers and the view is a custom 3D view
/// (or Draft 3D is on), and part of the visible viewer lies outside the comp frame.
///
/// [`ViewerState::extended`]: crate::state::ViewerState::extended
pub(crate) fn extended_region(
app: &EffectcraftApp,
comp: &effectcraft_engine::project::Comp,
cid: effectcraft_engine::project::ItemId,
map: ViewerMap,
) -> Option<[f64; 4]> {
if !app.session.prefs.three_d.extended_viewer || !comp.has_3d() || app.session.state.region_of_interest.is_some() {
return None;
}
let view = app.session.state.views3d.get(&cid).map(|v| v.current).unwrap_or_default();
if view == View3D::ActiveCamera && !comp.draft_3d {
return None;
}
let a = map.to_comp(map.area.min);
let b = map.to_comp(map.area.max);
effectcraft_engine::render::extended_region(comp.width, comp.height, [a[0], a[1], b[0], b[1]], 1.0)
}
fn rect_of(map: &ViewerMap, r: Option<[f64; 4]>) -> Rect {
let [x, y, w, h] = r.unwrap_or_default();
Rect::from_min_max(map.to_screen([x, y]), map.to_screen([x + w, y + h]))
}
/// Put a rendered frame on screen: CPU pixels go into an egui texture; GPU frames are drawn
/// straight from their wgpu texture (registered with egui-wgpu, no readback).
fn show_frame(app: &mut EffectcraftApp, ctx: &egui::Context, key: crate::frames::FrameKey, img: crate::frames::FrameImage) {
@@ -1672,7 +1709,7 @@ fn show_frame(app: &mut EffectcraftApp, ctx: &egui::Context, key: crate::frames:
}
app.viewer_shown = app.viewer_tex.as_ref().map(|(t, k)| (t.id(), *k));
app.viewer_image = Some(img);
vt::set_texture_roi(ctx, app.session.state.region_of_interest);
vt::set_texture_roi(ctx, app.session.state.region_of_interest.or(app.ui.viewer.extended));
}
FrameImage::Gpu(f) => {
let Some(rs) = &app.wgpu else { return };
+7 -1
View File
@@ -694,7 +694,13 @@ pub(crate) fn bottom_bar(app: &mut EffectcraftApp, ui: &mut egui::Ui, bar: Rect,
if let Some(i) = popup(app, ui, "vw-cam-pop", r, &items, "view3dItem") {
let _ = app.session.execute("view.set3DView", json!({"view": View3D::ALL[i].id()}));
}
x = r.max.x + 6.0;
x = r.max.x + 4.0;
// Extended Viewer (Settings ▸ 3D): custom views and Draft 3D show past the comp frame.
let on = app.session.prefs.three_d.extended_viewer;
if tog(ui, &mut app.auto, &mut x, Icon::ExtendedViewer, on, "extendedViewer", "Extended Viewer").0 {
let _ = app.session.execute("view.extendedViewer", json!({}));
}
x += 2.0;
}
// Current time.
let tc = crate::panels::timecode(&app.session, comp, time);
+5
View File
@@ -299,6 +299,10 @@ pub struct ViewerState {
/// The pointer is dragging in the viewer this frame (Adaptive Resolution).
#[serde(skip)]
pub interacting: bool,
/// Extended Viewer: the comp-space region the viewer renders this frame (comp frame plus
/// the visible pasteboard), set while a 3D view shows past the frame.
#[serde(skip)]
pub extended: Option<[f64; 4]>,
/// View ▸ Panel Background Color (`None` = theme default).
pub pasteboard: Option<[u8; 3]>,
pub custom_pasteboard: [u8; 3],
@@ -326,6 +330,7 @@ impl Default for ViewerState {
ruler_origin: [0.0, 0.0],
roi_draw: false,
interacting: false,
extended: None,
pasteboard: None,
custom_pasteboard: [0x80, 0x80, 0x80],
}