fix: increase bounded screen draw-order depth resolution for overlapping block wipeouts

This commit is contained in:
gianlucafiore committed 2026-10-12 18:07:48 -03:00
1 parent 93a54d66e3
commit 1074c81f52
1 file changed
+8 -9
+8 -9
View File
@@ -1,13 +1,12 @@
// Positive order draws in front; zero retains geometric depth. Keep the usual // Positive draw order moves geometry towards the camera. In dense blocks,
// 0.001 NDC offset away from the clipping planes, but reduce it near either // child ranks occupy a narrow fraction of the INSERT depth band: a 0.001
// plane: perspective depth can be much closer to 1 than this fixed offset. // NDC bias can quantize two overlapping lines/masks to the same depth value,
// // especially after changing view/zoom. Use a wider, yet bounded range for
// Using order / (1 + abs(order)) for the limited region keeps ordering monotonic // CAD 2D draw order. Limit displacement to less than half the available
// (including the paper background's -2). Less than half the remaining depth is // clip-space room, so we never push valid geometry across near/far planes.
// consumed, so valid vertices stay valid. Out-of-range/behind-eye vertices get // This is a screen-only GPU change; PDF order uses its own stable sorting.
// no offset and remain subject to the real near/far clipping planes.
fn apply_draw_order(clip: vec4<f32>, order: f32) -> vec4<f32> { fn apply_draw_order(clip: vec4<f32>, order: f32) -> vec4<f32> {
let room = 0.5 * max(0.0, min(clip.z, clip.w - clip.z)); let room = 0.5 * max(0.0, min(clip.z, clip.w - clip.z));
let scale = min(0.001 * max(clip.w, 0.0), room / (1.0 + abs(order))); let scale = min(0.02 * max(clip.w, 0.0), room / (1.0 + abs(order)));
return vec4<f32>(clip.xy, clip.z - order * scale, clip.w); return vec4<f32>(clip.xy, clip.z - order * scale, clip.w);
} }