---
id: "cube-sphere-mapping"
title: "Cube-Sphere Planet Mapping"
aliases: [spherified cube, quadrilateralized spherical cube, planet cube mapping]
domain: "procgen"
stage: "procedural"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, cpu, unity, unreal, godot]
year_introduced: 2013
outputs: [mesh, heightfield, texture]
style: "both"
dynamic: "static"
cost: "cheap"
authority: "Wittens"
url: "https://texelatlas.vercel.app/t/cube-sphere-mapping/"
sources_verified_at: "2026-11-29"
---
# Cube-Sphere Planet Mapping (Wittens)

> 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.

## 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

## 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 use it

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](https://texelatlas.vercel.app/t/fractal-brownian-motion.md) sampled in 3D as the height source on whichever mesh you use.

## Cost

cheap — Mapping is a few arithmetic operations per vertex; cost depends on LOD scheme and noise octaves.
Measured GPU Weight: 1.86× baseline (feather) — 0.0613 ms median / 0.0655 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 1.48× baseline (feather) — 0.0236 ms median (2.6× faster on L4).
Ampere A100 scaling: 1.24× baseline (feather) — 0.0358 ms median (1.71× faster on A100).

## Failure modes

- 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

## Dataflow

- Inputs: —
- Outputs: mesh, heightfield, texture
- Platforms: webgl2, webgpu, desktop-gpu, cpu, unity, unreal, godot

## Presets

### Cube-sphere mapping: plain cube faces (left) vs tangent-warped faces (right) (glsl-fragment; rendered 2026-11-29)

```json
{
  "GRID": 6
}
```

```glsl
// 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

## Combines with

- [Simplex Noise](https://texelatlas.vercel.app/t/simplex-noise.md): 3D noise sampled at the sphere position gives seamless planetary heights across cube faces.

## Combination ideas

- [Planets with rivers across cube seams](https://texelatlas.vercel.app/ideas/drainage-consistent-planets/)

## Sources

1. [primary] Steven Wittens Making Worlds 1 - Of Spheres and Cubes. acko.net. https://acko.net/blog/making-worlds-1-of-spheres-and-cubes (verified via http on 2026-11-29)

## Cite this entry

Texel. "Cube-Sphere Planet Mapping." https://texelatlas.vercel.app/t/cube-sphere-mapping/ (accessed 2026-12-01).
