- Irradiance - Light that shines on object surfaces from the environment
- Reflections - Specular component for reflective surfaces
Overview
Environments are usually captured as high-resolution HDR equirectangular images and processed by the cmgen tool to generate the data needed by IndirectLight.Currently IndirectLight is intended for “distant probes” - global illumination from a distant environment at infinity, such as the sky or distant mountains. Only a single IndirectLight can be used in a Scene.
Creation and Destruction
An IndirectLight object is created using the IndirectLight::Builder and destroyed by callingEngine::destroy(const IndirectLight*).
Builder Methods
Constructor
Creates an IndirectLight builder.reflections
Set the reflections cubemap mipmap chain.A mip-mapped cubemap generated by cmgen. Each cubemap level encodes the irradiance for a roughness level
This Builder, for chaining calls
irradiance (Spherical Harmonics)
Sets the irradiance as Spherical Harmonics.Number of spherical harmonics bands. Must be 1, 2, or 3
Array containing the spherical harmonics coefficients. Size must be bands² (1, 4, or 9 coefficients)
This Builder, for chaining calls
The irradiance must be pre-convolved and pre-multiplied by the Lambertian BRDF (1/π). The cmgen tool generates these coefficients automatically.
Spherical Harmonics Indexing
The index in the sh array is given by:index(l, m) = l * (l + 1) + m
| Index | l | m | A_l^m | Normalized |
|---|---|---|---|---|
| 0 | 0 | 0 | 0.282095 | 0.282095 |
| 1 | 1 | -1 | -0.488602 | -0.325735 |
| 2 | 1 | 0 | 0.488602 | 0.325735 |
| 3 | 1 | 1 | -0.488602 | -0.325735 |
| 4 | 2 | -2 | 1.092548 | 0.273137 |
| 5 | 2 | -1 | -1.092548 | -0.273137 |
| 6 | 2 | 0 | 0.315392 | 0.078848 |
| 7 | 2 | 1 | -1.092548 | -0.273137 |
| 8 | 2 | 2 | 0.546274 | 0.136569 |
radiance
Sets the irradiance from the radiance expressed as Spherical Harmonics.Number of spherical harmonics bands. Must be 1, 2, or 3
Array containing the spherical harmonics coefficients L_l^m. Size must be bands² (1, 4, or 9 coefficients)
This Builder, for chaining calls
irradiance (Cubemap)
Sets the irradiance as a cubemap.Cubemap representing the irradiance pre-convolved by ⟨n·l⟩
This Builder, for chaining calls
This irradiance cubemap can be generated with the cmgen tool. Using a cubemap may be more or less efficient than Spherical Harmonics depending on your hardware (trading ALU for bandwidth).
intensity
Environment intensity.Scale factor applied to the environment and irradiance such that the result is in lux (lumen/m²)
This Builder, for chaining calls
rotation
Specifies the rigid-body transformation to apply to the IBL.3x3 rotation matrix. Must be a rigid-body transform
This Builder, for chaining calls
build
Creates the IndirectLight object and returns a pointer to it.Reference to the filament::Engine to associate this IndirectLight with
Pointer to the newly created object, or nullptr if an error occurred
Instance Methods
setIntensity
Sets the environment’s intensity.Scale factor applied to the environment and irradiance such that the result is in lux (lumen/m²)
getIntensity
Returns the environment’s intensity in lux (lumen/m²).Intensity in lux
setRotation
Sets the rigid-body transformation to apply to the IBL.3x3 rotation matrix. Must be a rigid-body transform
getRotation
Returns the rigid-body transformation applied to the IBL.The rotation matrix
getReflectionsTexture
Returns the associated reflection map, or null if it does not exist.The reflections texture, or nullptr
getIrradianceTexture
Returns the associated irradiance map, or null if it does not exist.The irradiance texture, or nullptr
Helper Methods
getDirectionEstimate (Static)
Helper to estimate the direction of the dominant light in the environment.3-band spherical harmonics coefficients
A unit vector representing the direction of the dominant light
getColorEstimate (Static)
Helper to estimate the color and relative intensity of the environment in a given direction.3-band spherical harmonics coefficients
A unit vector representing the direction to estimate. Typically from getDirectionEstimate()
First 3 components are linear color, 4th component is relative intensity
getDirectionEstimate (Instance)
Helper to estimate the direction of the dominant light.A unit vector representing the direction of the dominant light
Spherical harmonics must be set in the Builder or the result is undefined.
getColorEstimate (Instance)
Helper to estimate the color and relative intensity in a given direction.A unit vector representing the direction to estimate
First 3 components are linear color, 4th component is relative intensity
Complete Example
Using cmgen
The cmgen tool processes HDR environment maps and generates the data needed for IndirectLight:Best Practices
- Use cmgen to generate properly formatted IBL data from HDR images
- Match directional light to the environment using
getDirectionEstimate()andgetColorEstimate() - Adjust intensity based on your scene’s lighting requirements (default 30000 lux is for outdoor scenes)
- Rotate the environment if needed to align with your scene’s lighting direction
- One IndirectLight per Scene - Currently only one is supported