The Las Vegas Sphere, alive inside Apple Maps.
Custom animated geometry injected into Apple Maps' own Metal render pass — so the map's real 3D buildings occlude it natively, no compositing tricks. Inspired by Charly Delaroche's "same pass · injected geometry" demo; there is no public MapKit API for this (checked the iOS 26.5 SDK), so everything here is runtime reverse engineering.
| Emoji face (blinks, looks around, tracks the camera) | Trippy LED plasma | Night orbit |
|---|---|---|
![]() |
![]() |
![]() |
-
Get inside the map's renderer. Swizzle
CAMetalLayer.nextDrawableplus the concreteMTLCommandBuffer.renderCommandEncoderWithDescriptor:/MTLRenderCommandEncoder.endEncodingclasses. The map's main scene pass is the one with a depth attachment whose color target is the drawable. Just before that pass ends, encode our own draw call — same encoder, same depth buffer, so VectorKit's geometry depth-tests against ours for free. -
Match the camera. Rebuild the view-projection from
MKMapCamera(ENU meters at the site) and calibrate the unknowns againstmapView.convert(_:toPointTo:)ground samples at runtime. Apple Maps renders with a ~29.6° vertical FOV and a slight vertical principal-point offset (~3 px reprojection residual). -
Match the depth mapping. The map's depth buffer is memoryless, so we substitute our own depth texture into the pass descriptor before encoder creation, then read it back post-pass with a tiny compute kernel at pixels we know are flat ground. A robust Theil–Sen fit recovers VectorKit's actual mapping — it's logarithmic depth — which our vertex shader then emits directly. Result: correct occlusion against buildings at every distance.
-
The ball. A UV sphere at the Sphere's real site (36.12124, −115.16207), real dimensions (157 m wide, truncated at plaza level), shelled just proud of Apple's own dark Sphere model. Shaders are compiled at runtime from source (no metallib step). Two modes: LED-grid plasma, and an emoji face with gaussian blinks, wandering pupils, and lazy camera tracking.
./build.sh # swiftc → .app → boots an iPhone simulator → installs → launchesNo Xcode project — plain swiftc against the iphonesimulator SDK. Tested with Xcode 26.6 / iOS 26.5 simulator.
On-screen: orbit toggles the auto-orbit, face switches shader modes, the slider tunes the depth-fit near constant.
Launch-time knobs (prefix with SIMCTL_CHILD_ via simctl launch):
| var | default | |
|---|---|---|
SHADER_MODE |
0 | 0 plasma, 1 face |
ORBIT / CAM_H / CAM_P / CAM_D |
1 / 210 / 55 / 1400 | orbit on, heading°, pitch°, distance m |
SPHERE_R / SPHERE_ALT / CUT_Z |
82.5 / 33.5 / 3 | ball radius, center height, ground cut (m) |
SPHERE_DE / SPHERE_DN |
0 / 0 | position nudge east/north (m) |
DEPTH_MODE |
always | force less / rev instead of the probe fit |
PROBE_APPLY |
1 | 0 disables the fitted depth mapping |
- Swizzles private rendering internals of MapKit/VectorKit — a demo/research hack, not App Store material, and any iOS update may break it.
- Only exercised on the iOS simulator; on-device Metal class names and pass structure may differ.
- The FOV/depth constants aren't hardcoded guesses — they're re-fitted live — so it should self-adapt, but no promises.
MIT


