Skip to content

fix(compositor): high-quality motion blur (cursor & screen) and gaussian webcam blur #606

Description

@EtienneLescot

Context & Problem Description

Users reported severe quality degradation when using motion blur and webcam background blur:

  1. Cursor Motion Blur: When cursor motion blur is enabled, moving the cursor produces a trail of disconnected ghost replicas (multi-exposure stepped ghosts, e.g. 👆 👆 👆 👆) rather than a smooth directional smear. Additionally, the active cursor head becomes faint and washed out.
  2. General Screen / Camera Motion Blur: The \effects.motionBlur\ slider only scales the number of taps (\mb_taps\ 1..16) but does not scale the displacement vector (\duv), which always spans 100% of 1 full frame. Consequently, at low slider settings (e.g. 0.2), the shader samples a large 1-frame movement with only 4 discrete taps, creating visible quadruple ghost images.
  3. Webcam Background Blur (Segmentation): The \�lur_webcam_bg\ shader function uses a 5x5 Cartesian grid with up to 14px step size and an inverse-distance weight (\1 / (1 + r)). This results in harsh grid/cross artifacts, dithering, and 25 discrete pinhole dots on point lights instead of a soft Gaussian bokeh.

Root Cause Analysis

  • Cursor:
    • \ rail_frames\ in \ rame_geometry.rs\ and \compositor_windows.rs\ is set to \1.0 + blur01 * 7.0\ (spanning up to 8 frames / ~266ms into the past).
    • \ aps\ is capped at 11, resulting in 10-30px gaps between discrete cursor quads.
    • Uniform tap weighting (\1 / taps) reduces current cursor opacity to ~9%.
    • \compositor_windows.rs\ duplicates \plan_cursor\ inline rather than sharing \ rame_geometry::plan_cursor.
  • General Motion Blur:
    • \mb_taps = 1.0 + motion_blur * 15.0, but \duv = uv_now - uv_prev\ is always full frame displacement. The slider acts as sample count rather than shutter angle/duration.
  • Webcam Background Blur:
    • 25 unrolled taps on a coarse grid with large spacing and non-Gaussian falloff.

Objectives & Requirements

  1. Cursor Motion Blur:
    • Limit temporal window to single-frame shutter duration (\shutter_dt <= 1.0 / FPS).
    • Adaptive or sufficiently dense sampling so consecutive taps overlap continuously.
    • Front-weighting (falloff from current cursor to past) so the cursor head remains sharp and visible.
    • Unify Windows, macOS, and Linux backends via \ rame_geometry::plan_cursor.
  2. General Motion Blur:
    • Scale blur vector by \effects.motionBlur\ (shutter angle).
    • Trailing sampling ending at \uv_now.
    • Smooth reconstruction without ghosting at low slider values.
  3. Webcam Segmentation Blur:
    • Replace 5x5 Cartesian grid with true Gaussian disc/spiral sampling (Vogel spiral / multi-ring) with Gaussian weights (e^{-r^2 / 2\sigma^2}) and high-frequency dither (Interleaved Gradient Noise).
    • Keep tap budget <= 20-24 taps for maximum efficiency on integrated GPUs.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions