forked from 1b-agent/opencadstudio-upstream
DRAWORDER now affects rendering immediately (bump geometry epoch so the sort cache rebuilds) and front/back anchor to the block's full effective sort range instead of only existing table entries, so bring-to-front actually lands on top. The render fallback sorts table-absent entities by their own handle. Draw order now applies across entity types, not just within a type. A per-entity draw-order rank (SortEntitiesTable override or own handle, ranked per block) is encoded as a small signed clip-z bias in the wire, hatch, image, and 3DFACE pipelines. The shared LessEqual depth buffer then orders fills, lines, rasters and 2D solids against each other regardless of pass order — without touching model coordinates. 3D meshes keep real geometric depth; wipeouts stay always-on-top. Adds a Draw Order submenu to the viewport context menu (Bring to Front, Send to Back, Bring Above/Send Under Object). The above/under items run an interactive reference-object pick, then reorder the captured selection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.1 KiB
WebGPU Shading Language
44 lines
1.1 KiB
WebGPU Shading Language
// Face3D shader — flat-shaded triangle fill for DXF 3DFACE entities.
|
|
//
|
|
// Vertex layout (28 bytes):
|
|
// position [f32; 3] offset 0 12 B
|
|
// color [f32; 4] offset 12 16 B
|
|
|
|
struct Uniforms {
|
|
view_proj: mat4x4<f32>,
|
|
viewport: vec2<f32>,
|
|
_pad: vec2<f32>,
|
|
};
|
|
|
|
@group(0) @binding(0)
|
|
var<uniform> u: Uniforms;
|
|
|
|
struct VertexIn {
|
|
@location(0) position: vec3<f32>,
|
|
@location(1) color: vec4<f32>,
|
|
@location(2) draw_depth: f32,
|
|
};
|
|
|
|
struct VertexOut {
|
|
@builtin(position) clip_pos: vec4<f32>,
|
|
@location(0) color: vec4<f32>,
|
|
};
|
|
|
|
// Draw-order depth bias (see wire.wgsl). Signed draw_depth; 0.0 (3D mesh
|
|
// faces) leaves real depth untouched; 2D fills / 3DFACE quads order by rank.
|
|
const DRAW_ORDER_BIAS: f32 = 0.001;
|
|
|
|
@vertex
|
|
fn vs_main(v: VertexIn) -> VertexOut {
|
|
var out: VertexOut;
|
|
out.clip_pos = u.view_proj * vec4<f32>(v.position, 1.0);
|
|
out.clip_pos.z = out.clip_pos.z - v.draw_depth * DRAW_ORDER_BIAS * out.clip_pos.w;
|
|
out.color = v.color;
|
|
return out;
|
|
}
|
|
|
|
@fragment
|
|
fn fs_main(in: VertexOut) -> @location(0) vec4<f32> {
|
|
return in.color;
|
|
}
|