logo
By Lawrence

5 minutes

Keep the World Precise as You Fly Far

Point the falcon at empty space and hold the throttle. For a while the view looks clean. Then you fly far out, tens of thousands of units from the start, and the picture starts to break up: the hull shimmers, the motion picks up a small jitter, distant edges crawl. Your code did not change. Precision ran thin.

A single-precision float — what every matrix handed to the GPU is made of — carries about seven significant digits, and they are significant, not absolute. Spend five of them on the integer part and only two are left for everything smaller. The gap between neighbouring representable positions grows with distance from zero:

distance from origin      spacing between representable float32 positions
1                         ~0.0000001 units
1,000                     ~0.00006   units
100,000                   ~0.008     units
1,000,000                 ~0.06      units      ← the falcon is 5 units long

At a million units out the ship can only land on a grid whose steps are a hundredth of its own length — and it is the whole world landing on that grid, not just the ship. Every frame everything snaps to the nearest point on it, and that is the jitter — nothing is moving badly, the numbers just can't say where it is any more. The same thinning precision spread across a 200,000-unit depth range is what makes distant edges crawl.

See the jitter a million units out

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search