Skip to content

sparse strips: Fix erf calculation, fixing blurred rectangles with very small/zero blur#1422

Merged
tomcur merged 3 commits into
linebender:mainfrom
tomcur:blurred-rounded-rect-zero
Feb 6, 2026
Merged

sparse strips: Fix erf calculation, fixing blurred rectangles with very small/zero blur#1422
tomcur merged 3 commits into
linebender:mainfrom
tomcur:blurred-rounded-rect-zero

Conversation

@tomcur
Copy link
Copy Markdown
Member

@tomcur tomcur commented Feb 5, 2026

This fixes #1406.

The issue there is not incorrect blending, but rather that blurred rounded rectangles with a small or zero blur standard deviation cause calculations to overflow the max finite values an f32 can represent. This causes them to punch a transparent hole instead.

Specifically, the issue is in our erf calculation. We can clamp the input without any loss of information: erf(x) quickly approaches 1 as x grows (-1 for negative values), and at erf(10) the result is approximately 1 well within even f64 precision, let alone f32. Our implementation calculates erf(+/- 10) gracefully in f32.

Copy link
Copy Markdown
Member Author

@tomcur tomcur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First commit adds tests, second commit adds the fix. Note the tests fail in the first commit.

@tomcur tomcur added bug Something isn't working C-cpu Applies to the vello_cpu crate C-sparse-strips Applies to sparse strips variants of vello in general labels Feb 5, 2026
Copy link
Copy Markdown
Collaborator

@LaurenzV LaurenzV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I have the maths knowledge to properly evaluate this, but since it fixes the issue LGTM. 👍

@tomcur tomcur changed the title sparse strips: Fix erf7 calculation, fixing blurred rectangles with very small/zero blur sparse strips: Fix erf calculation, fixing blurred rectangles with very small/zero blur Feb 6, 2026
@tomcur tomcur force-pushed the blurred-rounded-rect-zero branch from 1b18765 to 1d96223 Compare February 6, 2026 15:39
@tomcur tomcur enabled auto-merge February 6, 2026 15:40
@tomcur tomcur added this pull request to the merge queue Feb 6, 2026
Merged via the queue into linebender:main with commit e55ddd8 Feb 6, 2026
17 checks passed
@tomcur tomcur deleted the blurred-rounded-rect-zero branch February 6, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working C-cpu Applies to the vello_cpu crate C-sparse-strips Applies to sparse strips variants of vello in general

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Sparse Strips] Incorrect blending?

2 participants