Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Prevent glyphs from bleeding into neighbours in atlas #1014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Mar 5, 2025
Merged

Conversation

almarklein
Copy link
Member

@almarklein almarklein commented Mar 4, 2025

... and a few other improvements to the text shader

Alternative to #1001

  • Update the text shader to constrain the texcoord to be within the glyphs own patch.
  • Also deal with the sdf's edge-pixels being nonzero, preventing (more) artifacts in outlines.
  • This update also reduces the chance on rarer differences due to lower precision in varyings (from experience I know that the precision of varyings is less than 32 bits).
  • Tweak smoothness factor for aa a bit.
  • Don't diminish alpha for text that is "unreadably small".
  • Instead render such text as little blobs, and at smaller text sizes.

@almarklein
Copy link
Member Author

I saw a call to clamp() in the shader that looked wrong. Upon further investigation, it turns out that you can interchange clamp(x, min_val, max_val) with clamp(min_val, x, max_val) 🤯 I will still update the call though ...

@almarklein
Copy link
Member Author

There's a few odd effects I'm looking into while i'm here:

Weird ghosting of the glyph bg when using outline:
image

Weird outline edges. Their shape looks like they might be sampling from neighbouring glyph, but that does not seem to be it:
image

Text becomes near-transparent from far off. This effect was added deliberately, but happens a bit too early. It starts at a scale when the text is still readable:
image

@almarklein
Copy link
Member Author

Tiny text better visible:
image

No background, no odd shapes on edges:

image

pygfx/renderers/wgpu/wgsl/text.wgsl Outdated Show resolved Hide resolved
@almarklein almarklein marked this pull request as ready for review March 5, 2025 11:03
@Korijn Korijn enabled auto-merge (squash) March 5, 2025 11:53
@Korijn Korijn merged commit 99e1e84 into main Mar 5, 2025
14 checks passed
@Korijn Korijn deleted the text-bleed branch March 5, 2025 12:01
@@ -148,7 +148,7 @@ def test_examples_compare(filename, pytestconfig, force_offscreen, mock_time):
stored_img = iio.imread(screenshot_path)

# assert similarity
atol = 2
atol = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

wow. i somewhat don't believe this.....

i was seeing variations in the middle of the k .... i guess your changes made it more stable for "small font" which I think we were always operating in that limit.

Copy link
Contributor

Choose a reason for hiding this comment

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

The file validate_blend_dither.png lost the word "dither" at the very top.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry about that. The example changed, and I thought to just remove that text because the aa is dithered too. Thanks for bringing it back!

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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.