Techniquecore
Image-based lighting
Also called IBL.
Light a scene with a captured high dynamic range image of the real surroundings, treating each texel as a distant light source.
Image-based lighting lights a scene with a picture of real or rendered surroundings. The picture is a high dynamic range map of the radiance that arrives at one point from every direction, often made from photos of a mirror ball or from a panoramic camera at several exposures. Each texel acts as a light source at infinite distance. The light that a surface reflects toward the eye is then the integral, over all directions, of that radiance times the BRDF times the cosine, the local part of the rendering equation with the environment as the only source. An offline renderer estimates the integral by Monte Carlo integration, with importance sampling of the BRDF or of the bright parts of the map. A real-time renderer precomputes it: an irradiance environment map for the diffuse part, and the split sum approximation for the glossy part. Debevec (1998) made the method common for placing synthetic objects into photographs.
In plain words
To make a computer object look like it belongs in a real place, light it with the light of that place. Take photos in every direction from where the object should stand, at several exposures, so that both the dark corners and the bright sun are recorded. This gives one image of all the light that arrives at that spot. Then treat every pixel of that image as a small lamp very far away. A matte part of the object sums the light from the half of the image it faces. A shiny part mostly shows the image in its mirror direction. Doing this sum for every pixel is slow, so games do most of the work once, ahead of time, and store the results in small textures.
When it applies
- The light comes mostly from far away, compared to the size of the lit objects: outdoors under a sky, or a small object in a large room.
- A record of that light exists, or can be made: a photographed light probe, a rendered cube map, or an analytic sky.
- The renderer needs light from every direction, including soft light from the sky and colored bounce light from the ground, which a few point lights do not give.
- The lighting is about the same over the object, so one map can serve all of its points. Where it is not, several maps are placed in space, as probes.
The template
IBL-SHADE(p, n, v, L_env, f)- 1
L_env ← linear HDR radiance map of the surroundings of p ▷ hole: capture or render - 2
reference: L_o ← (1/N) Σ_k L_env(l_k) f(l_k, v) max(n · l_k, 0) / pdf(l_k) ▷ N samples l_k - 3
real time, diffuse: D ← (ρ / π) · E(n) ▷ E from an irradiance map - 4
real time, specular: S ← P(r, α) · (F_0 · A(α, n · v) + B(α, n · v)) ▷ split sum - 5
return V · (D + S) ▷ hole: occlusion V
The map (line L1). The map must hold linear radiance, not display values, and its range must include the sun and lamps; a map clipped at the brightest texels loses most of the energy of a sunny day. Photos at several exposures are merged into one HDR image. The map is valid at the point where it was taken.
The reference estimate (line L2). This is Monte Carlo integration of the reflected radiance. The sample directions come from a density that follows the BRDF lobe, the cosine, or the brightness of the map; multiple importance sampling combines these. The estimate is unbiased for any density that is positive wherever the integrand is not zero (a proved property of importance sampling), and its noise falls as .
The diffuse part (line L3). For a Lambertian surface with albedo , the integral is , with the irradiance for the normal . It depends only on , so it can be stored per normal: as a convolved cube map, or as nine spherical harmonic coefficients.
The specular part (line L4). For a glossy microfacet BRDF, the integral depends on , and the roughness . The split sum approximation stores a map prefiltered by the lobe per roughness, looked up at the reflected direction , and a 2D table of the scale and the bias of .
Occlusion (line L5). The map does not know about the object itself, so parts of the object that hide the sky from a point are ignored. A factor from ambient occlusion darkens such points (a heuristic). Precomputed radiance transfer includes the shadowing in the precomputation instead.
Classic examples
- Synthetic objects in photographs. Debevec (1998) lit objects with a light probe of a real scene in a global illumination renderer, and composited them with differential rendering: the photo plus the difference between renders of a local scene model with and without the objects, which adds their shadows and reflections.
- Diffuse light in games. The irradiance environment map turns line L3 into a quadratic form in the normal, a few multiply-adds per pixel.
- Glossy reflections in games. The split sum approximation turns line L4 into one cube map lookup and one 2D table lookup.
- Probes in space. An irradiance volume stores many small diffuse maps on a grid, so that the light can change across a level.
- Shadows from the environment. Precomputed radiance transfer precomputes how each point of a static object sees the map, including its own shadows.
Variations
- Sampling the map. For maps with a small bright sun, sampling by the brightness of the map, with a 2D table of its distribution, removes most of the noise of line L2. For rough surfaces, sampling the BRDF is better; multiple importance sampling uses both.
- Extracting the sun. Remove the brightest texels into one directional light with a sharp shadow map, and light the rest with the smooth map. This keeps hard shadows, which a map alone gives only at high sample counts.
- Spherical harmonics. Store the whole map as a few spherical harmonic coefficients. This is enough for diffuse light and cheap to rotate and blend, but too blurry for glossy reflection.
- Local maps. Render maps at several points of a level and blend them by position, with a box or sphere proxy to correct the parallax of reflections, see environment mapping.
- Dynamic maps. Render the map from the scene at run time and prefilter it on the GPU, so that the lighting follows changes in the scene or the time of day.
Pitfalls
- Clipped range at line L1. A map stored in 8 bits, or a photo with a saturated sun, loses the strongest light. The scene then looks flat and has no clear shadows. Merge several exposures, or add the sun back as a separate light.
- Display values at line L1. A map in sRGB or tone mapped values is not radiance. Decode it to linear values before any integral, see gamma correction, and apply tone mapping only to the final image.
- Noise at line L2. A few BRDF samples of a map with a small bright source give fireflies. Sample the map as well, or use more samples.
- Double counting at line L5. If the sun is extracted as a separate light, remove it from the map, or the surfaces get its light twice.
- Units and scale. The map of a real place has an absolute brightness that the exposure of the camera sets. Mixing it with analytic lights in other units gives the wrong balance; calibrate the map, for example with a gray card or a light meter reading.
- The distant light assumption. A map taken at one point is wrong for points far from it, and for objects close to the walls. Use several probes, or a local correction, when the object moves through the scene.
Exercises
- A white Lambertian surface () sits under a uniform environment of radiance . Show that it reflects radiance for every normal. Answer: , so . This is the white furnace test of a renderer.
- In line L2 for the surface of Exercise 1, take the density . Show that every sample gives exactly , so the estimate has no variance. Answer: each term is .
- The sun covers about sr of the sky. With BRDF sampling of a diffuse surface, about what fraction of the samples hit the sun when it is straight above? Answer: the cosine density near the normal is per steradian, so about , one sample in about 46000. This is why the sun is sampled or extracted separately.
References
- Paul Debevec, Rendering synthetic objects into real scenes, bridging traditional and image-based graphics with global illumination and high dynamic range photography, SIGGRAPH 98, 189 to 198, the light probe image of the real scene, its use as distant illumination in a global illumination renderer, and the differential rendering that composites synthetic objects into photographs (general locator)
- Gene S. Miller and C. Robert Hoffman, Illumination and Reflection Maps, Simulated Objects in Simulated and Real Environments, SIGGRAPH 84 course notes, Advanced Computer Graphics Animation, maps of real surroundings photographed at several exposures and convolved for diffuse and glossy reflection
- Brian Karis, Real Shading in Unreal Engine 4, SIGGRAPH 2013 course Physically Based Shading in Theory and Practice, the section on image-based lighting (importance sampling of the GGX lobe, the split sum, the prefiltered environment map and the environment BRDF)
- Tomas Akenine-Möller, Eric Haines, Naty Hoffman, Angelo Pesce, Michał Iwanicki and Sébastien Hillaire, Real-Time Rendering, fourth edition, CRC Press, 2018, Chapter 10, Local Illumination (the parts on environment lighting and its prefiltering)
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W3 standard |
|
Tag KFMF0H Edit this page History Report an error Markdown