Skip to content

Anti-alias wire edges and draw block wipeout frames above their mask - #3612

Merged
HakanSeven12 merged 2 commits into
HakanSeven12:mainfrom
insanedps:pr/wire-aa
Nov 24, 2026
Merged

HakanSeven12 merged 2 commits into
HakanSeven12:mainfrom
insanedps:pr/wire-aa

Conversation

@insanedps

Copy link
Copy Markdown
Contributor

Problem

Wire quads are hard-edged: thin wires are about 1 px wide and the fragment shaders only discard (dash gaps, round
caps). MSAA 4x smooths the quad edge in four steps at best, so lines at an angle look stair-stepped, and block-heavy
drawings (many small angled outlines) look noticeably rougher than in other CAD applications.

A second problem shows once the edges are smooth: a WIPEOUT inside a block drew its frame at the mask's own rank
(block_cache local rank d[0]; the top-level path already puts the frame half a rank above, depth_override 0.5).
The mask pass ties the depth test and erases part of the anti-aliased frame, and the outline drawn after it shows as
beads.

Fix

  1. Anti-alias wire edges (wire.wgsl, wire_indexed.wgsl, block_wire.wgsl, block_wire_storage.wgsl): the
    quad is padded one pixel past the stroke and the fragment alpha is multiplied by an analytic edge coverage,
    clamp(0.5 + (r - d) / px), with px the screen-space gradient of the across coordinate (DPI-independent). Round
    caps use the same distance. The coverage discard runs before the dash test. World-width bands keep their visible
    width. The pipelines already blend alpha.
  2. Block wipeout frames above their mask (block_cache.rs): wipeout members get d[0] + 0.5 * d[1], as at the
    top level.

Tests

  • Shader validation (naga) of the four changed shaders passes.
  • cargo test --lib: 7102 passed, 0 failed (46 ignored)

Manual check

  • A fan of thin lines at many angles (synthetic DXF): edges go from 4 shade steps to smooth gradients.
  • A block with a framed WIPEOUT over a polyline outline: cross-section coverage along the edge 0.28 before, 0.90
    after (the rest is the outline drawn over the frame).
  • Pan/zoom frame times unchanged in a release build. With smooth edges MSAA can be lowered (OCS_MSAA=1) for the
    same look and less VRAM.

insanedps and others added 2 commits November 24, 2026 21:19
Wire quads were hard-edged (about 1 px for thin wires), so angled lines
stair-stepped. Pad the quad one pixel past the stroke and fade the edge
pixels by coverage computed from the across coordinate and its screen
gradient; round caps use the same distance. World-width bands keep their
visible width. The coverage discard runs before the dash test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A wipeout frame inside a block took its mask's rank, so the mask pass tied
the depth test and erased part of the anti-aliased frame; the outline
drawn after it then showed as beads. It now sits half a rank above the
mask, as the top-level path already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HakanSeven12
HakanSeven12 merged commit 08bf0b4 into HakanSeven12:main Nov 24, 2026
6 checks passed
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.

2 participants