PlanetGen: The Math Behind Walkable Planets in UE5 @CodeLikeMe
PlanetGen: The Math Behind Walkable Planets in UE5  @CodeLikeMe
Uploaded October 2026 | Updated November 2026, 3 days ago
A planet you can walk on, built from a cube. This case study follows PlanetGen's real maths from six flat grids to a streaming planet, with the formulas on screen and real Unreal Engine footage in every chapter.

Why a latitude and longitude grid pinches at the poles. How PlanetGen pushes a cube out to a sphere, and warps each face with tan(u x pi/4) first so equal steps give equal angles. Chunks, vertices and height along the radius. Noise sampled in 3D so the six faces agree at their edges, and a continent mask that keeps mountains on the land. Normals from four neighbours, with one extra ring of samples so chunk edges match. The horizon cone that decides which chunks load, far planets that swap in without a pop, and ring worlds built by the same pipeline.

The diagrams are drawn in code. The footage was captured in Unreal Engine 5.

────────────────────────────────────────
🧩 GET IT
────────────────────────────────────────
► PlanetGen on FAB: fab.com/listings/96c36654-f244-4c75-a527-cfaaab2d5ac4
► Playable Demo: patreon.com/CodeLikeMe/posts/173503702
► PlanetGen docs: https://codelikeme-site.teez-mrt.workers.dev/docs/planetgen/
► Discord Community: discord.gg/jRhvJtw5r5

────────────────────────────────────────
🪐 WHAT IS IN IT
────────────────────────────────────────
✔ A cube's six faces, each a grid with u and v running from -1 to 1
✔ Plain normalize: of nine equal steps, the middle cell covers 12.7 degrees, the edge cells only 7.1
✔ PlanetGen's mapping: dir = normalize(N + U x tan(u x pi/4) + V x tan(v x pi/4)), equal steps give equal angles
✔ Chunks per face = round(R x pi/2 / Tile Size): 9 x 9 x 6 = 486 on the default 6 km planet; 32 x 32 x 6 = 6,144 (the cap) on the 50 km planet in the footage
✔ 64 x 64 vertices and 7,938 triangles per chunk; height along the radius: position = dir x (R + h)
✔ Noise sampled in 3D at the point on the smooth sphere, so two faces read the same value on their shared edge
✔ The continent mask: mask = smoothstep(clamp((C + threshold) / blend, 0, 1)), the other layers weighted by it
✔ Normals: cross(R - L, U - D) from four neighbours, with one extra ring of samples (66 x 66 for 64 x 64 vertices)
✔ Horizon culling: a cone of acos(R / D) + acos(R / (R + peak)) + 7.5 degrees + one chunk; a chunk loads when it is inside
✔ On the default planet, standing on the ground: about 40 degrees, about 12% of the planet instead of about 55%
✔ The 50 km planet from above: about 40 degrees again, roughly 700 of its 6,144 chunks loaded
✔ Far planets: one low-poly sphere (6 x 32 x 32 = 6,144 vertices) just above the peaks; it sinks below the terrain once about 90% of the nearby chunks are built, and needs only 70% to stay down
✔ Ring worlds: one face wrapped round a cylinder, angle = u x pi, along the axis = v x L/2

────────────────────────────────────────
📋 WHAT IT IS NOT
────────────────────────────────────────
✘ Not a tutorial or a build-along: it shows the maths PlanetGen runs, not how to write it
✘ Not how every game builds planets: this is PlanetGen's cube-to-sphere pipeline
✘ The diagrams are illustrations drawn in code, not PlanetGen's own output
✘ The footage was captured in the SpaceKit project, which uses the same planet code; its planet has a 50 km radius (PlanetGen's default is 6 km)
✘ The orbit wireframe shows the planet's far sphere (the same mapping at 32 vertices a side); from that far away the streamed chunks draw as a solid disc in wireframe
✘ Planet Radius goes up to 1,000 km, but past a few hundred km terrain detail eventually softens as float precision runs out

────────────────────────────────────────
🔧 REQUIREMENTS
────────────────────────────────────────
✔ Unreal Engine 5.4, 5.5, 5.6, 5.7 or 5.8

────────────────────────────────────────
🎮 SUPPORT & COMMUNITY
────────────────────────────────────────
► Discord: discord.gg/jRhvJtw5r5
► Patreon: patreon.com/cw/CodeLikeMe
► Subscribe: youtube.com/codelikeme

#UnrealEngine #UE5 #GameDev #ProceduralGeneration #ProceduralPlanet #GameMath #Math #IndieDev #PlanetGen #CodeLikeMe

0:00 Why not a latitude longitude sphere
0:42 Cube to sphere mapping: normalize and the tan warp
3:14 Planet chunks, vertices and radial height
4:53 3D noise without seams and the continent mask
6:24 Seamless normals across chunk edges
7:36 Horizon culling: load only what you can see
9:57 Far planets without a pop: multi-planet LOD
10:56 Ring worlds: the same pipeline on a cylinder
11:36 Recap and limits
PlanetGen: The Math Behind Walkable Planets in UE5Attack & Match Flow - Unreal Engine Reactive Turn Based Combat #33Unreal Engine Common UI Menu System #51 - Bug FixesSwitch Player Character in Free Roaming Mode - Unreal Engine Reactive Turn Based Combat #24Free Roam To Combat Post Process Effect - Unreal Engine Reactive Turn Based Combat #27Match Victory and Continue - Unreal Engine Reactive Turn Based Combat #40Niagara Character Trail - Unreal Engine Reactive Turn Based Combat #48Character Death - Unreal Engine Reactive Turn Based Combat #38Learn Verse Before UE6: 10 Differences From BlueprintWorldGen 1.9 — Spawn Resources & NPCs in a Procedural Open World | UE5RTSKit V1.1 for UE5: Top-Down RTS Starter with Research and ProductionFree Roam Mode - Unreal Engine Reactive Turn Based Combat #21
CodeLikeMe |

PlanetGen: The Math Behind Walkable Planets in UE5

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER