0}>
{
if (!s) return;
- return s.splice(segmentIndex, 1);
+ s.splice(segmentIndex, 1);
}),
);
setEditorState("timeline", "selection", null);
});
},
- deleteZoomSegment: (segmentIndex: number) => {
+ deleteZoomSegments: (segmentIndices: number[]) => {
batch(() => {
setProject(
"timeline",
"zoomSegments",
produce((s) => {
if (!s) return;
- return s.splice(segmentIndex, 1);
+ // Normalize: numbers only, in-bounds, deduped, then descending
+ const sorted = [...new Set(segmentIndices)]
+ .filter((i) => Number.isInteger(i) && i >= 0 && i < s.length)
+ .sort((a, b) => b - a);
+ if (sorted.length === 0) return;
+ for (const i of sorted) s.splice(i, 1);
+ }),
+ );
+ setEditorState("timeline", "selection", null);
+ });
+ },
+ deleteLayoutSegment: (segmentIndex: number) => {
+ batch(() => {
+ setProject(
+ "timeline",
+ "layoutSegments",
+ produce((s) => {
+ if (!s) return;
+ s.splice(segmentIndex, 1);
}),
);
setEditorState("timeline", "selection", null);
@@ -237,8 +255,9 @@ export const [EditorContextProvider, useEditorContext] = createContextProvider(
interactMode: "seek" as "seek" | "split",
selection: null as
| null
- | { type: "zoom"; index: number }
- | { type: "clip"; index: number },
+ | { type: "zoom"; indices: number[] }
+ | { type: "clip"; index: number }
+ | { type: "layout"; index: number },
transform: {
// visible seconds
zoom: zoomOutLimit(),
diff --git a/apps/desktop/src/styles/theme.css b/apps/desktop/src/styles/theme.css
index ce6f5ee6d95..72a63df900b 100644
--- a/apps/desktop/src/styles/theme.css
+++ b/apps/desktop/src/styles/theme.css
@@ -151,6 +151,7 @@
.custom-scroll {
margin-right: 3px; /* Add margin to create space between scrollbar and window edge */
overflow-y: scroll;
+ margin-top: var(--margin-top-scroll);
}
.custom-scroll::-webkit-scrollbar {
diff --git a/apps/desktop/src/utils/tauri.ts b/apps/desktop/src/utils/tauri.ts
index e2cd307ab9a..84c1629a1f1 100644
--- a/apps/desktop/src/utils/tauri.ts
+++ b/apps/desktop/src/utils/tauri.ts
@@ -721,9 +721,16 @@ export type TargetUnderCursor = {
window: WindowUnderCursor | null;
screen: ScreenUnderCursor | null;
};
+export type LayoutSegment = {
+ start: number;
+ end: number;
+ mode?: "default" | "cameraOnly" | "hideCamera";
+};
+
export type TimelineConfiguration = {
segments: TimelineSegment[];
zoomSegments: ZoomSegment[];
+ layoutSegments?: LayoutSegment[];
};
export type TimelineSegment = {
recordingSegment?: number;
diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rs
index 3202b1e5c77..8caa77a937d 100644
--- a/crates/project/src/configuration.rs
+++ b/crates/project/src/configuration.rs
@@ -456,11 +456,31 @@ pub enum ZoomMode {
Manual { x: f32, y: f32 },
}
+#[derive(Type, Serialize, Deserialize, Clone, Copy, Debug, Default)]
+#[serde(rename_all = "camelCase")]
+pub enum LayoutMode {
+ #[default]
+ Default,
+ CameraOnly,
+ HideCamera,
+}
+
+#[derive(Type, Serialize, Deserialize, Clone, Debug)]
+#[serde(rename_all = "camelCase")]
+pub struct LayoutSegment {
+ pub start: f64,
+ pub end: f64,
+ #[serde(default)]
+ pub mode: LayoutMode,
+}
+
#[derive(Type, Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct TimelineConfiguration {
pub segments: Vec,
pub zoom_segments: Vec,
+ #[serde(default)]
+ pub layout_segments: Vec,
}
impl TimelineConfiguration {
diff --git a/crates/rendering/src/composite_frame.rs b/crates/rendering/src/composite_frame.rs
index 992246caaa8..e6481184365 100644
--- a/crates/rendering/src/composite_frame.rs
+++ b/crates/rendering/src/composite_frame.rs
@@ -8,7 +8,7 @@ pub struct CompositeVideoFramePipeline {
pub render_pipeline: wgpu::RenderPipeline,
}
-#[derive(Debug, Clone, Copy, Pod, Zeroable, Default)]
+#[derive(Debug, Clone, Copy, Pod, Zeroable)]
#[repr(C)]
pub struct CompositeVideoFrameUniforms {
pub crop_bounds: [f32; 4],
@@ -25,9 +25,33 @@ pub struct CompositeVideoFrameUniforms {
pub shadow_size: f32,
pub shadow_opacity: f32,
pub shadow_blur: f32,
+ pub opacity: f32,
pub _padding: [f32; 3],
}
+impl Default for CompositeVideoFrameUniforms {
+ fn default() -> Self {
+ Self {
+ crop_bounds: Default::default(),
+ target_bounds: Default::default(),
+ output_size: Default::default(),
+ frame_size: Default::default(),
+ velocity_uv: Default::default(),
+ target_size: Default::default(),
+ rounding_px: Default::default(),
+ mirror_x: Default::default(),
+ motion_blur_amount: Default::default(),
+ camera_motion_blur_amount: Default::default(),
+ shadow: Default::default(),
+ shadow_size: Default::default(),
+ shadow_opacity: Default::default(),
+ shadow_blur: Default::default(),
+ opacity: 1.0,
+ _padding: Default::default(),
+ }
+ }
+}
+
impl CompositeVideoFrameUniforms {
pub fn to_buffer(self, device: &wgpu::Device) -> wgpu::Buffer {
device.create_buffer_init(
diff --git a/crates/rendering/src/layout.rs b/crates/rendering/src/layout.rs
new file mode 100644
index 00000000000..03e6f1bfd59
--- /dev/null
+++ b/crates/rendering/src/layout.rs
@@ -0,0 +1,276 @@
+use cap_project::{LayoutMode, LayoutSegment};
+
+pub const LAYOUT_TRANSITION_DURATION: f64 = 0.3;
+
+#[derive(Debug, Clone, Copy)]
+pub struct LayoutSegmentsCursor<'a> {
+ time: f64,
+ segment: Option<&'a LayoutSegment>,
+ prev_segment: Option<&'a LayoutSegment>,
+ segments: &'a [LayoutSegment],
+}
+
+impl<'a> LayoutSegmentsCursor<'a> {
+ pub fn new(time: f64, segments: &'a [LayoutSegment]) -> Self {
+ match segments
+ .iter()
+ .position(|s| time >= s.start && time < s.end)
+ {
+ Some(segment_index) => LayoutSegmentsCursor {
+ time,
+ segment: Some(&segments[segment_index]),
+ prev_segment: if segment_index > 0 {
+ Some(&segments[segment_index - 1])
+ } else {
+ None
+ },
+ segments,
+ },
+ None => {
+ let prev = segments
+ .iter()
+ .enumerate()
+ .rev()
+ .find(|(_, s)| s.end <= time);
+ LayoutSegmentsCursor {
+ time,
+ segment: None,
+ prev_segment: prev.map(|(_, s)| s),
+ segments,
+ }
+ }
+ }
+ }
+
+ pub fn next_segment(&self) -> Option<&'a LayoutSegment> {
+ let current_time = self.time;
+ self.segments.iter().find(|s| s.start > current_time)
+ }
+}
+
+#[derive(Debug, Clone, Copy)]
+pub struct InterpolatedLayout {
+ pub camera_opacity: f64,
+ pub screen_opacity: f64,
+ pub camera_scale: f64,
+ pub layout_mode: LayoutMode,
+ pub transition_progress: f64,
+ pub from_mode: LayoutMode,
+ pub to_mode: LayoutMode,
+ pub screen_blur: f64,
+ pub camera_only_zoom: f64,
+ pub camera_only_blur: f64,
+}
+
+impl InterpolatedLayout {
+ pub fn new(cursor: LayoutSegmentsCursor) -> Self {
+ let ease_in_out = bezier_easing::bezier_easing(0.42, 0.0, 0.58, 1.0).unwrap();
+
+ let (current_mode, next_mode, transition_progress) = if let Some(segment) = cursor.segment {
+ let transition_start = segment.start - LAYOUT_TRANSITION_DURATION;
+ let transition_end = segment.end - LAYOUT_TRANSITION_DURATION;
+
+ if cursor.time < segment.start && cursor.time >= transition_start {
+ let prev_mode = cursor
+ .prev_segment
+ .map(|s| s.mode.clone())
+ .unwrap_or(LayoutMode::Default);
+ let progress = (cursor.time - transition_start) / LAYOUT_TRANSITION_DURATION;
+ (
+ prev_mode,
+ segment.mode.clone(),
+ ease_in_out(progress as f32) as f64,
+ )
+ } else if cursor.time >= transition_end && cursor.time < segment.end {
+ if let Some(next_seg) = cursor.next_segment() {
+ let progress = (cursor.time - transition_end) / LAYOUT_TRANSITION_DURATION;
+ (
+ segment.mode.clone(),
+ next_seg.mode.clone(),
+ ease_in_out(progress as f32) as f64,
+ )
+ } else {
+ let progress = (cursor.time - transition_end) / LAYOUT_TRANSITION_DURATION;
+ (
+ segment.mode.clone(),
+ LayoutMode::Default,
+ ease_in_out(progress as f32) as f64,
+ )
+ }
+ } else {
+ (segment.mode.clone(), segment.mode.clone(), 1.0)
+ }
+ } else if let Some(next_segment) = cursor.next_segment() {
+ let transition_start = next_segment.start - LAYOUT_TRANSITION_DURATION;
+ if cursor.time >= transition_start {
+ let prev_mode = cursor
+ .prev_segment
+ .map(|s| s.mode.clone())
+ .unwrap_or(LayoutMode::Default);
+ let progress = (cursor.time - transition_start) / LAYOUT_TRANSITION_DURATION;
+ (
+ prev_mode,
+ next_segment.mode.clone(),
+ ease_in_out(progress as f32) as f64,
+ )
+ } else if let Some(prev_segment) = cursor.prev_segment {
+ if cursor.time < prev_segment.end + 0.05 {
+ (prev_segment.mode.clone(), LayoutMode::Default, 1.0)
+ } else {
+ (LayoutMode::Default, LayoutMode::Default, 1.0)
+ }
+ } else {
+ (LayoutMode::Default, LayoutMode::Default, 1.0)
+ }
+ } else {
+ if let Some(prev_segment) = cursor.prev_segment {
+ if cursor.time < prev_segment.end + 0.05 {
+ (prev_segment.mode.clone(), LayoutMode::Default, 1.0)
+ } else {
+ (LayoutMode::Default, LayoutMode::Default, 1.0)
+ }
+ } else {
+ (LayoutMode::Default, LayoutMode::Default, 1.0)
+ }
+ };
+
+ let (start_camera_opacity, start_screen_opacity, start_camera_scale) =
+ Self::get_layout_values(¤t_mode);
+ let (end_camera_opacity, end_screen_opacity, end_camera_scale) =
+ Self::get_layout_values(&next_mode);
+
+ let camera_opacity = Self::lerp(
+ start_camera_opacity,
+ end_camera_opacity,
+ transition_progress,
+ );
+ let screen_opacity = Self::lerp(
+ start_screen_opacity,
+ end_screen_opacity,
+ transition_progress,
+ );
+ let camera_scale = Self::lerp(start_camera_scale, end_camera_scale, transition_progress);
+
+ let screen_blur = if matches!(current_mode, LayoutMode::CameraOnly)
+ || matches!(next_mode, LayoutMode::CameraOnly)
+ {
+ if matches!(current_mode, LayoutMode::CameraOnly)
+ && !matches!(next_mode, LayoutMode::CameraOnly)
+ {
+ Self::lerp(1.0, 0.0, transition_progress)
+ } else if !matches!(current_mode, LayoutMode::CameraOnly)
+ && matches!(next_mode, LayoutMode::CameraOnly)
+ {
+ transition_progress
+ } else {
+ 0.0
+ }
+ } else {
+ 0.0
+ };
+
+ let camera_only_zoom = if matches!(next_mode, LayoutMode::CameraOnly)
+ && !matches!(current_mode, LayoutMode::CameraOnly)
+ {
+ Self::lerp(1.1, 1.0, transition_progress)
+ } else if matches!(current_mode, LayoutMode::CameraOnly)
+ && !matches!(next_mode, LayoutMode::CameraOnly)
+ {
+ Self::lerp(1.0, 1.1, transition_progress)
+ } else {
+ 1.0
+ };
+
+ let camera_only_blur = if matches!(next_mode, LayoutMode::CameraOnly)
+ && !matches!(current_mode, LayoutMode::CameraOnly)
+ {
+ Self::lerp(1.0, 0.0, transition_progress)
+ } else if matches!(current_mode, LayoutMode::CameraOnly)
+ && !matches!(next_mode, LayoutMode::CameraOnly)
+ {
+ transition_progress
+ } else {
+ 0.0
+ };
+
+ InterpolatedLayout {
+ camera_opacity,
+ screen_opacity,
+ camera_scale,
+ layout_mode: if transition_progress > 0.5 {
+ next_mode.clone()
+ } else {
+ current_mode.clone()
+ },
+ transition_progress,
+ from_mode: current_mode,
+ to_mode: next_mode,
+ screen_blur,
+ camera_only_zoom,
+ camera_only_blur,
+ }
+ }
+
+ fn get_layout_values(mode: &LayoutMode) -> (f64, f64, f64) {
+ match mode {
+ LayoutMode::Default => (1.0, 1.0, 1.0),
+ LayoutMode::CameraOnly => (1.0, 1.0, 1.0),
+ LayoutMode::HideCamera => (0.0, 1.0, 1.0),
+ }
+ }
+
+ fn lerp(start: f64, end: f64, t: f64) -> f64 {
+ start + (end - start) * t
+ }
+
+ pub fn should_render_camera(&self) -> bool {
+ self.camera_opacity > 0.01
+ }
+
+ pub fn should_render_screen(&self) -> bool {
+ true
+ }
+
+ pub fn is_transitioning_camera_only(&self) -> bool {
+ matches!(self.from_mode, LayoutMode::CameraOnly)
+ || matches!(self.to_mode, LayoutMode::CameraOnly)
+ }
+
+ pub fn camera_only_transition_opacity(&self) -> f64 {
+ if matches!(self.from_mode, LayoutMode::CameraOnly)
+ && !matches!(self.to_mode, LayoutMode::CameraOnly)
+ {
+ 1.0 - self.transition_progress
+ } else if !matches!(self.from_mode, LayoutMode::CameraOnly)
+ && matches!(self.to_mode, LayoutMode::CameraOnly)
+ {
+ self.transition_progress
+ } else if matches!(self.from_mode, LayoutMode::CameraOnly)
+ && matches!(self.to_mode, LayoutMode::CameraOnly)
+ {
+ 1.0
+ } else {
+ 0.0
+ }
+ }
+
+ pub fn regular_camera_transition_opacity(&self) -> f64 {
+ if matches!(self.to_mode, LayoutMode::CameraOnly)
+ && !matches!(self.from_mode, LayoutMode::CameraOnly)
+ {
+ let fast_fade = (1.0 - self.transition_progress * 1.5).max(0.0);
+ fast_fade * self.camera_opacity
+ } else if matches!(self.from_mode, LayoutMode::CameraOnly)
+ && !matches!(self.to_mode, LayoutMode::CameraOnly)
+ {
+ let fast_fade = (self.transition_progress * 1.5).min(1.0);
+ fast_fade * self.camera_opacity
+ } else if matches!(self.from_mode, LayoutMode::CameraOnly)
+ && matches!(self.to_mode, LayoutMode::CameraOnly)
+ {
+ 0.0
+ } else {
+ self.camera_opacity
+ }
+ }
+}
diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rs
index cbae60a986b..2e539a319dc 100644
--- a/crates/rendering/src/lib.rs
+++ b/crates/rendering/src/lib.rs
@@ -26,6 +26,7 @@ mod cursor_interpolation;
pub mod decoder;
mod frame_pipeline;
mod layers;
+mod layout;
mod project_recordings;
mod spring_mass_damper;
mod zoom;
@@ -35,6 +36,7 @@ pub use decoder::DecodedFrame;
pub use frame_pipeline::RenderedFrame;
pub use project_recordings::{ProjectRecordingsMeta, SegmentRecordings};
+use layout::*;
use zoom::*;
const STANDARD_CURSOR_HEIGHT: f32 = 75.0;
@@ -192,7 +194,6 @@ pub async fn render_video_to_channel(
let start_time = Instant::now();
- // Get the duration from the timeline if it exists, otherwise use the longest source duration
let duration = get_duration(recordings, recording_meta, meta, project);
let total_frames = (fps as f64 * duration).ceil() as u32;
@@ -216,7 +217,6 @@ pub async fn render_video_to_channel(
let segment = &segments[segment_i as usize];
- // do this after all usages but before any 'continue' to handle frame skip
let frame_number = {
let prev = frame_number;
std::mem::replace(&mut frame_number, prev + 1)
@@ -266,7 +266,6 @@ pub fn get_duration(
) -> f64 {
let mut max_duration = recordings.duration();
- // Check camera duration if it exists
if let Some(camera_path) = meta.camera_path()
&& let Ok(camera_duration) =
recordings.get_source_duration(&recording_meta.path(&camera_path))
@@ -276,18 +275,7 @@ pub fn get_duration(
println!("New max duration after camera check: {max_duration}");
}
- // If there's a timeline, ensure all segments extend to the max duration
if let Some(timeline) = &project.timeline {
- // for (i, segment) in timeline.segments.iter().enumerate() {
- // println!(
- // "Segment {} - current end: {}, max_duration: {}",
- // i, segment.end, max_duration
- // );
- // if segment.end < max_duration {
- // segment.end = max_duration;
- // println!("Extended segment {} to new end: {}", i, segment.end);
- // }
- // }
timeline.duration()
} else {
println!("No timeline found, using max_duration: {max_duration}");
@@ -353,9 +341,11 @@ pub struct ProjectUniforms {
pub cursor_size: f32,
display: CompositeVideoFrameUniforms,
camera: Option,
+ camera_only: Option,
interpolated_cursor: Option,
pub project: ProjectConfiguration,
pub zoom: InterpolatedZoom,
+ pub layout: InterpolatedLayout,
pub resolution_base: XY,
}
@@ -458,8 +448,6 @@ impl ProjectUniforms {
let scaled_width = ((base_width as f32 * scale) as u32 + 1) & !1;
let scaled_height = ((base_height as f32 * scale) as u32 + 1) & !1;
(scaled_width, scaled_height)
-
- // ((base_width + 1) & !1, (base_height + 1) & !1)
}
pub fn display_offset(
@@ -491,7 +479,6 @@ impl ProjectUniforms {
f64::max(output_size.x, output_size.y) * padding_factor
};
- // let padding = Self::get_padding(options, project);
let is_height_constrained = cropped_aspect <= output_aspect;
let available_size = output_size - 2.0 * padding;
@@ -578,6 +565,15 @@ impl ProjectUniforms {
.unwrap_or_else(|| Coord::new(XY::new(0.5, 0.5))),
);
+ let layout = InterpolatedLayout::new(LayoutSegmentsCursor::new(
+ frame_time as f64,
+ project
+ .timeline
+ .as_ref()
+ .map(|t| t.layout_segments.as_slice())
+ .unwrap_or(&[]),
+ ));
+
let display = {
let output_size = XY::new(output_size.0 as f64, output_size.1 as f64);
let size = [options.screen_size.x as f32, options.screen_size.y as f32];
@@ -621,7 +617,7 @@ impl ProjectUniforms {
rounding_px: (project.background.rounding / 100.0 * 0.5 * min_target_axis) as f32,
mirror_x: 0.0,
velocity_uv: velocity,
- motion_blur_amount,
+ motion_blur_amount: (motion_blur_amount + layout.screen_blur as f32 * 0.8).min(1.0),
camera_motion_blur_amount: 0.0,
shadow: project.background.shadow,
shadow_size: project
@@ -639,19 +635,19 @@ impl ProjectUniforms {
.advanced_shadow
.as_ref()
.map_or(50.0, |s| s.blur),
+ opacity: layout.screen_opacity as f32,
_padding: [0.0; 3],
}
};
let camera = options
.camera_size
- .filter(|_| !project.camera.hide)
+ .filter(|_| !project.camera.hide && layout.should_render_camera())
.map(|camera_size| {
let output_size = [output_size.0 as f32, output_size.1 as f32];
let frame_size = [camera_size.x as f32, camera_size.y as f32];
let min_axis = output_size[0].min(output_size[1]);
- // Calculate camera size based on zoom
let base_size = project.camera.size / 100.0;
let zoom_size = project
.camera
@@ -662,6 +658,8 @@ impl ProjectUniforms {
let zoomed_size =
(zoom.t as f32) * zoom_size * base_size + (1.0 - zoom.t as f32) * base_size;
+ let zoomed_size = zoomed_size * layout.camera_scale as f32;
+
let aspect = frame_size[0] / frame_size[1];
let size = match project.camera.shape {
CameraShape::Source => {
@@ -704,21 +702,22 @@ impl ProjectUniforms {
position[1] + size[1],
];
- // Calculate camera motion blur based on zoom transition
let camera_motion_blur = 0.0;
+ let crop_bounds = match project.camera.shape {
+ CameraShape::Source => [0.0, 0.0, frame_size[0], frame_size[1]],
+ CameraShape::Square => [
+ (frame_size[0] - frame_size[1]) / 2.0,
+ 0.0,
+ frame_size[0] - (frame_size[0] - frame_size[1]) / 2.0,
+ frame_size[1],
+ ],
+ };
+
CompositeVideoFrameUniforms {
output_size,
frame_size,
- crop_bounds: match project.camera.shape {
- CameraShape::Source => [0.0, 0.0, frame_size[0], frame_size[1]],
- CameraShape::Square => [
- (frame_size[0] - frame_size[1]) / 2.0,
- 0.0,
- frame_size[0] - (frame_size[0] - frame_size[1]) / 2.0,
- frame_size[1],
- ],
- },
+ crop_bounds,
target_bounds,
target_size: [
target_bounds[2] - target_bounds[0],
@@ -745,6 +744,70 @@ impl ProjectUniforms {
.advanced_shadow
.as_ref()
.map_or(50.0, |s| s.blur),
+ opacity: layout.regular_camera_transition_opacity() as f32,
+ _padding: [0.0; 3],
+ }
+ });
+
+ let camera_only = options
+ .camera_size
+ .filter(|_| !project.camera.hide && layout.is_transitioning_camera_only())
+ .map(|camera_size| {
+ let output_size = [output_size.0 as f32, output_size.1 as f32];
+ let frame_size = [camera_size.x as f32, camera_size.y as f32];
+
+ let aspect = frame_size[0] / frame_size[1];
+ let output_aspect = output_size[0] / output_size[1];
+
+ let zoom_factor = layout.camera_only_zoom as f32;
+ let size = [output_size[0] * zoom_factor, output_size[1] * zoom_factor];
+
+ let position = [
+ (output_size[0] - size[0]) / 2.0,
+ (output_size[1] - size[1]) / 2.0,
+ ];
+
+ let target_bounds = [
+ position[0],
+ position[1],
+ position[0] + size[0],
+ position[1] + size[1],
+ ];
+
+ // In camera-only mode, we ignore the camera shape setting (Square/Source)
+ // and just apply the minimum crop needed to fill the output aspect ratio.
+ // This prevents excessive zooming when shape is set to Square.
+ let crop_bounds = if aspect > output_aspect {
+ // Camera is wider than output - crop left and right
+ let visible_width = frame_size[1] * output_aspect;
+ let crop_x = (frame_size[0] - visible_width) / 2.0;
+ [crop_x, 0.0, frame_size[0] - crop_x, frame_size[1]]
+ } else {
+ // Camera is taller than output - crop top and bottom
+ let visible_height = frame_size[0] / output_aspect;
+ let crop_y = (frame_size[1] - visible_height) / 2.0;
+ [0.0, crop_y, frame_size[0], frame_size[1] - crop_y]
+ };
+
+ CompositeVideoFrameUniforms {
+ output_size,
+ frame_size,
+ crop_bounds,
+ target_bounds,
+ target_size: [
+ target_bounds[2] - target_bounds[0],
+ target_bounds[3] - target_bounds[1],
+ ],
+ rounding_px: 0.0,
+ mirror_x: if project.camera.mirror { 1.0 } else { 0.0 },
+ velocity_uv: [0.0, 0.0],
+ motion_blur_amount: 0.0,
+ camera_motion_blur_amount: layout.camera_only_blur as f32 * 0.5,
+ shadow: 0.0,
+ shadow_size: 0.0,
+ shadow_opacity: 0.0,
+ shadow_blur: 0.0,
+ opacity: layout.camera_only_transition_opacity() as f32,
_padding: [0.0; 3],
}
});
@@ -755,8 +818,10 @@ impl ProjectUniforms {
resolution_base,
display,
camera,
+ camera_only,
project: project.clone(),
zoom,
+ layout,
interpolated_cursor,
}
}
@@ -821,6 +886,7 @@ pub struct RendererLayers {
display: DisplayLayer,
cursor: CursorLayer,
camera: CameraLayer,
+ camera_only: CameraLayer,
#[allow(unused)]
captions: CaptionsLayer,
}
@@ -833,6 +899,7 @@ impl RendererLayers {
display: DisplayLayer::new(device),
cursor: CursorLayer::new(device),
camera: CameraLayer::new(device),
+ camera_only: CameraLayer::new(device),
captions: CaptionsLayer::new(device, queue),
}
}
@@ -885,14 +952,17 @@ impl RendererLayers {
})(),
);
- // if let Some(captions) = &uniforms.project.captions {
- // self.captions.prepare(
- // uniforms,
- // segment_frames,
- // uniforms.resolution_base,
- // constants,
- // );
- // }
+ self.camera_only.prepare(
+ &constants.device,
+ &constants.queue,
+ (|| {
+ Some((
+ uniforms.camera_only?,
+ constants.options.camera_size?,
+ segment_frames.camera_frame.as_ref()?,
+ ))
+ })(),
+ );
Ok(())
}
@@ -902,6 +972,7 @@ impl RendererLayers {
device: &wgpu::Device,
encoder: &mut wgpu::CommandEncoder,
session: &mut RenderSession,
+ uniforms: &ProjectUniforms,
) {
macro_rules! render_pass {
($view:expr, $load:expr) => {
@@ -909,7 +980,6 @@ impl RendererLayers {
label: Some("Render Pass"),
color_attachments: &[Some(wgpu::RenderPassColorAttachment {
view: $view,
- // depth_slice: None,
resolve_target: None,
ops: wgpu::Operations {
load: $load,
@@ -939,25 +1009,29 @@ impl RendererLayers {
session.swap_textures();
}
- {
+ if uniforms.layout.should_render_screen() {
let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);
self.display.render(&mut pass);
}
- {
+ if uniforms.layout.should_render_screen() {
let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);
self.cursor.render(&mut pass);
}
+ // Render camera-only layer when transitioning with CameraOnly mode
+ if uniforms.layout.is_transitioning_camera_only() {
+ let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);
+ self.camera_only.render(&mut pass);
+ }
+
+ // Also render regular camera overlay during transitions when its opacity > 0
+ if uniforms.layout.should_render_camera()
+ && uniforms.layout.regular_camera_transition_opacity() > 0.01
{
let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);
self.camera.render(&mut pass);
}
-
- // {
- // let mut pass = render_pass!(session.current_texture_view(), wgpu::LoadOp::Load);
- // self.captions.render(&mut pass);
- // }
}
}
@@ -1056,8 +1130,6 @@ impl RenderSession {
}
}
-// TODO: reuse as many resources as possible
-// https://github.com/gfx-rs/wgpu/wiki/Encapsulating-Graphics-Work
async fn produce_frame(
constants: &RenderVideoConstants,
segment_frames: DecodedSegmentFrames,
@@ -1076,7 +1148,7 @@ async fn produce_frame(
}),
);
- layers.render(&constants.device, &mut encoder, session);
+ layers.render(&constants.device, &mut encoder, session, &uniforms);
finish_encoder(
session,
@@ -1088,26 +1160,21 @@ async fn produce_frame(
.await
}
-// Helper function to parse color components from hex strings
fn parse_color_component(hex_color: &str, index: usize) -> f32 {
- // Remove # prefix if present
let color = hex_color.trim_start_matches('#');
- // Parse the color component
if color.len() == 6 {
- // Standard hex color #RRGGBB
let start = index * 2;
if let Ok(value) = u8::from_str_radix(&color[start..start + 2], 16) {
return value as f32 / 255.0;
}
}
- // Default fallback values
match index {
- 0 => 1.0, // Red default
- 1 => 1.0, // Green default
- 2 => 1.0, // Blue default
- _ => 1.0, // Alpha default
+ 0 => 1.0,
+ 1 => 1.0,
+ 2 => 1.0,
+ _ => 1.0,
}
}
@@ -1177,7 +1244,3 @@ fn srgb_to_linear(c: u16) -> f32 {
((c + 0.055) / 1.055).powf(2.4)
}
}
-
-// fn get_either((a, b): (T, T), left: bool) -> T {
-// if left { a } else { b }
-// }
diff --git a/crates/rendering/src/shaders/composite-video-frame.wgsl b/crates/rendering/src/shaders/composite-video-frame.wgsl
index 2f76e3c120f..4f47f4fb1d2 100644
--- a/crates/rendering/src/shaders/composite-video-frame.wgsl
+++ b/crates/rendering/src/shaders/composite-video-frame.wgsl
@@ -13,6 +13,7 @@ struct Uniforms {
shadow_size: f32,
shadow_opacity: f32,
shadow_blur: f32,
+ opacity: f32,
};
@group(0) @binding(0) var uniforms: Uniforms;
@@ -96,6 +97,7 @@ fn fs_main(@builtin(position) frag_coord: vec4) -> @location(0) vec4 {
var base_color = sample_texture(target_uv, crop_bounds_uv);
base_color = apply_rounded_corners(base_color, target_uv);
+ base_color.a = base_color.a * uniforms.opacity;
let blur_amount = select(uniforms.motion_blur_amount, uniforms.camera_motion_blur_amount, uniforms.camera_motion_blur_amount > 0.0);
diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.ts
index 7c165f2b98f..844138e5ca6 100644
--- a/packages/ui-solid/src/auto-imports.d.ts
+++ b/packages/ui-solid/src/auto-imports.d.ts
@@ -69,9 +69,11 @@ declare global {
const IconLucideDatabase: typeof import("~icons/lucide/database.jsx")["default"];
const IconLucideEdit: typeof import("~icons/lucide/edit.jsx")["default"];
const IconLucideEye: typeof import("~icons/lucide/eye.jsx")["default"];
+ const IconLucideEyeOff: typeof import("~icons/lucide/eye-off.jsx")["default"];
const IconLucideFolder: typeof import("~icons/lucide/folder.jsx")["default"];
const IconLucideGift: typeof import("~icons/lucide/gift.jsx")["default"];
const IconLucideHardDrive: typeof import("~icons/lucide/hard-drive.jsx")["default"];
+ const IconLucideLayout: typeof import("~icons/lucide/layout.jsx")["default"];
const IconLucideLoaderCircle: typeof import("~icons/lucide/loader-circle.jsx")["default"];
const IconLucideMessageSquarePlus: typeof import("~icons/lucide/message-square-plus.jsx")["default"];
const IconLucideMicOff: typeof import("~icons/lucide/mic-off.jsx")["default"];