From f72852e94b64440328eb92152a67ed90ed0cb65a Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Thu, 23 Jul 2026 07:23:10 +0300 Subject: [PATCH] fix(hatch): radial gradient stops run outside-in SPHERICAL/HEMISPHERICAL gradients painted colour 1 at the centre; AutoCAD's convention is colour 1 at the rim and colour 2 at the centre (the INV variants swap them back). Both the native and the WebGL2 shader now mix the radial branch outside-in; linear/cylinder/curved are untouched. Co-Authored-By: Claude Fable 5 --- src/shaders/hatch.wgsl | 5 ++++- src/shaders/hatch_web.wgsl | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/shaders/hatch.wgsl b/src/shaders/hatch.wgsl index 21898c6e6..18de5e863 100644 --- a/src/shaders/hatch.wgsl +++ b/src/shaders/hatch.wgsl @@ -313,7 +313,10 @@ fn check_family( if (inst.grad_kind & 16u) != 0u { t = 1.0 - t; } - return mix(inst.color, inst.color2, t); + // Radial stops run OUTSIDE-IN: colour 1 at the rim, colour 2 at the + // centre (AutoCAD's SPHERICAL/HEMISPHERICAL convention; the INV bit + // above swaps them back). + return mix(inst.color2, inst.color, t); } // 3. Pattern LOD: when the densest family's spacing projects below diff --git a/src/shaders/hatch_web.wgsl b/src/shaders/hatch_web.wgsl index 644cd1181..33a474e8e 100644 --- a/src/shaders/hatch_web.wgsl +++ b/src/shaders/hatch_web.wgsl @@ -268,7 +268,8 @@ fn check_family( if ginv { t = 1.0 - t; } - return mix(h.color, h.color2, t); + // Radial stops run outside-in (colour 2 at the centre) — see hatch.wgsl. + return mix(h.color2, h.color, t); } // Pattern LOD: when the densest family projects below 2 px, lines blur into