Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
docs(rendering): describe motion blur semantics in plain terms
Richie McIlroy022c2b802d77
diff --git a/crates/project/src/configuration.rs b/crates/project/src/configuration.rsindex 4e107005f..a519723fe 100644--- a/crates/project/src/configuration.rs+++ b/crates/project/src/configuration.rs@@ -2789,9 +2789,8 @@ impl ProjectConfiguration {}fn default_screen_motion_blur() -> f32 {- // Screen Studio's default blur amount is 1.0; with length-based blur- // semantics (amount scales the smear length, output fully blurred)- // 1.0 reproduces its out-of-the-box look.+ // With length-based blur semantics (amount scales the smear length,+ // output fully blurred) 1.0 gives the natural out-of-the-box look.1.0}@@ -4105,9 +4104,9 @@ mod tests {#[test]fn default_motion_blur_is_full() {- // 1.0 matches Screen Studio's default amount under length-based blur- // semantics; the two fields must agree because the editor drives them- // with one slider and load() re-couples them.+ // 1.0 is the natural default under length-based blur semantics; the+ // two fields must agree because the editor drives them with one+ // slider and load() re-couples them.let config = ProjectConfiguration::default();assert_eq!(config.cursor.motion_blur, 1.0);diff --git a/crates/rendering/src/layers/cursor.rs b/crates/rendering/src/layers/cursor.rsindex fce5bcd35..a2d16dd99 100644--- a/crates/rendering/src/layers/cursor.rs+++ b/crates/rendering/src/layers/cursor.rs@@ -17,7 +17,7 @@ const CLICK_SHRINK_SIZE: f32 = 0.8;const CURSOR_IDLE_MIN_DELAY_MS: f64 = 500.0;const CURSOR_IDLE_FADE_OUT_MS: f64 = 400.0;const CURSOR_IDLE_RESUME_LOOKAHEAD_MS: f64 = 250.0;-/// Smear length ceiling in output px. Screen Studio semantics: the smear+/// Smear length ceiling in output px. Length-based semantics: the smear/// length equals the cursor's per-frame travel scaled by the user amount —/// linear, with no response curve — so this only bounds pathological/// single-frame teleports, not real flicks (spring motion peaks well below@@ -490,7 +490,7 @@ impl CursorLayer {child_motion};- // Screen Studio semantics: smear length = per-frame travel x amount,+ // Length-based semantics: smear length = per-frame travel x amount,// linear all the way down (a sub-pixel kernel is the identity, so no// response ramp is needed to avoid popping).let scaled_motion = if cursor_strength > f32::EPSILON {@@ -1327,7 +1327,7 @@ mod tests {#[test]fn cursor_blur_vector_is_linear_in_travel_and_amount() {- // Screen Studio semantics: smear length == per-frame travel x amount,+ // Length-based semantics: smear length == per-frame travel x amount,// with no response curve shortening slow-to-medium motion.let motion = cursor_blur_vector(XY::new(40.0, -30.0), 0.5);assert!((motion.x - 20.0).abs() < 1e-4);diff --git a/crates/rendering/src/lib.rs b/crates/rendering/src/lib.rsindex 5330a8429..b17e25424 100644--- a/crates/rendering/src/lib.rs+++ b/crates/rendering/src/lib.rs@@ -2860,7 +2860,7 @@ fn clamp_vector(vec: XY<f32>, max_len: f32) -> XY<f32> {}}-/// Screen Studio blur semantics: the user amount scales the LENGTH of the+/// Length-based blur semantics: the user amount scales the LENGTH of the/// smear (linear in the per-frame delta, no response curve) and the shader/// outputs the fully blurred result — strength is a pure on/off gate, never a/// crossfade with the sharp frame. Per frame the dominant delta wins: a size@@ -3024,9 +3024,9 @@ fn notch_bounds(}const MOTION_BLUR_BASELINE_FPS: f32 = 60.0;-/// Velocity is measured strictly against the previous frame (Screen Studio-/// samples frame f vs f-1); averaging over more frames lags peaks and lets-/// blur linger after motion stops.+/// Velocity is measured strictly against the previous frame (frame f vs+/// f-1); averaging over more frames lags peaks and lets blur linger after+/// motion stops.const DISPLAY_MOTION_SAMPLE_FRAMES: u32 = 1;/// Skip blur when the per-frame delta is under ~1px — a sub-pixel kernel is/// visually the identity, so there is no pop at the boundary.@@ -5383,7 +5383,7 @@ mod tests {#[test]fn display_zoom_blur_is_symmetric_in_and_out() {- // Screen Studio treats zoom-in and zoom-out identically: the radial+ // Zoom-in and zoom-out are treated identically: the radial// amount is |1 - diag ratio| either way.let small = motion_bounds(XY::new(0.0, 0.0), XY::new(1920.0, 1080.0));let large = motion_bounds(XY::new(-960.0, -540.0), XY::new(2880.0, 1620.0));diff --git a/crates/rendering/src/shaders/composite-video-frame.wgsl b/crates/rendering/src/shaders/composite-video-frame.wgslindex cf6b0c01e..ec2e57b5a 100644--- a/crates/rendering/src/shaders/composite-video-frame.wgsl+++ b/crates/rendering/src/shaders/composite-video-frame.wgsl@@ -337,7 +337,7 @@ fn fs_main(@builtin(position) frag_coord: vec4<f32>) -> @location(0) vec4<f32> {return composite_source_over(apply_color_grade(base_color, target_uv, p), shadow_color);}- // Screen Studio semantics: the user amount is baked into the LENGTH of+ // Length-based semantics: the user amount is baked into the LENGTH of// the kernel (velocity vector / zoom ray) on the CPU side, and the output// is the fully blurred result — never a crossfade with the sharp frame// (a sharp copy mixed over a smear reads as ghosting, not motion). Alphadiff --git a/crates/rendering/src/shaders/cursor.wgsl b/crates/rendering/src/shaders/cursor.wgslindex 9f60d75a3..e7c2284d9 100644--- a/crates/rendering/src/shaders/cursor.wgsl+++ b/crates/rendering/src/shaders/cursor.wgsl@@ -30,7 +30,7 @@ var s_cursor: sampler;const MAX_ROTATION_RADIANS: f32 = 0.34906584;// Smear length ceiling in sprite-UV (1.0 = one cursor-sprite width). A fast// flick travels several sprite widths per frame, and the smear length must-// track it (Screen Studio semantics); this only bounds pathological+// track it (length-based semantics); this only bounds pathological// teleports. The vertex quad expands by the same vector, so the geometry// always contains the full streak.const MAX_CURSOR_BLUR_UV: f32 = 4.0;