Skip to content

explorer: fix halo terrain occlusion via scene.globe.depthTestAgainstTerrain (v2)#184

Closed
rdhyee wants to merge 1 commit intoisamplesorg:mainfrom
rdhyee:explorer-halo-terrain-fix-v2
Closed

explorer: fix halo terrain occlusion via scene.globe.depthTestAgainstTerrain (v2)#184
rdhyee wants to merge 1 commit intoisamplesorg:mainfrom
rdhyee:explorer-halo-terrain-fix-v2

Conversation

@rdhyee
Copy link
Copy Markdown
Contributor

@rdhyee rdhyee commented May 9, 2026

Summary

Second attempt at the PR #180 halo terrain-occlusion bug. Replaces the reverted #181.

Why #181 was wrong (Codex review of d681758):
Setting disableDepthTestDistance: Number.POSITIVE_INFINITY on every PointPrimitive disables depth-test entirely, including against the globe ellipsoid. That caused two regressions worse than the original crescent halos:

  1. Back-side bleed-through — points on the geographic far side of the globe rendered through the planet (the global H3 cluster collection makes this visible everywhere).
  2. Broken picking — hover labels and click-handlers got routed to back-side primitives intersecting the screen ray.

The correct fix (one line, scene-level):

v.scene.globe.depthTestAgainstTerrain = false;

Applied immediately after Viewer construction. This is the documented Cesium switch for "primitives at altitude=0 should draw over terrain elevation, but still respect ellipsoid back-face occlusion." It fixes the original crescent / disappearing-dots-over-hills problem without the d681758 regressions because:

  • Globe ellipsoid depth-test still applies → back-side primitives still hidden.
  • Scene-pick depth still works → hover and click correctness preserved.
  • No per-primitive flags → no cross-cutting changes to the three add() sites.

The halos from #180 are untouched.

Verified locally

quarto render + Playwright at two cameras:

view result
Reported repro: lat=33.27, lng=-86.24, alt=311km (Birmingham AL hill country) ✓ full-circle halos, no crescents, dots over higher terrain visible
World view (Africa-centered) ✓ globe occlusion intact, no back-side primitive bleed-through, edges crisp

Diff

8 lines — 1 line of actual code + 7 lines of comment explaining the Cesium-API choice and why per-primitive disableDepthTestDistance was wrong.

Test plan

  • Visit https://isamples.org/explorer.html#v=1&lat=33.2706&lng=-86.2375&alt=311435&heading=360.0 — full-circle halos
  • Mountainous regions (Rockies, Andes, Himalayas) at street zoom — dots remain visible
  • World zoom — back side of globe stays hidden, no cluster bleed-through
  • Hover and click on cluster + sample dots — correct primitive selected (no through-globe pick)

Refs #180, #181 (reverted), #183 (revert PR). Codex-reviewed.

🤖 Generated with Claude Code

Replaces the reverted PR isamplesorg#181 fix. The earlier attempt set
`disableDepthTestDistance: Number.POSITIVE_INFINITY` on every PointPrimitive,
which disables depth-test entirely — including against the globe ellipsoid.
That caused back-side-of-globe primitives to bleed through the planet AND
broke pickability (hover labels and click-routing went to wrong primitives),
both worse than the original crescent halos it was trying to fix.

Codex review of d681758 identified the correct Cesium API: scene-level
`globe.depthTestAgainstTerrain = false`. This tells the globe to draw
primitives over terrain (fixes crescents and disappearing dots over hills)
while preserving the ellipsoid's normal back-face occlusion and pick
correctness.

One line, applied right after Viewer construction. No per-primitive changes;
the halos from isamplesorg#180 stay.

Verified locally:
- Birmingham AL hilly view (the reported repro): full-circle halos, no
  crescents, dots over higher terrain visible.
- World view (Africa-centered): globe occlusion intact, no back-side
  primitive bleed-through.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rdhyee
Copy link
Copy Markdown
Contributor Author

rdhyee commented May 9, 2026

Closing as no-op per Codex review: Globe#depthTestAgainstTerrain already defaults to false in Cesium 1.127, so the explicit assignment changes nothing. My local 'verification' was bogus — the bug doesn't reproduce at the canvas resolution my browser was running, with or without this line.

The original PR #180 halo crescents must therefore have a different root cause. Re-investigating before opening another fix attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant