Skip to content

fix(bodies): register every body texture on its prime meridian#508

Merged
rulkens merged 1 commit into
mainfrom
worktree-moon-texture-orientation
Jul 24, 2026
Merged

fix(bodies): register every body texture on its prime meridian#508
rulkens merged 1 commit into
mainfrom
worktree-moon-texture-orientation

Conversation

@rulkens

@rulkens rulkens commented Jul 24, 2026

Copy link
Copy Markdown
Owner

The Moon showed its far side to Earth.

Root cause

uvSphereMesh emitted u = lon / 2π, putting u=0 on the local +x axis the IAU rotation aims a body's prime meridian at. Every standard equirectangular map — Solar System Scope, USGS, Blue Marble — paints longitude 0 at the image centre (u=0.5). So the shared sphere sampled the map's antimeridian where the prime meridian should be: the whole surface 180° round about the pole, on all twelve bodies riding that mesh (Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, the four Galileans).

Confirmed against the asset: in moon-2048.jpg the maria sit dead centre and the far-side cratering is at the edges. The Moon is tidally locked, so its prime meridian points at Earth — which makes it the one body with a permanent rotational-phase ground truth, and the one where the bug is unmissable.

Earth escaped it two different ways: its surface rides the Earth-only cubeSphereMesh, which bakes the offset, and its cloud deck (on the shared sphere) compensated with a hand-rolled +0.5 in cloudShell/fragment.wesl.

The fix

Bake the registration into uvSphereMesh from the same constant cubeSphereMesh uses, and delete the cloud shader's patch — one convention, one site per mesh, instead of a per-shader correction that only the shaders someone noticed ever received.

u runs 0.5→1.5 unwrapped rather than wrapping back into [0,1]: both samplers address u as repeat, so the hardware closes the turn, and a mid-sphere whole-turn jump would break the fragment quad's derivatives at the seam (coarsest mip along a ~1px antimeridian line).

The constant stops being Earth's, so EARTH_TEXTURE_PRIME_MERIDIAN_UTEXTURE_PRIME_MERIDIAN_U and its file follows the symbol, both via npm run refactor.

Backlog

Picks up and removes body-texture-meridian-registration (surfaced 2026-07-21 during the terminator fix, #472). Its deferral rested on "no other body has a rotational-phase ground truth" — tidal locking is one.

Verification

  • New test pins the registration (lon 0 → u 0.5); it fails on the old mesh.
  • 867 test files / 5027 tests pass; npm run build green (WESL relinks).
  • Visual pass confirmed by @rulkens: Moon near side correct, Earth + cloud deck unchanged.

🤖 Generated with Claude Code

`uvSphereMesh` emitted u = lon/2π, putting u=0 on the local +x axis the IAU
rotation aims a body's prime meridian at. Standard equirectangular maps paint
longitude 0 at the image CENTRE, so every body riding the shared sphere
rendered its surface 180° round about the pole — visibly, on the tidally
locked Moon, which showed its far side to Earth.

Earth escaped it: `cubeSphereMesh` bakes the registration offset already, and
the cloud deck compensated with a hand-rolled +0.5 in its fragment shader. Bake
the offset into `uvSphereMesh` instead, from the same constant, and drop the
shader patch — one convention, one site per mesh. u runs 0.5..1.5 unwrapped so
the samplers' `repeat` addressing closes the turn, keeping the quad derivatives
continuous across the antimeridian.

The constant is no longer Earth's, so `EARTH_TEXTURE_PRIME_MERIDIAN_U` becomes
`TEXTURE_PRIME_MERIDIAN_U` (via `npm run refactor`).

Picks up and removes the `body-texture-meridian-registration` backlog item,
whose "no observable consequence today" reading missed that tidal locking is
itself a rotational-phase ground truth.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
skymap 6b557a4 Commit Preview URL

Branch Preview URL
Jul 24 2026, 11:13 PM

@rulkens
rulkens merged commit 4d65e70 into main Jul 24, 2026
2 checks passed
@rulkens
rulkens deleted the worktree-moon-texture-orientation branch July 24, 2026 23:16
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