This document summarizes a detailed technical blog post by "Bowerbyte" about "Blocky Planet," a tech demo that maps a Minecraft-style voxel world onto a sphere, along with a corresponding Hacker News discussion.
The blog post outlines the significant challenges and novel solutions involved. Key among these is the use of a "quad sphere" projection to map the world's surface, which minimizes distortion compared to standard projections. To address vertical distortion as players dig inward, a system of nested "shells" is implemented, where the number of blocks per layer quadruples at set intervals to maintain consistent block sizes. The author details the complex data structure (Sector → Shell → Chunk → Block) and the logic for finding neighboring blocks, especially across the tricky sector and shell boundaries. The post also covers custom gravity, terrain generation using 3D noise, and a system for placing pre-built structures.
The Hacker News discussion reflects a highly positive reception, praising the project's technical depth and clear explanation. Commenters draw comparisons to games like Super Mario Galaxy, Space Engineers, and Outer Wilds, discussing the various approaches to spherical worlds. Key technical points from the community include the importance of the quad sphere to avoid polar singularities, the physics of zero gravity at a planet's core (Shell Theorem), and suggestions for alternative geometric bases like geodesic spheres or toruses.
Blocky Planet: A Technical Deep Dive into a Spherical Voxel World
Introduction: The Core Challenge
The project aims to create a spherical, fully destructible voxel planet. The primary challenge is mapping a cubic grid to a sphere without creating severe visual distortion or breaking gameplay mechanics like building and walking, as standard grid alignment conflicts with a central gravity point.
Let’s Get Spherical: Surface Mapping
Problem: Mapping a flat grid to a sphere inevitably causes distortion. A simple projection creates extreme stretching at the poles.
Solution: The project uses a quad sphere, which maps six square faces of a cube onto the sphere. This greatly reduces distortion compared to a single rectangular map.
Refinement: To further improve visual quality, a pre-distortion is applied to the square grid to counteract the distortion introduced during the spherical projection, resulting in blocks that look much more like squares, even at the seams between sectors.
Digging Deep: Handling Vertical Distortion
Problem: On a sphere, layers have a smaller area closer to the center. Stacking identical layers results in stretched blocks near the surface and compressed blocks near the core.
Solution: The world is divided into concentric shells. As a player moves outward into a new shell, the number of blocks per layer quadruples. This keeps the blocks' size relatively consistent.
Trade-off: This creates perfect block alignment within a shell but results in seams at shell boundaries, where one larger block from an inner shell maps to four smaller blocks in the next shell out.
Planet Structure: Data Organization
The planet is organized hierarchically for efficient data management. The structure is: Planet → 6 Sectors → Shells → Chunks (16x16x16) → Blocks.
Each block has a unique BlockAddress that specifies its exact location within this structure.
Who’s my Neighbor?: The Biggest Hurdle
Finding a block's neighbor is the most complex operation, especially across boundaries.
Vertical Shell Boundaries: A block at the top of an inner shell has four neighbors "above" it in the next shell, complicating adjacency calculations.
Sector Boundaries: The local coordinate systems of adjacent sectors are often misaligned (axes are swapped or flipped). This requires specific mapping logic for each of the 12 edge pairings on the quad sphere's cube net.
Miscellaneous Functionality: Gameplay Mechanics
Player Gravity: A custom gravity system pulls the player towards the planet's center. Gravity decreases to zero at the core, and a "thruster" allows for flight and orbital mechanics.
Terrain Generation: The system uses 3D noise sampled on a sphere, which naturally avoids the seams and distortion that would occur when mapping 2D noise. Biomes (arctic and forest) are determined by angular distance from the poles.
Block Structures: Placing pre-built structures is achieved by navigating from an origin block using relative directions. This allows structures to be placed even across the "wonky" corner and shell boundary areas, though some distortion may occur.
Future Work
The author plans to potentially add features like multiple planets and moons (an Outer Wilds-style system), chunk-based dynamic gravity, cave generation, and more realistic biomes.
Key Points from the Hacker News Discussion
General Reception: The project and its detailed write-up were met with widespread praise for tackling a difficult problem with elegant solutions and for the clarity of the explanation.
Game Comparisons: Many users compared the concept to other games with non-Euclidean or planetary physics, including Super Mario Galaxy (small planetoids), Space Engineers (spherical voxels), Outer Wilds (solar system exploration), and PlanetSmith (hexagonal voxels).
Gravity Physics: Several comments discussed the realism of the gravity model, noting that according to the Shell Theorem, gravity should indeed fall to zero at the center of a spherically symmetric body. The weird gravity in games like Astroneer was also mentioned.
The Quad Sphere: The choice of a quad sphere was highlighted as a critical and intelligent design decision to avoid the extreme distortion and singularity issues found at the poles of traditional latitude-longitude map projections.
Alternative Geometries: Commenters proposed alternative approaches, such as using a geodesic sphere (based on triangles) for more uniform distortion or a torus, which would eliminate polar issues entirely but introduce its own topological challenges.
Player Experience: Users who tried the demo reported enjoying the gameplay, particularly the ability to achieve a stable orbit around the planet using the thruster.