Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
feat: render cursor styles and click ripples
Richie McIlroyba7cf2e8e7db
diff --git a/crates/rendering/src/layers/click_ripple.rs b/crates/rendering/src/layers/click_ripple.rsnew file mode 100644index 000000000..d7e03c7ca--- /dev/null+++ b/crates/rendering/src/layers/click_ripple.rs@@ -0,0 +1,266 @@+use bytemuck::{Pod, Zeroable};+use cap_project::XY;+use wgpu::{include_wgsl, util::DeviceExt};++use super::cursor::{CursorPlacement, cursor_height_px};+use crate::{Coord, FrameSpace, ProjectUniforms, RenderVideoConstants, zoom::InterpolatedZoom};++/// Ripples older than this are dropped rather than queued, so a burst of+/// clicks can never grow the uniform buffer.+pub const MAX_CLICK_RIPPLES: usize = 6;++/// Ring radius relative to the un-shrunk cursor height.+const RIPPLE_RADIUS_SCALE: f32 = 1.25;++/// Quad half-extent in ring radii. The ring's outer feather reaches+/// `r + w` = 1.16 radii at the end of the animation, so a quad of exactly+/// `2R` clips the last frames of the expansion into a squircle.+const RIPPLE_QUAD_EXTENT: f32 = 1.3;++/// Dynamic-offset slots must be `min_uniform_buffer_offset_alignment` apart;+/// 256 is the widest alignment any backend asks for.+const SLOT_SIZE: u64 = 256;++pub struct ClickRippleLayer {+ statics: Statics,+ bind_group: wgpu::BindGroup,+ instance_count: u32,+}++struct Statics {+ uniform_buffer: wgpu::Buffer,+ bind_group_layout: wgpu::BindGroupLayout,+ render_pipeline: wgpu::RenderPipeline,+}++impl Statics {+ fn new(device: &wgpu::Device) -> Self {+ let bind_group_layout = device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {+ label: Some("Click Ripple Bind Group Layout"),+ entries: &[wgpu::BindGroupLayoutEntry {+ binding: 0,+ visibility: wgpu::ShaderStages::VERTEX_FRAGMENT,+ ty: wgpu::BindingType::Buffer {+ ty: wgpu::BufferBindingType::Uniform,+ has_dynamic_offset: true,+ min_binding_size: wgpu::BufferSize::new(+ std::mem::size_of::<ClickRippleUniforms>() as u64,+ ),+ },+ count: None,+ }],+ });++ let shader = device.create_shader_module(include_wgsl!("../shaders/click-ripple.wgsl"));++ let render_pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {+ label: Some("Click Ripple Pipeline"),+ layout: Some(+ &device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {+ label: Some("Click Ripple Pipeline Layout"),+ bind_group_layouts: &[&bind_group_layout],+ push_constant_ranges: &[],+ }),+ ),+ vertex: wgpu::VertexState {+ module: &shader,+ entry_point: Some("vs_main"),+ buffers: &[],+ compilation_options: wgpu::PipelineCompilationOptions {+ constants: &[],+ zero_initialize_workgroup_memory: false,+ },+ },+ fragment: Some(wgpu::FragmentState {+ module: &shader,+ entry_point: Some("fs_main"),+ targets: &[Some(wgpu::ColorTargetState {+ format: wgpu::TextureFormat::Rgba8Unorm,+ blend: Some(wgpu::BlendState {+ color: wgpu::BlendComponent {+ src_factor: wgpu::BlendFactor::One,+ dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,+ operation: wgpu::BlendOperation::Add,+ },+ alpha: wgpu::BlendComponent {+ src_factor: wgpu::BlendFactor::One,+ dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha,+ operation: wgpu::BlendOperation::Add,+ },+ }),+ write_mask: wgpu::ColorWrites::ALL,+ })],+ compilation_options: wgpu::PipelineCompilationOptions {+ constants: &[],+ zero_initialize_workgroup_memory: false,+ },+ }),+ primitive: wgpu::PrimitiveState {+ topology: wgpu::PrimitiveTopology::TriangleStrip,+ strip_index_format: None,+ front_face: wgpu::FrontFace::Ccw,+ cull_mode: None,+ unclipped_depth: false,+ polygon_mode: wgpu::PolygonMode::Fill,+ conservative: false,+ },+ depth_stencil: None,+ multisample: wgpu::MultisampleState::default(),+ multiview: None,+ cache: None,+ });++ Self {+ bind_group_layout,+ render_pipeline,+ uniform_buffer: device.create_buffer_init(&wgpu::util::BufferInitDescriptor {+ label: Some("Click Ripple Uniform Buffer"),+ contents: &[0u8; MAX_CLICK_RIPPLES * SLOT_SIZE as usize],+ usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,+ }),+ }+ }+}++impl ClickRippleLayer {+ pub fn new(device: &wgpu::Device) -> Self {+ let statics = Statics::new(device);+ let bind_group = device.create_bind_group(&wgpu::BindGroupDescriptor {+ layout: &statics.bind_group_layout,+ entries: &[wgpu::BindGroupEntry {+ binding: 0,+ resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {+ buffer: &statics.uniform_buffer,+ offset: 0,+ size: wgpu::BufferSize::new(std::mem::size_of::<ClickRippleUniforms>() as u64),+ }),+ }],+ label: Some("Click Ripple Bind Group"),+ });++ Self {+ statics,+ bind_group,+ instance_count: 0,+ }+ }++ pub fn prepare(+ &mut self,+ uniforms: &ProjectUniforms,+ resolution_base: XY<u32>,+ zoom: &InterpolatedZoom,+ constants: &RenderVideoConstants,+ ) {+ self.instance_count = 0;++ if uniforms.click_ripples.is_empty() {+ return;+ }++ let ripple = &uniforms.project.cursor.ripple;+ let color = [+ ripple.color[0] as f32 / 255.0,+ ripple.color[1] as f32 / 255.0,+ ripple.color[2] as f32 / 255.0,+ ripple.strength_clamped(),+ ];++ let crop = ProjectUniforms::get_crop(&constants.options, &uniforms.project);+ let display_size =+ ProjectUniforms::display_size(&constants.options, &uniforms.project, resolution_base);+ let radius = cursor_height_px(+ constants.options.screen_size.y as f32,+ crop.size.y as f32,+ display_size.y as f32,+ uniforms.cursor_size,+ 1.0,+ ) * RIPPLE_RADIUS_SCALE+ * ripple.size_clamped();++ if !radius.is_finite() || radius <= 0.0 {+ return;+ }++ let quad_side = (radius * 2.0 * RIPPLE_QUAD_EXTENT) as f64;+ let size = Coord::<FrameSpace>::new(XY::new(quad_side, quad_side));+ let hotspot = XY::new(0.5, 0.5);+ let placement = CursorPlacement {+ constants,+ uniforms,+ resolution_base,+ zoom,+ };++ let mut slots = [0u8; MAX_CLICK_RIPPLES * SLOT_SIZE as usize];+ let mut count = 0usize;++ for click_ripple in uniforms.click_ripples.iter().take(MAX_CLICK_RIPPLES) {+ let position_uv = click_ripple.position.coord;+ if !position_uv.x.is_finite() || !position_uv.y.is_finite() {+ continue;+ }++ let (position_size, opacity) = placement.map(position_uv, size, hotspot, 1.0);+ if !position_size.iter().all(|v| v.is_finite()) {+ continue;+ }++ let slot = ClickRippleUniforms {+ position_size,+ output_size: [+ uniforms.output_size.0 as f32,+ uniforms.output_size.1 as f32,+ 0.0,+ 0.0,+ ],+ screen_bounds: uniforms.display.target_bounds,+ color,+ params: [+ click_ripple.progress.clamp(0.0, 1.0),+ opacity,+ RIPPLE_QUAD_EXTENT,+ 0.0,+ ],+ };++ let offset = count * SLOT_SIZE as usize;+ slots[offset..offset + std::mem::size_of::<ClickRippleUniforms>()]+ .copy_from_slice(bytemuck::bytes_of(&slot));+ count += 1;+ }++ if count == 0 {+ return;+ }++ constants.queue.write_buffer(+ &self.statics.uniform_buffer,+ 0,+ &slots[..count * SLOT_SIZE as usize],+ );+ self.instance_count = count as u32;+ }++ pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {+ if self.instance_count == 0 {+ return;+ }++ pass.set_pipeline(&self.statics.render_pipeline);+ for i in 0..self.instance_count {+ pass.set_bind_group(0, &self.bind_group, &[i * SLOT_SIZE as u32]);+ pass.draw(0..4, 0..1);+ }+ }+}++#[repr(C)]+#[derive(Debug, Clone, Copy, Pod, Zeroable, Default)]+struct ClickRippleUniforms {+ position_size: [f32; 4],+ output_size: [f32; 4],+ screen_bounds: [f32; 4],+ color: [f32; 4],+ params: [f32; 4],+}diff --git a/crates/rendering/src/layers/cursor.rs b/crates/rendering/src/layers/cursor.rsindex 148b3cfa0..715c16efe 100644--- a/crates/rendering/src/layers/cursor.rs+++ b/crates/rendering/src/layers/cursor.rs@@ -7,8 +7,9 @@ use tracing::error;use wgpu::{BindGroup, FilterMode, include_wgsl, util::DeviceExt};use crate::{- Coord, DecodedSegmentFrames, FrameSpace, ProjectUniforms, RenderVideoConstants,- STANDARD_CURSOR_HEIGHT, composite_frame::ColorGradeUniformParams, zoom::InterpolatedZoom,+ Coord, DecodedSegmentFrames, FrameSpace, ProjectUniforms, RawDisplayUVSpace,+ RenderVideoConstants, STANDARD_CURSOR_HEIGHT, composite_frame::ColorGradeUniformParams,+ zoom::InterpolatedZoom,};const CURSOR_CLICK_DURATION: f64 = 0.13;@@ -272,10 +273,11 @@ impl CursorLayer {constants: &RenderVideoConstants,cursor_id: &str,use_svg: bool,+ cursor_type: &CursorType,) -> Option<CursorTexture> {let mut loaded_cursor = None;- let cursor_shape = match &constants.recording_meta.inner {+ let recorded_shape = match &constants.recording_meta.inner {RecordingMetaInner::Studio(studio) => match studio.as_ref() {StudioRecordingMeta::MultipleSegments {inner:@@ -289,6 +291,20 @@ impl CursorLayer {_ => None,};+ // An explicit family cross-maps the recorded shape into it (and+ // stands in with its arrow for recordings that carry no shape info at+ // all, e.g. Linux PNG-only captures), so SVG assets are the only+ // possible source and `use_svg` no longer applies.+ let (cursor_shape, use_svg) = match cursor_type.family() {+ Some(family) => (+ Some(+ recorded_shape.map_or_else(|| family.arrow(), |shape| shape.in_family(family)),+ ),+ true,+ ),+ None => (recorded_shape, use_svg),+ };+if let Some(cursor_shape) = cursor_shape&& use_svg&& let Some(info) = cursor_shape.resolve()@@ -315,7 +331,12 @@ impl CursorLayer {loaded_cursor}- fn preload_cursor_textures(&mut self, constants: &RenderVideoConstants, use_svg: bool) {+ fn preload_cursor_textures(+ &mut self,+ constants: &RenderVideoConstants,+ use_svg: bool,+ cursor_type: &CursorType,+ ) {let StudioRecordingMeta::MultipleSegments { inner, .. } = &constants.meta else {return;};@@ -326,7 +347,8 @@ impl CursorLayer {for cursor_id in cursors.keys() {if !self.cursors.contains_key(cursor_id)- && let Some(texture) = Self::load_cursor_texture(constants, cursor_id, use_svg)+ && let Some(texture) =+ Self::load_cursor_texture(constants, cursor_id, use_svg, cursor_type){self.cursors.insert(cursor_id.clone(), texture);}@@ -349,7 +371,7 @@ impl CursorLayer {}self.prev_is_svg_assets_enabled = Some(use_svg);- self.preload_cursor_textures(constants, use_svg);+ self.preload_cursor_textures(constants, use_svg, cursor_type);self.cursor_assets_preloaded = true;}@@ -440,9 +462,13 @@ impl CursorLayer {let cursor_type = uniforms.project.cursor.cursor_type().clone();+ // The family a cursor id resolves to is baked into its texture, so a+ // type change has to evict every cached sprite, not just the circle.if self.prev_cursor_type.as_ref() != Some(&cursor_type) {self.prev_cursor_type = Some(cursor_type.clone());self.circle_cursor = None;+ self.cursors.clear();+ self.cursor_assets_preloaded = false;}if self.prev_is_svg_assets_enabled != Some(uniforms.project.cursor.use_svg) {@@ -458,7 +484,11 @@ impl CursorLayer {self.circle_cursor.as_ref().unwrap()} else {if !self.cursor_assets_preloaded {- self.preload_cursor_textures(constants, uniforms.project.cursor.use_svg);+ self.preload_cursor_textures(+ constants,+ uniforms.project.cursor.use_svg,+ &cursor_type,+ );self.cursor_assets_preloaded = true;}if !self.cursors.contains_key(&interpolated_cursor.cursor_id)@@ -466,6 +496,7 @@ impl CursorLayer {constants,&interpolated_cursor.cursor_id,uniforms.project.cursor.use_svg,+ &cursor_type,){self.cursors@@ -511,28 +542,118 @@ impl CursorLayer {})};- let hotspot = Coord::<FrameSpace>::new(size.coord * cursor_texture.hotspot);-- // Calculate position without hotspot first- let position = interpolated_cursor.position.to_frame_space(- &constants.options,- &uniforms.project,+ let (position_size, cursor_opacity) = CursorPlacement {+ constants,+ uniforms,resolution_base,+ zoom,+ }+ .map(+ interpolated_cursor.position.coord,+ size,+ cursor_texture.hotspot,+ cursor_opacity,+ );++ let cursor_grade = if uniforms.project.color_correction.grade_cursor {+ uniforms.screen_color_grade+ } else {+ ColorGradeUniformParams::IDENTITY+ };++ let cursor_uniforms = CursorUniforms {+ position_size,+ output_size: [+ uniforms.output_size.0 as f32,+ uniforms.output_size.1 as f32,+ 0.0,+ 0.0,+ ],+ screen_bounds: uniforms.display.target_bounds,+ motion_vector_strength: [+ scaled_motion.x,+ scaled_motion.y,+ // Pure on/off gate: the amount is baked into the smear+ // length (scaled_motion), never an opacity mix.+ if cursor_strength > f32::EPSILON {+ 1.0+ } else {+ 0.0+ },+ cursor_opacity,+ ],+ rotation_params: [+ 0.0,+ uniforms.project.cursor.base_rotation,+ uniforms.cursor_x_axis_tilt_radians,+ 0.0,+ ],+ color_adjust_a: cursor_grade.color_adjust_a,+ color_adjust_b: cursor_grade.color_adjust_b,+ grain_params: cursor_grade.grain_params,+ };++ constants.queue.write_buffer(+ &self.statics.uniform_buffer,+ 0,+ bytemuck::cast_slice(&[cursor_uniforms]),+ );++ self.bind_group = Some(+ self.statics+ .create_bind_group(&constants.device, &cursor_texture.texture),+ );+ }++ pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {+ if let Some(bind_group) = &self.bind_group {+ pass.set_pipeline(&self.statics.render_pipeline);+ pass.set_bind_group(0, bind_group, &[]);+ pass.draw(0..4, 0..1);+ }+ }+}++/// The cursor sprite's output-rect chain: frame space minus hotspot -> zoomed+/// frame space -> split-screen pane remap -> text-takeover affine. The click+/// ripple has to land in exactly the same place as the sprite it sits under,+/// so both go through here.+pub(crate) struct CursorPlacement<'a> {+ pub constants: &'a RenderVideoConstants,+ pub uniforms: &'a ProjectUniforms,+ pub resolution_base: XY<u32>,+ pub zoom: &'a InterpolatedZoom,+}++impl CursorPlacement<'_> {+ pub(crate) fn map(+ &self,+ position_uv: XY<f64>,+ size: Coord<FrameSpace>,+ hotspot_frac: XY<f64>,+ opacity: f32,+ ) -> ([f32; 4], f32) {+ let hotspot = Coord::<FrameSpace>::new(size.coord * hotspot_frac);++ let position = Coord::<RawDisplayUVSpace>::new(position_uv).to_frame_space(+ &self.constants.options,+ &self.uniforms.project,+ self.resolution_base,) - hotspot;// Transform to zoomed spacelet zoomed_position = position.to_zoomed_frame_space(- &constants.options,- &uniforms.project,- resolution_base,- zoom,+ &self.constants.options,+ &self.uniforms.project,+ self.resolution_base,+ self.zoom,);let zoomed_size = (position + size).to_zoomed_frame_space(- &constants.options,- &uniforms.project,- resolution_base,- zoom,+ &self.constants.options,+ &self.uniforms.project,+ self.resolution_base,+ self.zoom,) - zoomed_position;// In split-screen the screen only occupies a half-rect, so remap the@@ -541,14 +662,15 @@ impl CursorLayer {// same factor. The cursor shader's screen_bounds clip already follows// uniforms.display.target_bounds (the morphing half), so a cursor that// lands outside the visible crop is confined automatically.- let position_size = match &uniforms.split {+ let position_size = match &self.uniforms.split {Some(split) if split.factor > 0.001 => {- let screen_size = constants.options.screen_size;- let crop = ProjectUniforms::get_crop(&constants.options, &uniforms.project);+ let screen_size = self.constants.options.screen_size;+ let crop =+ ProjectUniforms::get_crop(&self.constants.options, &self.uniforms.project);let display_size = ProjectUniforms::display_size(- &constants.options,- &uniforms.project,- resolution_base,+ &self.constants.options,+ &self.uniforms.project,+ self.resolution_base,);let scrop = split.screen.crop;@@ -559,8 +681,8 @@ impl CursorLayer {let target_h = starget[3] - starget[1];let cursor_px = [- cursor_uv.x as f32 * screen_size.x as f32,- cursor_uv.y as f32 * screen_size.y as f32,+ position_uv.x as f32 * screen_size.x as f32,+ position_uv.y as f32 * screen_size.y as f32,];let tip = [starget[0] + (cursor_px[0] - scrop[0]) / crop_w * target_w,@@ -598,7 +720,7 @@ impl CursorLayer {// translate (the takeover target preserves the card's aspect), so the// cursor follows with the same affine map — and fades with the card// when a Fullscreen takeover hides it.- let (position_size, cursor_opacity) = match &uniforms.takeover {+ let (position_size, opacity) = match &self.uniforms.takeover {Some(takeover) if takeover.t > 0.001 => {let from_w = (takeover.from[2] - takeover.from[0]).max(f32::EPSILON);let scale = (takeover.to[2] - takeover.to[0]) / from_w;@@ -616,68 +738,12 @@ impl CursorLayer {crate::lerp_f32(position_size[2], mapped[2], t),crate::lerp_f32(position_size[3], mapped[3], t),],- cursor_opacity * takeover.overlay_fade,+ opacity * takeover.overlay_fade,)}- _ => (position_size, cursor_opacity),- };-- let cursor_grade = if uniforms.project.color_correction.grade_cursor {- uniforms.screen_color_grade- } else {- ColorGradeUniformParams::IDENTITY+ _ => (position_size, opacity),};-- let cursor_uniforms = CursorUniforms {- position_size,- output_size: [- uniforms.output_size.0 as f32,- uniforms.output_size.1 as f32,- 0.0,- 0.0,- ],- screen_bounds: uniforms.display.target_bounds,- motion_vector_strength: [- scaled_motion.x,- scaled_motion.y,- // Pure on/off gate: the amount is baked into the smear- // length (scaled_motion), never an opacity mix.- if cursor_strength > f32::EPSILON {- 1.0- } else {- 0.0- },- cursor_opacity,- ],- rotation_params: [- 0.0,- uniforms.project.cursor.base_rotation,- uniforms.cursor_x_axis_tilt_radians,- 0.0,- ],- color_adjust_a: cursor_grade.color_adjust_a,- color_adjust_b: cursor_grade.color_adjust_b,- grain_params: cursor_grade.grain_params,- };-- constants.queue.write_buffer(- &self.statics.uniform_buffer,- 0,- bytemuck::cast_slice(&[cursor_uniforms]),- );-- self.bind_group = Some(- self.statics- .create_bind_group(&constants.device, &cursor_texture.texture),- );- }-- pub fn render(&self, pass: &mut wgpu::RenderPass<'_>) {- if let Some(bind_group) = &self.bind_group {- pass.set_pipeline(&self.statics.render_pipeline);- pass.set_bind_group(0, bind_group, &[]);- pass.draw(0..4, 0..1);- }+ (position_size, opacity)}}@@ -699,7 +765,7 @@ fn composite_cursor_layer(dst: &mut [f32; 4], src: [f32; 4]) {dst[3] = out_a;}-fn cursor_height_px(+pub(crate) fn cursor_height_px(source_screen_height: f32,crop_height: f32,display_frame_height: f32,diff --git a/crates/rendering/src/layers/mod.rs b/crates/rendering/src/layers/mod.rsindex 5571e2faf..6de28b939 100644--- a/crates/rendering/src/layers/mod.rs+++ b/crates/rendering/src/layers/mod.rs@@ -4,6 +4,7 @@ mod blur;mod camera;mod camera3d;mod captions;+mod click_ripple;mod color_grade;mod cursor;mod display;@@ -70,6 +71,7 @@ pub use blur::*;pub use camera::*;pub use camera3d::*;pub use captions::*;+pub use click_ripple::*;pub use color_grade::*;pub use cursor::*;pub use display::*;diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex f9f752eb8..d7a1c1799 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -20,8 +20,8 @@ use frame_pipeline::{use futures::future::OptionFuture;use layers::{Background, BackgroundLayer, BlurLayer, Camera3DBlurKind, Camera3DLayer, CameraLayer,- CaptionsLayer, ColorGradeLayer, CursorLayer, DisplayLayer, FrameLayer, KeyboardLayer,- MaskLayer, NotchLayer, NotchUniforms, TextLayer,+ CaptionsLayer, ClickRippleLayer, ColorGradeLayer, CursorLayer, DisplayLayer, FrameLayer,+ KeyboardLayer, MaskLayer, NotchLayer, NotchUniforms, TextLayer,};use specta::Type;use spring_mass_damper::SpringMassDamperSimulationConfig;@@ -2355,6 +2355,14 @@ fn fit_crop_to_target([x0, y0, x0 + w, y0 + h]}+/// One in-flight click ripple: where the drawn cursor was when the button+/// went down, and how far through its animation it is.+#[derive(Clone, Debug)]+pub struct ClickRipple {+ pub position: Coord<RawDisplayUVSpace>,+ pub progress: f32,+}+#[derive(Clone, Debug)]pub struct ProjectUniforms {pub output_size: (u32, u32),@@ -2380,6 +2388,7 @@ pub struct ProjectUniforms {display_outer_bounds: [f32; 4],interpolated_cursor: Option<InterpolatedCursorPosition>,pub prev_cursor: Option<InterpolatedCursorPosition>,+ pub click_ripples: Vec<ClickRipple>,pub project: ProjectConfiguration,pub zoom: InterpolatedZoom,pub scene: InterpolatedScene,@@ -2401,6 +2410,48 @@ pub struct ProjectUniforms {pub camera3d_zoom: Option<camera3d::Camera3DScreenZoom>,}+/// Ripples for every mouse-down still inside its animation window, newest+/// last. The centre comes from the smoothed cursor path at the click's own+/// timestamp, so the ring sits under where the cursor was DRAWN rather than+/// where the raw sample was.+fn collect_click_ripples(+ project: &ProjectConfiguration,+ cursor_events: &CursorEvents,+ now_ms: f64,+ cursor_interp_fn: &dyn Fn(f32) -> Option<InterpolatedCursorPosition>,+) -> Vec<ClickRipple> {+ let ripple = &project.cursor.ripple;+ if project.cursor.hide || !ripple.enabled {+ return Vec::new();+ }++ let duration_ms = ripple.duration_clamped() as f64 * 1000.0;+ let mut ripples: Vec<ClickRipple> = cursor_events+ .clicks+ .iter()+ .filter(|click| click.down)+ .filter_map(|click| {+ let age_ms = now_ms - click.time_ms;+ if age_ms < 0.0 || age_ms >= duration_ms {+ return None;+ }++ let position = cursor_interp_fn((click.time_ms / 1000.0) as f32)?.position;++ Some(ClickRipple {+ position,+ progress: (age_ms / duration_ms) as f32,+ })+ })+ .collect();++ if ripples.len() > layers::MAX_CLICK_RIPPLES {+ ripples.drain(..ripples.len() - layers::MAX_CLICK_RIPPLES);+ }++ ripples+}+#[derive(Debug, Clone)]pub struct Zoom {pub amount: f64,@@ -3407,7 +3458,7 @@ impl ProjectUniforms {frame_number: u32,fps: u32,resolution_base: XY<u32>,- _cursor_events: &CursorEvents,+ cursor_events: &CursorEvents,segment_frames: &DecodedSegmentFrames,total_duration: f64,zoom_timeline: &ZoomTransformTimeline,@@ -3462,6 +3513,12 @@ impl ProjectUniforms {let interpolated_cursor = cursor_interp_fn(cursor_time_for_interp);let prev_interpolated_cursor = cursor_interp_fn(prev_cursor_time_for_interp);+ let click_ripples = collect_click_ripples(+ project,+ cursor_events,+ current_recording_time as f64 * 1000.0,+ cursor_interp_fn,+ );let lookback_t = (cursor_time_for_interp - 0.4).max(0.0);let past_cursor_for_tilt = cursor_interp_fn(lookback_t);@@ -4429,6 +4486,7 @@ impl ProjectUniforms {frame_number,recording_time: current_recording_time as f64,prev_cursor: prev_interpolated_cursor,+ click_ripples,display_parent_motion_px: display_motion_parent,motion_blur_amount: cursor_motion_blur,masks,@@ -5718,6 +5776,7 @@ pub struct RendererLayers {frame: FrameLayer,display: DisplayLayer,notch: NotchLayer,+ click_ripple: ClickRippleLayer,cursor: CursorLayer,camera: CameraLayer,camera_only: CameraLayer,@@ -5756,6 +5815,7 @@ impl RendererLayers {shared_composite_pipeline.clone(),prefer_cpu_conversion,),+ click_ripple: ClickRippleLayer::new(device),cursor: CursorLayer::new(device),camera: CameraLayer::new_with_all_shared_pipelines(device,@@ -5928,6 +5988,13 @@ impl RendererLayers {);}+ self.click_ripple.prepare(+ uniforms,+ uniforms.resolution_base,+ &uniforms.zoom,+ constants,+ );+self.cursor.prepare(segment_frames,uniforms.resolution_base,@@ -6083,6 +6150,12 @@ impl RendererLayers {timings.display_prepare_duration = start.elapsed();let start = Instant::now();+ self.click_ripple.prepare(+ uniforms,+ uniforms.resolution_base,+ &uniforms.zoom,+ constants,+ );self.cursor.prepare(segment_frames,uniforms.resolution_base,@@ -6301,6 +6374,7 @@ impl RendererLayers {if should_render_cursor {let mut pass = render_pass!(content_view!(), wgpu::LoadOp::Load);+ self.click_ripple.render(&mut pass);self.cursor.render(&mut pass);}diff --git a/crates/rendering/src/shaders/click-ripple.wgsl b/crates/rendering/src/shaders/click-ripple.wgslnew file mode 100644index 000000000..99af58b8c--- /dev/null+++ b/crates/rendering/src/shaders/click-ripple.wgsl@@ -0,0 +1,75 @@+struct VertexOutput {+ @builtin(position) position: vec4<f32>,+ @location(0) uv: vec2<f32>,+};++struct Uniforms {+ position_size: vec4<f32>,+ output_size: vec4<f32>,+ screen_bounds: vec4<f32>,+ // (r, g, b, strength).+ color: vec4<f32>,+ // (progress, opacity, quad half-extent in ring radii, unused).+ params: vec4<f32>,+};++@group(0) @binding(0)+var<uniform> uniforms: Uniforms;++@vertex+fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {+ var corners = array<vec2<f32>, 4>(+ vec2<f32>(0.0, 0.0),+ vec2<f32>(0.0, 1.0),+ vec2<f32>(1.0, 0.0),+ vec2<f32>(1.0, 1.0)+ );++ let local_uv = corners[vertex_index];+ let pos = vec2<f32>(local_uv.x, -local_uv.y);++ var adjusted_pos = uniforms.position_size.xy;+ adjusted_pos.y = uniforms.output_size.y - adjusted_pos.y;++ let final_pos = ((pos * uniforms.position_size.zw) + adjusted_pos)+ / uniforms.output_size.xy * 2.0 - 1.0;++ var output: VertexOutput;+ output.position = vec4<f32>(final_pos, 0.0, 1.0);+ output.uv = local_uv;+ return output;+}++// Same feathered display-card clip the cursor sprite uses, so a ripple whose+// click landed in a cropped-away region slides off the card edge instead of+// floating over the background.+fn screen_bounds_mask(frag_pos: vec2<f32>) -> f32 {+ let b = uniforms.screen_bounds;+ let inside = min(+ min(frag_pos.x - b.x, b.z - frag_pos.x),+ min(frag_pos.y - b.y, b.w - frag_pos.y),+ );+ return clamp(inside + 0.5, 0.0, 1.0);+}++@fragment+fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {+ let t = clamp(uniforms.params.x, 0.0, 1.0);+ let inv = 1.0 - t;++ // Distances are measured in ring radii, so R cancels out of the whole+ // profile below.+ let d = length(input.uv - vec2<f32>(0.5)) * 2.0 * uniforms.params.z;++ let r = 1.0 - inv * inv * inv;+ let w = 0.10 + 0.06 * t;++ let ring = 1.0 - smoothstep(0.0, w, abs(d - r));+ let fill = (1.0 - smoothstep(r - w, r, d)) * 0.30;++ var alpha = uniforms.color.a * pow(inv, 1.5) * (ring + fill);+ alpha *= uniforms.params.y * screen_bounds_mask(input.position.xy);+ alpha = clamp(alpha, 0.0, 1.0);++ return vec4<f32>(uniforms.color.rgb * alpha, alpha);+}