forked from 1b-agent/opencadstudio-upstream
perf(hatch): tessellate fills so navigation no longer flickers (#258)
The batched hatch pass drew a screen-covering AABB quad per hatch and, for every fragment, ran a point-in-polygon ray-cast over the whole boundary plus the pattern test, with a discard that disabled early-Z. Zoomed into a hatch the quad covers the screen, so the shader re-ran per pixel every frame — the cost the PR #273 interaction-LOD worked around by suppressing hatches during navigation, which made fills flicker on and off while zooming. Triangulate each boundary once (lyon, even-odd — same coverage as the old in_polygon, islands/holes included) and rasterize those triangles instead: no screen-filling overdraw, no per-fragment boundary test. The fragment shader keeps the boundary test only on a per-instance fallback path (poly_test == 1) for boundaries that fail to tessellate. Tessellation is cached with the batch build (geometry_epoch) in local space, so the double-single relative-to-eye precision is preserved. With the fast path the interaction-LOD is no longer needed; it is gated behind OCS_HATCH_LOD (default off) as a safety net for now.
This commit is contained in:
1 parent
fd0b8fc1d4
commit
b4152ae1fe
6 files changed
+236
-58
No files matched your search
@@ -1198,6 +1198,16 @@ impl Scene {
|
||||
.map_or(false, |t| t.elapsed().as_millis() < Self::NAV_SETTLE_MS)
|
||||
}
|
||||
|
||||
/// Whether the interaction-LOD hatch suppression is enabled (env
|
||||
/// `OCS_HATCH_LOD`), read once. Default OFF: the tessellated hatch pass is
|
||||
/// cheap enough that suppression — and its zoom flicker (#258) — is not
|
||||
/// needed. Kept behind the flag as a safety net for pathological drawings.
|
||||
pub fn hatch_lod_enabled(&self) -> bool {
|
||||
use std::sync::OnceLock;
|
||||
static ON: OnceLock<bool> = OnceLock::new();
|
||||
*ON.get_or_init(|| std::env::var_os("OCS_HATCH_LOD").is_some())
|
||||
}
|
||||
|
||||
/// True for a short window around navigation — used by the subscription to
|
||||
/// keep requesting frames just past the settle point so the one full-quality
|
||||
/// (hatched) frame actually renders after the cursor stops, even when no
|
||||
|
||||
Reference in new issue
Block a user