fix(render): correct lineweight display scaling

Remove the global display boost and scale paper-space lineweights with the current sheet zoom across wire, block-wire, and hatch paths.

Fixes #962
This commit is contained in:
Hakan Seven committed 2026-09-02 22:32:53 +03:00
1 parent 0f337db488
commit edbc4d8ff8
7 files changed
+34 -24

No files matched your search

+2 -2
View File
@@ -5,7 +5,7 @@ struct Uniforms {
flat_shade: f32,
transparency_enable: f32,
linetype_scale: f32,
_pad: f32,
lineweight_scale: f32,
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
@@ -67,7 +67,7 @@ fn resolve_hw(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
if world_hw > 0.0 {
return max(world_hw / u.world_per_pixel, 0.5);
}
return select(0.5, px_hw, u.lwdisplay_enable > 0.5);
return select(0.5, max(px_hw * u.lineweight_scale, 0.5), u.lwdisplay_enable > 0.5);
}
fn marker_relative(
+7 -2
View File
@@ -14,7 +14,8 @@ struct Uniforms {
lwdisplay_enable: f32,
flat_shade: f32,
transparency_enable: f32,
_pad: vec2<f32>,
_linetype_scale: f32,
lineweight_scale: f32,
// Relative-to-eye (double-single): see wire.wgsl.
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
@@ -162,7 +163,11 @@ fn check_family(
-ddx_xz.x * sin_a + ddx_xz.y * cos_a,
-ddy_xz.x * sin_a + ddy_xz.y * cos_a,
)) * 0.5;
let width_px = select(1.0, max(fam.line_width, 1.0), u.lwdisplay_enable > 0.5);
let width_px = select(
1.0,
max(fam.line_width * u.lineweight_scale, 1.0),
u.lwdisplay_enable > 0.5,
);
let half_line = half_px * width_px;
// World units per screen pixel on each axis — used to light exactly the
+7 -2
View File
@@ -13,7 +13,8 @@ struct Uniforms {
lwdisplay_enable: f32,
flat_shade: f32,
transparency_enable: f32,
_pad: vec2<f32>,
_linetype_scale: f32,
lineweight_scale: f32,
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
@@ -146,7 +147,11 @@ fn check_family(
-ddx_xz.x * sin_a + ddx_xz.y * cos_a,
-ddy_xz.x * sin_a + ddy_xz.y * cos_a,
)) * 0.5;
let width_px = select(1.0, max(fam.line_width, 1.0), u.lwdisplay_enable > 0.5);
let width_px = select(
1.0,
max(fam.line_width * u.lineweight_scale, 1.0),
u.lwdisplay_enable > 0.5,
);
let half_line = half_px * width_px;
let wpx = length(vec2<f32>(ddx_xz.x, ddy_xz.x));
+2 -2
View File
@@ -29,7 +29,7 @@ struct Uniforms {
// every line opaque.
transparency_enable: f32,
linetype_scale: f32,
_pad: f32,
lineweight_scale: f32,
// ── Relative-to-eye (double-single) ──────────────────────────────────
// view_rot is the rotation-only view-projection; vertices subtract the eye
// (eye_high + eye_low, two f32 emulating f64) before transforming, so the
@@ -102,7 +102,7 @@ struct VertexOut {
fn resolve_hw(taper: f32, world_hw: f32, px_hw: f32) -> f32 {
if taper > 0.0 { return max(taper / u.world_per_pixel, 0.5); }
if world_hw > 0.0 { return max(world_hw / u.world_per_pixel, 0.5); }
return select(0.5, px_hw, u.lwdisplay_enable > 0.5);
return select(0.5, max(px_hw * u.lineweight_scale, 0.5), u.lwdisplay_enable > 0.5);
}
fn marker_relative(position_high: vec3<f32>, position_low: vec3<f32>, instance: InstanceIn) -> vec3<f32> {
+2 -2
View File
@@ -12,7 +12,7 @@ struct Uniforms {
flat_shade: f32,
transparency_enable: f32,
linetype_scale: f32,
_pad: f32,
lineweight_scale: f32,
view_rot: mat4x4<f32>,
eye_high: vec3<f32>,
_pad_eh: f32,
@@ -81,7 +81,7 @@ fn resolve_hw(taper_ratio: f32, world_hw: f32, px_hw: f32) -> f32 {
return max((taper_ratio * world_hw) / u.world_per_pixel, 0.5);
}
if world_hw > 0.0 { return max(world_hw / u.world_per_pixel, 0.5); }
return select(0.5, px_hw, u.lwdisplay_enable > 0.5);
return select(0.5, max(px_hw * u.lineweight_scale, 0.5), u.lwdisplay_enable > 0.5);
}
fn marker_relative(position_high: vec3<f32>, position_low: vec3<f32>, c: WireConst) -> vec3<f32> {