forked from 1b-agent/opencadstudio-upstream
fix(renderer): keep draw-order offsets within clipping planes
This commit is contained in:
1 parent
0e42e3bf28
commit
e52e565b1f
26 files changed
+525
-90
No files matched your search
@@ -67,11 +67,6 @@ struct InstanceIn {
|
||||
@location(12) marker_normal_scale: vec4<f32>,
|
||||
}
|
||||
|
||||
// Draw-order depth bias: shifts clip-space z so 2D entities of different
|
||||
// types order against each other through the shared LessEqual depth test.
|
||||
// draw_depth is signed (-1,1): front → positive → smaller z → drawn on top;
|
||||
// 0.0 = neutral (real depth). Depth32Float gives ample precision.
|
||||
const DRAW_ORDER_BIAS: f32 = 0.001;
|
||||
const MODEL_LINEWEIGHT_BOOST: f32 = 2.0;
|
||||
const MODEL_LINEWEIGHT_MAX_PX: f32 = 10.0;
|
||||
|
||||
@@ -199,7 +194,7 @@ fn marker_relative(position_high: vec3<f32>, position_low: vec3<f32>, instance:
|
||||
let pos_rel = mix(rel_a, rel_b, which_end);
|
||||
let world_pos = pos_rel + perp_world * (eff_hw * side);
|
||||
var clip_pos = u.view_rot * vec4<f32>(world_pos, 1.0);
|
||||
clip_pos.z = clip_pos.z - in.misc.x * DRAW_ORDER_BIAS * clip_pos.w;
|
||||
clip_pos = apply_draw_order(clip_pos, in.misc.x);
|
||||
|
||||
final_clip = clip_pos;
|
||||
out_dist = mix(in.dists.x, in.dists.y, which_end);
|
||||
@@ -233,7 +228,7 @@ fn marker_relative(position_high: vec3<f32>, position_low: vec3<f32>, instance:
|
||||
let offset_px = perp * hw * side + dir * hw * ext;
|
||||
let ndc_offset = offset_px / (u.viewport_size * 0.5);
|
||||
var clip_pos_out = clip_pos + vec4<f32>(ndc_offset * clip_pos.w, 0.0, 0.0);
|
||||
clip_pos_out.z = clip_pos_out.z - in.misc.x * DRAW_ORDER_BIAS * clip_pos_out.w;
|
||||
clip_pos_out = apply_draw_order(clip_pos_out, in.misc.x);
|
||||
|
||||
final_clip = clip_pos_out;
|
||||
out_dist = mix(in.dists.x, in.dists.y, which_end) + ext * hw * u.world_per_pixel;
|
||||
|
||||
Reference in new issue
Block a user