Skip to content

feat(blur): blur only the background and give the outline a smooth, tight edge - #2

Merged
MiloszFilimowski merged 4 commits into
mainfrom
feat/blur-edge-quality
Sep 10, 2026
Merged

MiloszFilimowski merged 4 commits into
mainfrom
feat/blur-edge-quality

Conversation

@MiloszFilimowski

@MiloszFilimowski MiloszFilimowski commented Sep 10, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes the "scattered" look of background blur: a halo of the person's colours around the outline, a blocky stair-stepped edge, and sharp background left next to the person. Same GPU cost as before.

Changes (shared core, so native and web both get them)

  1. Blur only the background. The first rung of the blur ladder is a masked downsample: every tap is weighted by its background share and the weight travels in alpha; the composite divides it back out. The person's colours no longer bleed into the blurred background, which is what showed as a halo.
  2. Smooth, tight outline. The mask is eroded by 4 px, then averaged over a small diamond so the model's coarse steps become a soft ramp, with a wider feather (0.2) and a slightly higher threshold (0.6). The sharp area hugs the body.
  3. No colour-guided mask upsampling. That guidance pulled similar-coloured background next to the person (a door frame next to the ear, for instance) into the mask and left it sharp. It is off now.
  4. Outline weight computed once per frame. The erosion and smoothing run in one half-resolution single-channel pass; the blur and the composite read it with a single tap each.

Measured

Web, Chrome on an Apple GPU, minimal-react against a sandbox room, 1280×720, camera-capped at 24 fps. GPU time is the full effect per frame (segmentation, blur, composite):

0.1.1 this PR
GPU per frame, median 4.2 ms 4.3 ms
GPU per frame, 95th pct 6.6 ms 6.6 ms
Main thread per frame 0.43 ms 0.25 ms

Background sharpness (edge energy at 1/10 resolution) drops from about 40 to 22 while the person columns stay unchanged; no WebGPU errors. Close-ups show a smooth outline with no halo and the door frame blurred up to the hair.

Not run on a phone this round (no device at hand); the change is in the shared core with no platform-specific code.

Version bump left out on purpose; release as 0.1.2 when you want.

https://claude.ai/code/session_01FWRoR5MneE6GE9crQ9tF6W

The first blur rung keeps the person out of the blurred background, so the
outline no longer carries a halo of the person's colours. The mask is eroded
before compositing, so the sharp area hugs the body.
Average the eroded mask over a small diamond so the model's coarse steps
become a soft ramp, widen the feather and raise the threshold so the sharp
area hugs the body, and stop the mask upsampler from following camera
colours: that guidance pulled similar-coloured background next to the
person into the mask.
The erosion and smoothing taps now run in one half-resolution pass into an
r8 texture; the masked downsample and the composite read it with a single
tap each. Same output, and the frame's GPU time is back to what it was
before the outline work.
@MiloszFilimowski
MiloszFilimowski merged commit a6c5a14 into main Sep 10, 2026
1 check passed
@MiloszFilimowski
MiloszFilimowski deleted the feat/blur-edge-quality branch September 10, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant