---
id: "environment-mapping-cubemaps"
title: "Environment mapping, cubemaps and skyboxes"
aliases: [cube mapping, skybox, reflection mapping, HDRI backdrop, environment map]
domain: "gi"
stage: "lighting"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender]
year_introduced: 1986
inputs: [hdr-image]
outputs: [radiance]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "Greene, 1986"
url: "https://texelatlas.vercel.app/t/environment-mapping-cubemaps/"
sources_verified_at: "2026-11-29"
---
# Environment mapping, cubemaps and skyboxes (Greene, 1986)

> Store the light arriving from the distant surroundings in a six-face cubemap or equirectangular image, then look it up by direction for backgrounds, mirror reflections and, once prefiltered, diffuse and glossy lighting.

## Reach for it when

- need a skybox or hdri background behind the scene
- want cheap fake reflections of the surroundings on shiny objects
- metal looks dull without anything to reflect
- how to store light from all directions in a texture

## How it works

An environment map records incoming radiance as a function of direction only, which is exact when the light is far away compared with the object. The map is stored as six cube faces or a latitude-longitude image; a cubemap fetch converts a 3D direction into a face and texel, so there is no pole distortion and hardware filtering works across seams on modern GPUs.

Uses build on one lookup. The background is a draw at the far plane that samples the map with the view ray. A mirror reflection samples with `reflect(view, normal)`. Rough and diffuse lighting need the map convolved against a lobe, which is why engines prefilter it into mips ([split-sum-ibl](split-sum-ibl)) or project it into [spherical-harmonics-lighting](spherical-harmonics-lighting). Captured HDR data must stay in linear floating point; an LDR map clips the sun and makes every reflection look weak.

The map can be a photographed HDRI, a rendered sky ([hosek-wilkie-sky](hosek-wilkie-sky), [hillaire-sky-atmosphere](hillaire-sky-atmosphere)), or a capture from the scene itself.

## When to use it

Choose it for the backdrop, for sky and studio lighting, and for reflections of things that are effectively at infinity.

Prefer [reflection-probes-parallax-corrected-cubemaps](reflection-probes-parallax-corrected-cubemaps) for interiors, where finite room size makes plain lookups look pasted on. Prefer [screen-space-reflections](screen-space-reflections) or [path-tracing](path-tracing) when nearby dynamic objects must appear in reflections. Prefer [split-sum-ibl](split-sum-ibl) for glossy PBR lighting from the same map rather than raw reflect lookups.

## Cost

cheap — One texture fetch per pixel for lookup; memory is six faces per probe, and prefiltering is a one-time cost.
Measured GPU Weight: 4.91× baseline (light) — 0.1615 ms median / 0.1712 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 4.26× baseline (light) — 0.0678 ms median (2.38× faster on L4).
Ampere A100 scaling: 3.49× baseline (light) — 0.1004 ms median (1.61× faster on A100).

## Failure modes

- Reflections have no parallax, so an object near a floor or wall looks as if its reflection were infinitely far away
- Seams along cube edges if filtering across faces is not enabled or if prefilter does not wrap
- Clipped suns and lights when the map is stored in 8 bits, making metals dull
- Equirectangular maps stretch and alias near the poles
- Reflected content cannot contain the object itself or any local dynamic light
- Mismatched handedness or axis convention flips the map horizontally or vertically between tools

## Engine support

- babylonjs: builtin — `new BABYLON.CubeTexture(url, scene); scene.environmentTexture` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Materials/Textures/cubeTexture.pure.ts, checked 2026-12-01)
- blender: builtin — `World > Surface > Environment Texture node` (evidence: https://docs.blender.org/manual/en/5.2/render/shader_nodes/textures/environment.html, checked 2026-12-01) — Equirectangular and mirror-ball projections; no native cubemap type.
- godot: builtin — `WorldEnvironment > Environment.background_mode = BG_SKY with a Sky (PanoramaSkyMaterial for HDRI)` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Environment.xml, checked 2026-12-01)
- metal: builtin — `MTLTextureType.typeCube; MSL texturecube<float>` (evidence: https://developer.apple.com/tutorials/data/documentation/metal/mtltexturetype.json, checked 2026-12-01) — Cube textures and sampling are primitives; skybox pass is yours.
- threejs: builtin — `scene.background = scene.environment = cubeTexture (CubeTextureLoader)` (evidence: https://github.com/mrdoob/three.js/blob/r187/src/loaders/CubeTextureLoader.js, checked 2026-12-01)
- unity: builtin — `Lighting > Environment > Skybox Material (cubemap/panoramic); HDRP Volume > Visual Environment = HDRI Sky` (evidence: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/RenderSettings-skybox.html, checked 2026-12-01)
- unreal: builtin — `Sky Light with a manually specified cubemap` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/sky-lights-in-unreal-engine, checked 2026-12-01)
- webgpu: builtin — `createTexture(6 layers) + createView({dimension:'cube'}); WGSL texture_cube<f32>` (evidence: https://www.w3.org/TR/webgpu/, checked 2026-12-01) — Cube view and sampling are primitives; skybox pass is yours.

## Dataflow

- Inputs: hdr-image
- Outputs: radiance
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender

## Presets

### Environment Mapping & Cubemaps — unfolded 6-face cubemap cross & mip blur (left) vs seamless 3D skybox & glossy IBL spheres (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_ROUGHNESS": 0.18,
  "P_SUN_ELEV": 0.36,
  "P_CAM_ORBIT": 0.35,
  "P_SPLIT": 0.46
}
```

```glsl
const float P_ROUGHNESS = 0.18; // P IBL Roughness [0.0, 0.9, 0.03]
const float P_SUN_ELEV = 0.36; // P Sun Elevation [0.08, 0.85, 0.03]
const float P_CAM_ORBIT = 0.35; // P Orbit Speed [0.0, 1.5, 0.05]
const float P_SPLIT = 0.46; // P Cross / 3D Split [0.0, 1.0, 0.02]

// Analytic procedural HDR cubemap sampled by unit direction d and prefilter roughness r
vec3 evalCubemap(vec3 d, float rough, float sunElev) {
  d = normalize(d);
  vec3 sunDir = normalize(vec3(0.72, sunElev, -0.58));
  float blur = clamp(rough, 0.0, 1.0);

  // Sky zenith-to-horizon gradient with warm sunset scattering
  vec3 zenith = vec3(0.10, 0.24, 0.58);
  vec3 horizon = mix(vec3(0.95, 0.56, 0.30), vec3(0.65, 0.78, 0.94), smoothstep(0.15, 0.70, sunElev));
  vec3 ground = vec3(0.12, 0.11, 0.13);

  float upT = smoothstep(-0.04 - blur * 0.35, 0.55 + blur * 0.25, d.y);
  vec3 sky = mix(horizon, zenith, upT);
  float gndT = smoothstep(0.02 + blur * 0.25, -0.18 - blur * 0.35, d.y);
  vec3 col = mix(sky, ground, gndT);

  // Distant mountain silhouette band around the horizon
  float az = atan(d.z, d.x);
  float mtnH = 0.055 + 0.045 * sin(az * 3.0 + 0.5) + 0.028 * cos(az * 7.0 - 1.1) + 0.015 * sin(az * 13.0);
  float mtnMask = smoothstep(mtnH + 0.012 + blur * 0.14, mtnH - 0.012 - blur * 0.10, d.y) * smoothstep(-0.08, 0.01, d.y);
  col = mix(col, vec3(0.14, 0.16, 0.24) + vec3(0.22, 0.14, 0.10) * max(dot(d, sunDir), 0.0), mtnMask * (1.0 - blur * 0.65));

  // Soft volumetric cloud deck
  float cl = sin(az * 4.0 + d.y * 9.0) * cos(az * 6.0 - d.y * 5.0);
  float clBand = smoothstep(0.15, 0.45, d.y) * smoothstep(0.75, 0.35, d.y) * smoothstep(0.15, 0.72, cl);
  col = mix(col, mix(vec3(0.96, 0.86, 0.78), vec3(0.72, 0.78, 0.88), blur), clBand * 0.42 * (1.0 - blur * 0.5));

  // Pre-filtered solar disc + Mie aureole
  float sunCos = max(dot(d, sunDir), 0.0);
  float sunExp = mix(220.0, 6.0, blur * blur);
  float sunGain = mix(6.5, 0.95, blur);
  col += vec3(1.0, 0.86, 0.62) * (pow(sunCos, sunExp) * sunGain + pow(sunCos, 8.0) * 0.42);
  return col;
}

vec3 aces(vec3 x) {
  x = max(x, 0.0);
  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float sx = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  bool show3D = sx >= split;

  float rough = clamp(P_ROUGHNESS, 0.0, 0.95);
  float sunElev = clamp(P_SUN_ELEV, 0.06, 0.88);
  float orb = iTime * max(P_CAM_ORBIT, 0.0);

  vec3 col = vec3(0.05, 0.06, 0.09);

  if (!show3D) {
    // Left: Horizontal 4x3 cubemap cross layout (-X, +Z, +X, -Z across middle; +Y top; -Y bottom)
    vec2 p = vec2(sx / max(split, 0.05), fragCoord.y / max(iResolution.y, 1.0));
    vec2 g = (p - vec2(0.06, 0.14)) / vec2(0.88, 0.72);
    vec2 cell = floor(g * vec2(4.0, 3.0));
    vec2 f = fract(g * vec2(4.0, 3.0)) * 2.0 - 1.0;

    bool valid = false;
    vec3 dir = vec3(0.0, 0.0, 1.0);
    vec3 faceTint = vec3(1.0);

    if (cell.y == 1.0 && cell.x >= 0.0 && cell.x < 4.0) {
      valid = true;
      if (cell.x == 0.0) { dir = vec3(-1.0, f.y, f.x); faceTint = vec3(1.0, 0.45, 0.45); }
      else if (cell.x == 1.0) { dir = vec3(f.x, f.y, 1.0); faceTint = vec3(0.45, 0.85, 1.0); }
      else if (cell.x == 2.0) { dir = vec3(1.0, f.y, -f.x); faceTint = vec3(0.95, 0.72, 0.35); }
      else { dir = vec3(-f.x, f.y, -1.0); faceTint = vec3(0.65, 0.55, 1.0); }
    } else if (cell.x == 1.0 && cell.y == 2.0) {
      valid = true;
      dir = vec3(f.x, 1.0, -f.y);
      faceTint = vec3(0.45, 1.0, 0.65);
    } else if (cell.x == 1.0 && cell.y == 0.0) {
      valid = true;
      dir = vec3(f.x, -1.0, f.y);
      faceTint = vec3(0.85, 0.65, 0.45);
    }

    if (valid) {
      col = evalCubemap(dir, rough, sunElev);
      // Clean cubemap face border
      float edge = smoothstep(0.93, 0.985, max(abs(f.x), abs(f.y)));
      col = mix(col, faceTint * 1.15, edge);
    } else {
      vec2 bgG = abs(fract(p * 18.0) - 0.5);
      col = vec3(0.05, 0.06, 0.09) + vec3(0.025, 0.035, 0.05) * smoothstep(0.06, 0.01, min(0.5 - bgG.x, 0.5 - bgG.y));
    }
  } else {
    // Right: Seamless 3D skybox + chrome mirror ball (center) + prefiltered glossy/diffuse companion spheres
    vec3 ro = vec3(2.35 * sin(orb), 0.16, 2.35 * cos(orb));
    vec3 fw = normalize(-ro);
    vec3 ri = normalize(cross(fw, vec3(0.0, 1.0, 0.0)));
    vec3 up = cross(ri, fw);
    vec3 rd = normalize(fw * 1.38 + ri * (uv.x - 0.18) + up * uv.y);

    col = evalCubemap(rd, 0.0, sunElev);

    // Intersect 3 IBL chrome/glossy/matte spheres
    vec3 centers[3];
    float radii[3];
    float rVals[3];
    centers[0] = vec3(0.0, 0.02, 0.0); radii[0] = 0.52; rVals[0] = rough;
    centers[1] = vec3(-0.74, -0.22, 0.25); radii[1] = 0.24; rVals[1] = 0.03;
    centers[2] = vec3(0.74, -0.22, -0.18); radii[2] = 0.24; rVals[2] = 0.82;

    float bestT = 1e5;
    int bestI = -1;
    for (int i = 0; i < 3; i++) {
      vec3 oc = ro - centers[i];
      float b = dot(oc, rd);
      float c = dot(oc, oc) - radii[i] * radii[i];
      float disc = b * b - c;
      if (disc > 0.0) {
        float t = -b - sqrt(disc);
        if (t > 0.05 && t < bestT) { bestT = t; bestI = i; }
      }
    }

    if (bestI >= 0) {
      vec3 p = ro + rd * bestT;
      vec3 n = normalize(p - centers[bestI]);
      vec3 v = -rd;
      vec3 rDir = reflect(-v, n);
      float r = rVals[bestI];
      vec3 f0 = (bestI == 0) ? vec3(0.95, 0.78, 0.45) : ((bestI == 1) ? vec3(0.94) : vec3(0.32, 0.48, 0.62));
      float ndv = max(dot(n, v), 0.0);
      vec3 F = f0 + (1.0 - f0) * pow(1.0 - ndv, 5.0);
      vec3 specIBL = evalCubemap(rDir, r, sunElev);
      vec3 diffIBL = evalCubemap(n, 0.92, sunElev) * 0.55;
      col = mix(specIBL * F, diffIBL * f0 + specIBL * F * 0.35, r * 0.75);
    }
  }

  float sep = smoothstep(0.0035, 0.0008, abs(sx - split));
  col = mix(col, vec3(0.95, 0.97, 1.0), sep);
  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extended by [Reflection probes with parallax-corrected cubemaps](https://texelatlas.vercel.app/t/reflection-probes-parallax-corrected-cubemaps.md)

## Combines with

- [Split-Sum Image-Based Lighting](https://texelatlas.vercel.app/t/split-sum-ibl.md): The raw environment map is the input that gets convolved per roughness into the prefiltered mip chain.
- [Spherical-Harmonic Lighting (Irradiance Environment Maps)](https://texelatlas.vercel.app/t/spherical-harmonics-lighting.md): The same map projects to nine SH coefficients for cheap diffuse lighting.
- [Scalable Production Sky and Atmosphere (Hillaire)](https://texelatlas.vercel.app/t/hillaire-sky-atmosphere.md): A rendered sky can be captured into a cubemap each time the sun moves, giving a dynamic environment.

## Sources

1. [primary] Ned Greene (1986) Environment Mapping and Other Applications of World Projections. IEEE Computer Graphics and Applications. https://doi.org/10.1109/mcg.1986.276658 (verified via crossref on 2026-11-29)
2. [tutorial] Romain Guy, Mathias Agopian Filament: Physically based rendering (image based lights section). google.github.io. https://google.github.io/filament/Filament.html (verified via http on 2026-11-29)
3. [implementation] google (2018) google/filament. https://github.com/google/filament License: Apache-2.0. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Environment mapping, cubemaps and skyboxes." https://texelatlas.vercel.app/t/environment-mapping-cubemaps/ (accessed 2026-12-01).
