Environment mapping, cubemaps and skyboxes
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.
Also known as cube mapping, skybox, reflection mapping, HDRI backdrop, environment map
In the family Light transport & global illumination, image-based lighting
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Built in | scene.background = scene.environment = cubeTexture (CubeTextureLoader) docs |
| Babylon.js 9.38.0 | Built in | new BABYLON.CubeTexture(url, scene); scene.environmentTexture docs |
| Godot 4.7 | Built in | WorldEnvironment > Environment.background_mode = BG_SKY with a Sky (PanoramaSkyMaterial for HDRI) docs |
| Unity | Built in | Lighting > Environment > Skybox Material (cubemap/panoramic); HDRP Volume > Visual Environment = HDRI Sky docs |
| Unreal 5.7 | Built in | Sky Light with a manually specified cubemap docs |
| Blender 5.2 | Built in | World > Surface > Environment Texture node docs Equirectangular and mirror-ball projections; no native cubemap type. |
| WebGPU W3C | Built in | createTexture(6 layers) + createView({dimension:'cube'}); WGSL texture_cube<f32> docs Cube view and sampling are primitives; skybox pass is yours. |
| Metal | Built in | MTLTextureType.typeCube; MSL texturecube<float> docs Cube textures and sampling are primitives; skybox pass is yours. |
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 Image-Based Lighting) or project it into Spherical-Harmonic Lighting (Irradiance Environment Maps). 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 Model, Scalable Production Sky and Atmosphere (Hillaire)), or a capture from the scene itself.
When to choose it
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
Choose it for the backdrop, for sky and studio lighting, and for reflections of things that are effectively at infinity.
Prefer Reflection probes with parallax-corrected cubemaps for interiors, where finite room size makes plain lookups look pasted on. Prefer Screen-space reflections or Unidirectional Path Tracing when nearby dynamic objects must appear in reflections. Prefer Split-Sum Image-Based Lighting for glossy PBR lighting from the same map rather than raw reflect lookups.
Field marks
- 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
Presets
Environment Mapping & Cubemaps — unfolded 6-face cubemap cross & mip blur (left) vs seamless 3D skybox & glossy IBL spheres (right)
{
"P_ROUGHNESS": 0.18,
"P_SUN_ELEV": 0.36,
"P_CAM_ORBIT": 0.35,
"P_SPLIT": 0.46
}Show GLSL (143 lines)
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.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| environment-mapping-cubemaps-live | Tesla T4 1920x1080 | 4.91× baseline (light) · 0.162 ms / 0.171 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| environment-mapping-cubemaps-live | NVIDIA L4 1920x1080 | 4.26× baseline (light) · 0.068 ms / 0.071 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| environment-mapping-cubemaps-live | NVIDIA A100-SXM4-40GB 1920x1080 | 3.49× baseline (light) · 0.100 ms / 0.104 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): cited by Mipmapping and anisotropic texture filtering, Precomputed Radiance Transfer, Spherical-Harmonic Lighting (Irradiance Environment Maps).
Crosses
- Split-Sum Image-Based Lighting: The raw environment map is the input that gets convolved per roughness into the prefiltered mip chain.
- Spherical-Harmonic Lighting (Irradiance Environment Maps): The same map projects to nine SH coefficients for cheap diffuse lighting.
- Scalable Production Sky and Atmosphere (Hillaire): A rendered sky can be captured into a cubemap each time the sun moves, giving a dynamic environment.
Sources
- primaryNed Greene (1986). Environment Mapping and Other Applications of World Projections. IEEE Computer Graphics and Applications.Verified via crossref · 2026-11-29doi:10.1109/mcg.1986.276658
- tutorialRomain Guy, Mathias Agopian. Filament: Physically based rendering (image based lights section). google.github.io.Verified via live page · 2026-11-29
- implementationgoogle (2018). google/filament. Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, WebGPU, and WebGL2GitHub API · license Apache-2.0 · 2026-11-29