forked from 1b-agent/opencadstudio-upstream
fix(render): don't apply the draw-order z-bias to 3D mesh outline edges
Mesh (PolyfaceMesh / PolygonMesh) outline edges are drawn through the wire pipeline, whose shader pulls each wire toward the camera by draw_depth * DRAW_ORDER_BIAS (0.001) for 2-D draw-order layering. Every entity gets a draw_depth in [-1, 1], so a mesh's edges were pulled forward too — and when the mesh's depth extent projects to less than the bias (a small or distant mesh), its hidden back-face edges peeked through its own shaded fill. Solid feature edges use the mesh shader, which has no such bias, which is why only meshes showed it and why adjusting the fill's depth bias had no effect. 3-D mesh outline edges are real geometry occluded by true depth, so force their draw_depth to 0 (they are already grouped as `mesh_edge` in upload_wires). They now occlude exactly like solid edges. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
23d9a261b1
commit
17077ba8bf
1 file changed
+10
-2
@@ -441,7 +441,12 @@ impl WireGpu {
|
||||
.par_iter()
|
||||
.enumerate()
|
||||
.map(|(idx, w)| {
|
||||
emit_wire_native(w, idx as u32, w.color, wire_draw_depth(w, depth_map))
|
||||
// 3D mesh outline edges are real geometry occluded by true
|
||||
// depth — they must NOT take the draw-order z-bias (which
|
||||
// pulls 2D wires toward the camera), or the hidden edges of a
|
||||
// small / distant mesh peek through its own shaded fill.
|
||||
let dd = if mesh_edge { 0.0 } else { wire_draw_depth(w, depth_map) };
|
||||
emit_wire_native(w, idx as u32, w.color, dd)
|
||||
})
|
||||
.collect();
|
||||
let mut instances: Vec<WireInstance> =
|
||||
@@ -474,7 +479,10 @@ impl WireGpu {
|
||||
let _ = const_bgl;
|
||||
let per: Vec<Vec<WireInstance>> = wires
|
||||
.iter()
|
||||
.map(|w| emit_wire_instances(w, w.color, wire_draw_depth(w, depth_map)))
|
||||
.map(|w| {
|
||||
let dd = if mesh_edge { 0.0 } else { wire_draw_depth(w, depth_map) };
|
||||
emit_wire_instances(w, w.color, dd)
|
||||
})
|
||||
.collect();
|
||||
let mut instances: Vec<WireInstance> =
|
||||
Vec::with_capacity(per.iter().map(Vec::len).sum());
|
||||
|
||||
Reference in new issue
Block a user