Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Document the float32 depth limit of reversed-Z far from the camera (closes #310)

Nguyen Xuan An98abfc80f994
diff --git a/changes/310-float32-limit.md b/changes/310-float32-limit.md
new file mode 100644
index 00000000..02a29e3b
--- /dev/null
+++ b/changes/310-float32-limit.md
@@ -0,0 +1 @@
+- Document the float32 depth limit of reversed-Z (closes #310): `docs/guide.md` gives the measured failure rates far from the camera (0.1 mm gap at 500 m: 6.9% of pixels; 1 mm at 500 m: 1.4%) and the workaround, a gap of at least 1 mm or `decal: true`. A split-float vertex path that would remove the limit is tracked separately.
diff --git a/docs/guide.md b/docs/guide.md
index 721eede5..baebf462 100644
--- a/docs/guide.md
+++ b/docs/guide.md
@@ -197,7 +197,7 @@ The `surfaces` mode finds triangle contact. The `closed-solids` mode also tests
An index also supports `raycast(matrix, ray)` for a triangle number, hit point and barycentric coordinates.
The [mesh query contract](https://github.com/codepawl/67.js/blob/main/docs/mesh-query.md) describes results, solid validation, numerical limits and budget errors.
Rebuild indices after geometry edits. Queries reject skin and morph channels.
-Contact results do not measure penetration depth or resolve collisions. Z-fighting has its own check: `renderer.diagnostics` and `scene_inspect` report `coplanar-overlap` for two parts that draw the same plane (within 1 mm, same facing, at least 1 cm2 shared). Fix it with `decal: true` on the smaller part (layer 1; `depthLayer` 0 to 4 orders stacked decals), or `environment.resolveCoplanar: 'offset'` to bias the smaller part of every flagged pair. Both draw with a scoped polygon offset in the colour pass and render passes, and never move geometry. Use a real offset along the normal when the gap should be visible in exports or the path tracer. The coplanar code is not in the core bundle: call `installCoplanarDiagnostics(renderer)` from `67js/addons/coplanar-overlap` to add the warning to `renderer.diagnostics` (checked once per layout), and `scene_inspect` shows it once `loadAllAgentSceneModules()` (or a recipe with `resolveCoplanar`) has loaded the code. Reversed-Z depth is not implemented yet (#310).
+Contact results do not measure penetration depth or resolve collisions. Z-fighting has its own check: `renderer.diagnostics` and `scene_inspect` report `coplanar-overlap` for two parts that draw the same plane (within 1 mm, same facing, at least 1 cm2 shared). Fix it with `decal: true` on the smaller part (layer 1; `depthLayer` 0 to 4 orders stacked decals), or `environment.resolveCoplanar: 'offset'` to bias the smaller part of every flagged pair. Both draw with a scoped polygon offset in the colour pass and render passes, and never move geometry. Use a real offset along the normal when the gap should be visible in exports or the path tracer. The coplanar code is not in the core bundle: call `installCoplanarDiagnostics(renderer)` from `67js/addons/coplanar-overlap` to add the warning to `renderer.diagnostics` (checked once per layout), and `scene_inspect` shows it once `loadAllAgentSceneModules()` (or a recipe with `resolveCoplanar`) has loaded the code. Far from the camera, depth precision is the other cause: `installReversedDepth(renderer, 'auto')` from `67js/addons/reversed-depth` switches on reversed-Z with a 32-bit float depth buffer and camera-relative drawing when a frame's far / near passes 10,000, or when `installDepthPrecision` finds a flush pair more than 40 units from the eye. It still has a float32 limit, because vertex positions are float32. On the RTX 3060 a 0.1 mm gap at 500 m still draws the far surface on 6.9% of pixels, and a 1 mm gap at 500 m on 1.4%; at 50 m both stay under 1%. Keep surfaces that must not flicker at least 1 mm apart when they sit hundreds of metres from the camera, or mark the top one `decal: true`.
## Shrinkwrap and surface patches