Cube-Sphere Planet Mapping
Map a cube's six faces onto a sphere so a planet can be built from six square quadtrees: far less polar distortion than lat-long grids, uniform tiles for LOD, and trivial cube-map lookups.
Also known as spherified cube, quadrilateralized spherical cube, planet cube mapping
In the family Procedural generation, planets
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | No built-in cube-sphere planetary terrain mapper. |
| Unity | None found | |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
A point on a cube face is normalised to the sphere, or better mapped with an equal-area correction (tan warping or the 'spherified cube' formula) that reduces the shrinking of cells toward face centres. Each face carries a quadtree of square tiles that subdivide with camera proximity, each tile evaluating a 3D noise or heightmap sampled at the sphere position, which avoids seams because noise is a function of 3D position, not 2D face uv. Matching edge vertices (stitching or skirts) between neighbouring tiles at different LODs prevents cracks. Because each face is regular, cube maps and per-face texture atlases work directly, unlike a UV sphere, which pinches at poles.
When to choose it
Reach for it when
- pole pinching ruins my planet texture
- uv sphere has distorted triangles near the poles
- building a planet from tiles with level of detail
- need even tile sizes for streaming planetary terrain
- sky or planet lookup without polar distortion
Choose it for planetary terrain with LOD streaming, procedural planet generation and sky/cube-map lookups. Prefer lat-long UV spheres only for small, static globes, an icosphere when you need near-uniform triangles with no faces to stitch, and Fractal Brownian Motion and Multifractals sampled in 3D as the height source on whichever mesh you use.
Field marks
- Naive normalisation squashes cells toward cube corners and stretches them toward face centres, giving uneven texel density
- Cracks along face and LOD boundaries unless skirts or stitching are used
- 2D noise per face produces visible seams at cube edges; sample 3D noise on the sphere position instead
- Floating-point precision at planetary scale needs camera-relative or origin-shifted rendering
Presets
Cube-sphere mapping: plain cube faces (left) vs tangent-warped faces (right)
{
"GRID": 6
}Show GLSL (35 lines)
// Cube-to-sphere mapping: left sphere = plain gnomonic cube faces, right = tangent-warped faces.
const float GRID = 6.0;
float warp(float u, bool on) { return on ? tan(u * 0.7853982) : u; }
float unwarp(float u, bool on) { return on ? atan(u) * 1.2732395 : u; }
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
bool right = uv.x > 0.0;
vec2 p = uv - vec2(right ? 0.5 : -0.5, 0.0);
vec3 col = vec3(0.06, 0.07, 0.09) + 0.05 * uv.y;
float r2 = dot(p, p), R = 0.44;
if (r2 < R * R) {
float z = sqrt(R * R - r2);
vec3 n = normalize(vec3(p, z));
float a = iTime * 0.0 + 0.6;
mat2 rot = mat2(cos(a), -sin(a), sin(a), cos(a));
n.xz = rot * n.xz; n.yz = mat2(cos(0.5), -sin(0.5), sin(0.5), cos(0.5)) * n.yz;
vec3 an = abs(n); vec2 f; vec3 base;
if (an.x > an.y && an.x > an.z) { f = n.yz / an.x; base = vec3(0.85, 0.35, 0.3); }
else if (an.y > an.z) { f = n.xz / an.y; base = vec3(0.35, 0.8, 0.4); }
else { f = n.xy / an.z; base = vec3(0.35, 0.5, 0.9); }
vec2 g = vec2(unwarp(f.x, right), unwarp(f.y, right)) * 0.5 + 0.5;
vec2 cell = fract(g * GRID);
float line = min(min(cell.x, 1.0 - cell.x), min(cell.y, 1.0 - cell.y));
vec2 id = floor(g * GRID);
float chk = mod(id.x + id.y, 2.0);
vec3 c = base * (0.55 + 0.35 * chk);
c = mix(vec3(0.05), c, smoothstep(0.0, 0.07, line));
vec3 sn = normalize(vec3(p, z));
float dif = max(dot(sn, normalize(vec3(-0.4, 0.6, 0.7))), 0.0);
col = c * (0.25 + 0.85 * dif);
}
col = mix(col, vec3(0.9), smoothstep(0.004, 0.0, abs(uv.x)));
fragColor = vec4(pow(col, vec3(0.45)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| cube-sphere-mapping-specimen | Tesla T4 1920x1080 | 1.86× baseline (feather) · 0.061 ms / 0.066 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| cube-sphere-mapping-specimen | NVIDIA L4 1920x1080 | 1.48× baseline (feather) · 0.024 ms / 0.024 ms · 2.6× faster on L4 | opengl-timer-query · Cross-architecture validation |
| cube-sphere-mapping-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 1.24× baseline (feather) · 0.036 ms / 0.036 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Planets with rivers across cube seams: Whole planets whose mountain ranges and river networks are drainage-consistent across all six cube faces. Stream-power erosion runs on one flow graph over the cube-sphere, so rivers cross face seams without breaking and basins span continents.
- Simplex Noise: 3D noise sampled at the sphere position gives seamless planetary heights across cube faces.
Sources
- primarySteven Wittens. Making Worlds 1 - Of Spheres and Cubes. acko.net.Verified via live page · 2026-11-29