Skip to content
Andrew Voirol
Monday, August 31, 2026geogenesis-unfolding-globe

Hardware-accelerated country picking: 24-bit bijective RGB buffers

VisualizationCanvasDesign

Evaluating point-in-polygon raycasts across 180+ TopoJSON country boundaries during real-time continuous projection morphing causes heavy CPU bottlenecks and dropped frames.

GeoGenesis replaces geometric hit-testing with an off-screen 24-bit bijective RGB color-picking buffer.

1. 24-Bit Bijective Integer Encoding

Each country feature index k∈[0,N−1]k \in [0, N-1]k∈[0,N−1] is mapped to a unique 24-bit integer C=k+1C = k + 1C=k+1:

R=C(mod256),G=⌊C/256⌋(mod256),B=⌊C/65536⌋(mod256)R = C \pmod{256}, \quad G = \lfloor C / 256 \rfloor \pmod{256}, \quad B = \lfloor C / 65536 \rfloor \pmod{256}R=C(mod256),G=⌊C/256⌋(mod256),B=⌊C/65536⌋(mod256)

Decoding the pixel value read under the cursor:

Index k=R+G⋅256+B⋅65536−1\text{Index } k = R + G \cdot 256 + B \cdot 65536 - 1Index k=R+G⋅256+B⋅65536−1

If R=G=B=0R = G = B = 0R=G=B=0, the pointer is over ocean or void (k=nullk = \text{null}k=null).

2. Zero-Stall Host Memory Pinning

The off-screen canvas context is initialized with { willReadFrequently: true }. This pins the backing buffer in host memory, eliminating GPU-to-CPU pipeline stalls during ctx.getImageData() calls. Pointer inspection executes in <0.05 ms< 0.05\text{ ms}<0.05 ms (O(1)O(1)O(1) constant time) regardless of polygon complexity.

← Previous

Multi-projection topology mutators: Taylor sinc guards and Newton-Raphson Kepler solvers

Next →

Geodesic arc morphing: spherical SLERP flight paths across dynamic projections


Andrew Voirol

Builder, hacker, shipper. Currently leaving localhost.

Navigate

WorkThreadsBuilder's LogAboutContactRSS Feed

Connect

X / TwitterGitHubLinkedIn

© 2026 Andrew Voirol·Back to top ↑
✦Just one prompt away from figuring it all out.