Skip to content

fix: bordered shaders precision with asymmetric borders#21

Merged
chiefcll merged 1 commit into
mainfrom
fix/bordered-shaders-precision
May 19, 2026
Merged

fix: bordered shaders precision with asymmetric borders#21
chiefcll merged 1 commit into
mainfrom
fix/bordered-shaders-precision

Conversation

@chiefcll
Copy link
Copy Markdown
Contributor

Summary

  • Ports upstream lightning-js/renderer#751 ("fix drawing precision when using asym borders", merged 2026-03-09) to the three local WebGL bordered shaders.
  • Replaces the direct unpack of u_borderWidth.xyzw with vec4 adjustedBorderWidth = u_borderWidth - 1.0 + clamp(u_borderWidth, -1.0, 1.0) before splitting into top/right/bottom/left.

Why

The asymmetric border math (borderRight - borderLeft, borderBottom - borderTop) was losing precision for sub-pixel borders and zero-on-one-side cases. The clamp-based adjustment keeps values >= 1 unchanged but shifts the diff math so asymmetric borders render correctly.

Files

  • src/core/shaders/webgl/Border.ts
  • src/core/shaders/webgl/RoundedWithBorder.ts
  • src/core/shaders/webgl/RoundedWithBorderAndShadow.ts

Test plan

  • pnpm build passes
  • Visually verify asymmetric borders (e.g. borderTop: 4, borderBottom: 0) render with correct edges
  • Visually verify standard uniform borders (>= 1px) are unchanged
  • pnpm test:visual — review any diffs in border-related snapshots

🤖 Generated with Claude Code

Port upstream lightning-js/renderer#751: adjust u_borderWidth via
`u_borderWidth - 1.0 + clamp(u_borderWidth, -1.0, 1.0)` so asymmetric
border-diff math (borderRight - borderLeft, etc.) renders correctly
for sub-pixel and zero-on-one-side cases. Values >= 1 are unchanged.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@chiefcll chiefcll merged commit 7a86e33 into main May 19, 2026
1 check passed
@chiefcll chiefcll deleted the fix/bordered-shaders-precision branch May 19, 2026 16:31
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